babylon.module.d.ts 4.9 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708
  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. * Notify all Observers by calling their respective callback with the given data
  4356. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  4357. * @param eventData defines the data to send to all observers
  4358. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  4359. * @param target defines the original target of the state
  4360. * @param currentTarget defines the current target of the state
  4361. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  4362. */
  4363. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  4364. /**
  4365. * Calling this will execute each callback, expecting it to be a promise or return a value.
  4366. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  4367. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  4368. * and it is crucial that all callbacks will be executed.
  4369. * The order of the callbacks is kept, callbacks are not executed parallel.
  4370. *
  4371. * @param eventData The data to be sent to each callback
  4372. * @param mask is used to filter observers defaults to -1
  4373. * @param target defines the callback target (see EventState)
  4374. * @param currentTarget defines he current object in the bubbling phase
  4375. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  4376. */
  4377. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  4378. /**
  4379. * Notify a specific observer
  4380. * @param observer defines the observer to notify
  4381. * @param eventData defines the data to be sent to each callback
  4382. * @param mask is used to filter observers defaults to -1
  4383. */
  4384. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  4385. /**
  4386. * Gets a boolean indicating if the observable has at least one observer
  4387. * @returns true is the Observable has at least one Observer registered
  4388. */
  4389. hasObservers(): boolean;
  4390. /**
  4391. * Clear the list of observers
  4392. */
  4393. clear(): void;
  4394. /**
  4395. * Clone the current observable
  4396. * @returns a new observable
  4397. */
  4398. clone(): Observable<T>;
  4399. /**
  4400. * Does this observable handles observer registered with a given mask
  4401. * @param mask defines the mask to be tested
  4402. * @return whether or not one observer registered with the given mask is handeled
  4403. **/
  4404. hasSpecificMask(mask?: number): boolean;
  4405. }
  4406. }
  4407. declare module "babylonjs/Misc/filesInputStore" {
  4408. /**
  4409. * Class used to help managing file picking and drag'n'drop
  4410. * File Storage
  4411. */
  4412. export class FilesInputStore {
  4413. /**
  4414. * List of files ready to be loaded
  4415. */
  4416. static FilesToLoad: {
  4417. [key: string]: File;
  4418. };
  4419. }
  4420. }
  4421. declare module "babylonjs/Engines/constants" {
  4422. /** Defines the cross module used constants to avoid circular dependncies */
  4423. export class Constants {
  4424. /** Defines that alpha blending is disabled */
  4425. static readonly ALPHA_DISABLE: number;
  4426. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  4427. static readonly ALPHA_ADD: number;
  4428. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  4429. static readonly ALPHA_COMBINE: number;
  4430. /** Defines that alpha blending to DEST - SRC * DEST */
  4431. static readonly ALPHA_SUBTRACT: number;
  4432. /** Defines that alpha blending to SRC * DEST */
  4433. static readonly ALPHA_MULTIPLY: number;
  4434. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  4435. static readonly ALPHA_MAXIMIZED: number;
  4436. /** Defines that alpha blending to SRC + DEST */
  4437. static readonly ALPHA_ONEONE: number;
  4438. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  4439. static readonly ALPHA_PREMULTIPLIED: number;
  4440. /**
  4441. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  4442. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  4443. */
  4444. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  4445. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  4446. static readonly ALPHA_INTERPOLATE: number;
  4447. /**
  4448. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  4449. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  4450. */
  4451. static readonly ALPHA_SCREENMODE: number;
  4452. /** Defines that the ressource is not delayed*/
  4453. static readonly DELAYLOADSTATE_NONE: number;
  4454. /** Defines that the ressource was successfully delay loaded */
  4455. static readonly DELAYLOADSTATE_LOADED: number;
  4456. /** Defines that the ressource is currently delay loading */
  4457. static readonly DELAYLOADSTATE_LOADING: number;
  4458. /** Defines that the ressource is delayed and has not started loading */
  4459. static readonly DELAYLOADSTATE_NOTLOADED: number;
  4460. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  4461. static readonly NEVER: number;
  4462. /** 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 */
  4463. static readonly ALWAYS: number;
  4464. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  4465. static readonly LESS: number;
  4466. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  4467. static readonly EQUAL: number;
  4468. /** 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 */
  4469. static readonly LEQUAL: number;
  4470. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  4471. static readonly GREATER: number;
  4472. /** 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 */
  4473. static readonly GEQUAL: number;
  4474. /** 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 */
  4475. static readonly NOTEQUAL: number;
  4476. /** Passed to stencilOperation to specify that stencil value must be kept */
  4477. static readonly KEEP: number;
  4478. /** Passed to stencilOperation to specify that stencil value must be replaced */
  4479. static readonly REPLACE: number;
  4480. /** Passed to stencilOperation to specify that stencil value must be incremented */
  4481. static readonly INCR: number;
  4482. /** Passed to stencilOperation to specify that stencil value must be decremented */
  4483. static readonly DECR: number;
  4484. /** Passed to stencilOperation to specify that stencil value must be inverted */
  4485. static readonly INVERT: number;
  4486. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  4487. static readonly INCR_WRAP: number;
  4488. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  4489. static readonly DECR_WRAP: number;
  4490. /** Texture is not repeating outside of 0..1 UVs */
  4491. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  4492. /** Texture is repeating outside of 0..1 UVs */
  4493. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  4494. /** Texture is repeating and mirrored */
  4495. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  4496. /** ALPHA */
  4497. static readonly TEXTUREFORMAT_ALPHA: number;
  4498. /** LUMINANCE */
  4499. static readonly TEXTUREFORMAT_LUMINANCE: number;
  4500. /** LUMINANCE_ALPHA */
  4501. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  4502. /** RGB */
  4503. static readonly TEXTUREFORMAT_RGB: number;
  4504. /** RGBA */
  4505. static readonly TEXTUREFORMAT_RGBA: number;
  4506. /** RED */
  4507. static readonly TEXTUREFORMAT_RED: number;
  4508. /** RED (2nd reference) */
  4509. static readonly TEXTUREFORMAT_R: number;
  4510. /** RG */
  4511. static readonly TEXTUREFORMAT_RG: number;
  4512. /** RED_INTEGER */
  4513. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  4514. /** RED_INTEGER (2nd reference) */
  4515. static readonly TEXTUREFORMAT_R_INTEGER: number;
  4516. /** RG_INTEGER */
  4517. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  4518. /** RGB_INTEGER */
  4519. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  4520. /** RGBA_INTEGER */
  4521. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  4522. /** UNSIGNED_BYTE */
  4523. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  4524. /** UNSIGNED_BYTE (2nd reference) */
  4525. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  4526. /** FLOAT */
  4527. static readonly TEXTURETYPE_FLOAT: number;
  4528. /** HALF_FLOAT */
  4529. static readonly TEXTURETYPE_HALF_FLOAT: number;
  4530. /** BYTE */
  4531. static readonly TEXTURETYPE_BYTE: number;
  4532. /** SHORT */
  4533. static readonly TEXTURETYPE_SHORT: number;
  4534. /** UNSIGNED_SHORT */
  4535. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  4536. /** INT */
  4537. static readonly TEXTURETYPE_INT: number;
  4538. /** UNSIGNED_INT */
  4539. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  4540. /** UNSIGNED_SHORT_4_4_4_4 */
  4541. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  4542. /** UNSIGNED_SHORT_5_5_5_1 */
  4543. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  4544. /** UNSIGNED_SHORT_5_6_5 */
  4545. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  4546. /** UNSIGNED_INT_2_10_10_10_REV */
  4547. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  4548. /** UNSIGNED_INT_24_8 */
  4549. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  4550. /** UNSIGNED_INT_10F_11F_11F_REV */
  4551. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  4552. /** UNSIGNED_INT_5_9_9_9_REV */
  4553. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  4554. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  4555. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  4556. /** nearest is mag = nearest and min = nearest and mip = linear */
  4557. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  4558. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4559. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  4560. /** Trilinear is mag = linear and min = linear and mip = linear */
  4561. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  4562. /** nearest is mag = nearest and min = nearest and mip = linear */
  4563. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  4564. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4565. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  4566. /** Trilinear is mag = linear and min = linear and mip = linear */
  4567. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  4568. /** mag = nearest and min = nearest and mip = nearest */
  4569. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  4570. /** mag = nearest and min = linear and mip = nearest */
  4571. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  4572. /** mag = nearest and min = linear and mip = linear */
  4573. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  4574. /** mag = nearest and min = linear and mip = none */
  4575. static readonly TEXTURE_NEAREST_LINEAR: number;
  4576. /** mag = nearest and min = nearest and mip = none */
  4577. static readonly TEXTURE_NEAREST_NEAREST: number;
  4578. /** mag = linear and min = nearest and mip = nearest */
  4579. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  4580. /** mag = linear and min = nearest and mip = linear */
  4581. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  4582. /** mag = linear and min = linear and mip = none */
  4583. static readonly TEXTURE_LINEAR_LINEAR: number;
  4584. /** mag = linear and min = nearest and mip = none */
  4585. static readonly TEXTURE_LINEAR_NEAREST: number;
  4586. /** Explicit coordinates mode */
  4587. static readonly TEXTURE_EXPLICIT_MODE: number;
  4588. /** Spherical coordinates mode */
  4589. static readonly TEXTURE_SPHERICAL_MODE: number;
  4590. /** Planar coordinates mode */
  4591. static readonly TEXTURE_PLANAR_MODE: number;
  4592. /** Cubic coordinates mode */
  4593. static readonly TEXTURE_CUBIC_MODE: number;
  4594. /** Projection coordinates mode */
  4595. static readonly TEXTURE_PROJECTION_MODE: number;
  4596. /** Skybox coordinates mode */
  4597. static readonly TEXTURE_SKYBOX_MODE: number;
  4598. /** Inverse Cubic coordinates mode */
  4599. static readonly TEXTURE_INVCUBIC_MODE: number;
  4600. /** Equirectangular coordinates mode */
  4601. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  4602. /** Equirectangular Fixed coordinates mode */
  4603. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  4604. /** Equirectangular Fixed Mirrored coordinates mode */
  4605. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  4606. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  4607. static readonly SCALEMODE_FLOOR: number;
  4608. /** Defines that texture rescaling will look for the nearest power of 2 size */
  4609. static readonly SCALEMODE_NEAREST: number;
  4610. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  4611. static readonly SCALEMODE_CEILING: number;
  4612. /**
  4613. * The dirty texture flag value
  4614. */
  4615. static readonly MATERIAL_TextureDirtyFlag: number;
  4616. /**
  4617. * The dirty light flag value
  4618. */
  4619. static readonly MATERIAL_LightDirtyFlag: number;
  4620. /**
  4621. * The dirty fresnel flag value
  4622. */
  4623. static readonly MATERIAL_FresnelDirtyFlag: number;
  4624. /**
  4625. * The dirty attribute flag value
  4626. */
  4627. static readonly MATERIAL_AttributesDirtyFlag: number;
  4628. /**
  4629. * The dirty misc flag value
  4630. */
  4631. static readonly MATERIAL_MiscDirtyFlag: number;
  4632. /**
  4633. * The all dirty flag value
  4634. */
  4635. static readonly MATERIAL_AllDirtyFlag: number;
  4636. /**
  4637. * Returns the triangle fill mode
  4638. */
  4639. static readonly MATERIAL_TriangleFillMode: number;
  4640. /**
  4641. * Returns the wireframe mode
  4642. */
  4643. static readonly MATERIAL_WireFrameFillMode: number;
  4644. /**
  4645. * Returns the point fill mode
  4646. */
  4647. static readonly MATERIAL_PointFillMode: number;
  4648. /**
  4649. * Returns the point list draw mode
  4650. */
  4651. static readonly MATERIAL_PointListDrawMode: number;
  4652. /**
  4653. * Returns the line list draw mode
  4654. */
  4655. static readonly MATERIAL_LineListDrawMode: number;
  4656. /**
  4657. * Returns the line loop draw mode
  4658. */
  4659. static readonly MATERIAL_LineLoopDrawMode: number;
  4660. /**
  4661. * Returns the line strip draw mode
  4662. */
  4663. static readonly MATERIAL_LineStripDrawMode: number;
  4664. /**
  4665. * Returns the triangle strip draw mode
  4666. */
  4667. static readonly MATERIAL_TriangleStripDrawMode: number;
  4668. /**
  4669. * Returns the triangle fan draw mode
  4670. */
  4671. static readonly MATERIAL_TriangleFanDrawMode: number;
  4672. /**
  4673. * Stores the clock-wise side orientation
  4674. */
  4675. static readonly MATERIAL_ClockWiseSideOrientation: number;
  4676. /**
  4677. * Stores the counter clock-wise side orientation
  4678. */
  4679. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  4680. /**
  4681. * Nothing
  4682. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4683. */
  4684. static readonly ACTION_NothingTrigger: number;
  4685. /**
  4686. * On pick
  4687. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4688. */
  4689. static readonly ACTION_OnPickTrigger: number;
  4690. /**
  4691. * On left pick
  4692. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4693. */
  4694. static readonly ACTION_OnLeftPickTrigger: number;
  4695. /**
  4696. * On right pick
  4697. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4698. */
  4699. static readonly ACTION_OnRightPickTrigger: number;
  4700. /**
  4701. * On center pick
  4702. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4703. */
  4704. static readonly ACTION_OnCenterPickTrigger: number;
  4705. /**
  4706. * On pick down
  4707. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4708. */
  4709. static readonly ACTION_OnPickDownTrigger: number;
  4710. /**
  4711. * On double pick
  4712. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4713. */
  4714. static readonly ACTION_OnDoublePickTrigger: number;
  4715. /**
  4716. * On pick up
  4717. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4718. */
  4719. static readonly ACTION_OnPickUpTrigger: number;
  4720. /**
  4721. * On pick out.
  4722. * This trigger will only be raised if you also declared a OnPickDown
  4723. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4724. */
  4725. static readonly ACTION_OnPickOutTrigger: number;
  4726. /**
  4727. * On long press
  4728. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4729. */
  4730. static readonly ACTION_OnLongPressTrigger: number;
  4731. /**
  4732. * On pointer over
  4733. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4734. */
  4735. static readonly ACTION_OnPointerOverTrigger: number;
  4736. /**
  4737. * On pointer out
  4738. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4739. */
  4740. static readonly ACTION_OnPointerOutTrigger: number;
  4741. /**
  4742. * On every frame
  4743. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4744. */
  4745. static readonly ACTION_OnEveryFrameTrigger: number;
  4746. /**
  4747. * On intersection enter
  4748. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4749. */
  4750. static readonly ACTION_OnIntersectionEnterTrigger: number;
  4751. /**
  4752. * On intersection exit
  4753. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4754. */
  4755. static readonly ACTION_OnIntersectionExitTrigger: number;
  4756. /**
  4757. * On key down
  4758. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4759. */
  4760. static readonly ACTION_OnKeyDownTrigger: number;
  4761. /**
  4762. * On key up
  4763. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4764. */
  4765. static readonly ACTION_OnKeyUpTrigger: number;
  4766. /**
  4767. * Billboard mode will only apply to Y axis
  4768. */
  4769. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  4770. /**
  4771. * Billboard mode will apply to all axes
  4772. */
  4773. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  4774. /**
  4775. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  4776. */
  4777. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  4778. /**
  4779. * Gets or sets base Assets URL
  4780. */
  4781. static readonly PARTICLES_BaseAssetsUrl: string;
  4782. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  4783. * Test order :
  4784. * Is the bounding sphere outside the frustum ?
  4785. * If not, are the bounding box vertices outside the frustum ?
  4786. * It not, then the cullable object is in the frustum.
  4787. */
  4788. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  4789. /** Culling strategy : Bounding Sphere Only.
  4790. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  4791. * It's also less accurate than the standard because some not visible objects can still be selected.
  4792. * Test : is the bounding sphere outside the frustum ?
  4793. * If not, then the cullable object is in the frustum.
  4794. */
  4795. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  4796. /** Culling strategy : Optimistic Inclusion.
  4797. * This in an inclusion test first, then the standard exclusion test.
  4798. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  4799. * 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.
  4800. * Anyway, it's as accurate as the standard strategy.
  4801. * Test :
  4802. * Is the cullable object bounding sphere center in the frustum ?
  4803. * If not, apply the default culling strategy.
  4804. */
  4805. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  4806. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  4807. * This in an inclusion test first, then the bounding sphere only exclusion test.
  4808. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  4809. * 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.
  4810. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  4811. * Test :
  4812. * Is the cullable object bounding sphere center in the frustum ?
  4813. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  4814. */
  4815. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  4816. /**
  4817. * No logging while loading
  4818. */
  4819. static readonly SCENELOADER_NO_LOGGING: number;
  4820. /**
  4821. * Minimal logging while loading
  4822. */
  4823. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  4824. /**
  4825. * Summary logging while loading
  4826. */
  4827. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  4828. /**
  4829. * Detailled logging while loading
  4830. */
  4831. static readonly SCENELOADER_DETAILED_LOGGING: number;
  4832. }
  4833. }
  4834. declare module "babylonjs/Misc/domManagement" {
  4835. /**
  4836. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  4837. * Babylon.js
  4838. */
  4839. export class DomManagement {
  4840. /**
  4841. * Checks if the window object exists
  4842. * @returns true if the window object exists
  4843. */
  4844. static IsWindowObjectExist(): boolean;
  4845. /**
  4846. * Extracts text content from a DOM element hierarchy
  4847. * @param element defines the root element
  4848. * @returns a string
  4849. */
  4850. static GetDOMTextContent(element: HTMLElement): string;
  4851. }
  4852. }
  4853. declare module "babylonjs/Misc/logger" {
  4854. /**
  4855. * Logger used througouht the application to allow configuration of
  4856. * the log level required for the messages.
  4857. */
  4858. export class Logger {
  4859. /**
  4860. * No log
  4861. */
  4862. static readonly NoneLogLevel: number;
  4863. /**
  4864. * Only message logs
  4865. */
  4866. static readonly MessageLogLevel: number;
  4867. /**
  4868. * Only warning logs
  4869. */
  4870. static readonly WarningLogLevel: number;
  4871. /**
  4872. * Only error logs
  4873. */
  4874. static readonly ErrorLogLevel: number;
  4875. /**
  4876. * All logs
  4877. */
  4878. static readonly AllLogLevel: number;
  4879. private static _LogCache;
  4880. /**
  4881. * Gets a value indicating the number of loading errors
  4882. * @ignorenaming
  4883. */
  4884. static errorsCount: number;
  4885. /**
  4886. * Callback called when a new log is added
  4887. */
  4888. static OnNewCacheEntry: (entry: string) => void;
  4889. private static _AddLogEntry;
  4890. private static _FormatMessage;
  4891. private static _LogDisabled;
  4892. private static _LogEnabled;
  4893. private static _WarnDisabled;
  4894. private static _WarnEnabled;
  4895. private static _ErrorDisabled;
  4896. private static _ErrorEnabled;
  4897. /**
  4898. * Log a message to the console
  4899. */
  4900. static Log: (message: string) => void;
  4901. /**
  4902. * Write a warning message to the console
  4903. */
  4904. static Warn: (message: string) => void;
  4905. /**
  4906. * Write an error message to the console
  4907. */
  4908. static Error: (message: string) => void;
  4909. /**
  4910. * Gets current log cache (list of logs)
  4911. */
  4912. static readonly LogCache: string;
  4913. /**
  4914. * Clears the log cache
  4915. */
  4916. static ClearLogCache(): void;
  4917. /**
  4918. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  4919. */
  4920. static LogLevels: number;
  4921. }
  4922. }
  4923. declare module "babylonjs/Misc/typeStore" {
  4924. /** @hidden */
  4925. export class _TypeStore {
  4926. /** @hidden */
  4927. static RegisteredTypes: {
  4928. [key: string]: Object;
  4929. };
  4930. /** @hidden */
  4931. static GetClass(fqdn: string): any;
  4932. }
  4933. }
  4934. declare module "babylonjs/Misc/deepCopier" {
  4935. /**
  4936. * Class containing a set of static utilities functions for deep copy.
  4937. */
  4938. export class DeepCopier {
  4939. /**
  4940. * Tries to copy an object by duplicating every property
  4941. * @param source defines the source object
  4942. * @param destination defines the target object
  4943. * @param doNotCopyList defines a list of properties to avoid
  4944. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  4945. */
  4946. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  4947. }
  4948. }
  4949. declare module "babylonjs/Misc/precisionDate" {
  4950. /**
  4951. * Class containing a set of static utilities functions for precision date
  4952. */
  4953. export class PrecisionDate {
  4954. /**
  4955. * Gets either window.performance.now() if supported or Date.now() else
  4956. */
  4957. static readonly Now: number;
  4958. }
  4959. }
  4960. declare module "babylonjs/Misc/devTools" {
  4961. /** @hidden */
  4962. export class _DevTools {
  4963. static WarnImport(name: string): string;
  4964. }
  4965. }
  4966. declare module "babylonjs/Misc/webRequest" {
  4967. /**
  4968. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  4969. */
  4970. export class WebRequest extends XMLHttpRequest {
  4971. /**
  4972. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  4973. * i.e. when loading files, where the server/service expects an Authorization header
  4974. */
  4975. static CustomRequestHeaders: {
  4976. [key: string]: string;
  4977. };
  4978. /**
  4979. * Add callback functions in this array to update all the requests before they get sent to the network
  4980. */
  4981. static CustomRequestModifiers: ((request: WebRequest) => void)[];
  4982. private _injectCustomRequestHeaders;
  4983. open(method: string, url: string): void;
  4984. }
  4985. }
  4986. declare module "babylonjs/Misc/andOrNotEvaluator" {
  4987. /**
  4988. * Class used to evalaute queries containing `and` and `or` operators
  4989. */
  4990. export class AndOrNotEvaluator {
  4991. /**
  4992. * Evaluate a query
  4993. * @param query defines the query to evaluate
  4994. * @param evaluateCallback defines the callback used to filter result
  4995. * @returns true if the query matches
  4996. */
  4997. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  4998. private static _HandleParenthesisContent;
  4999. private static _SimplifyNegation;
  5000. }
  5001. }
  5002. declare module "babylonjs/Misc/tags" {
  5003. /**
  5004. * Class used to store custom tags
  5005. */
  5006. export class Tags {
  5007. /**
  5008. * Adds support for tags on the given object
  5009. * @param obj defines the object to use
  5010. */
  5011. static EnableFor(obj: any): void;
  5012. /**
  5013. * Removes tags support
  5014. * @param obj defines the object to use
  5015. */
  5016. static DisableFor(obj: any): void;
  5017. /**
  5018. * Gets a boolean indicating if the given object has tags
  5019. * @param obj defines the object to use
  5020. * @returns a boolean
  5021. */
  5022. static HasTags(obj: any): boolean;
  5023. /**
  5024. * Gets the tags available on a given object
  5025. * @param obj defines the object to use
  5026. * @param asString defines if the tags must be returned as a string instead of an array of strings
  5027. * @returns the tags
  5028. */
  5029. static GetTags(obj: any, asString?: boolean): any;
  5030. /**
  5031. * Adds tags to an object
  5032. * @param obj defines the object to use
  5033. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  5034. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  5035. */
  5036. static AddTagsTo(obj: any, tagsString: string): void;
  5037. /**
  5038. * @hidden
  5039. */
  5040. static _AddTagTo(obj: any, tag: string): void;
  5041. /**
  5042. * Removes specific tags from a specific object
  5043. * @param obj defines the object to use
  5044. * @param tagsString defines the tags to remove
  5045. */
  5046. static RemoveTagsFrom(obj: any, tagsString: string): void;
  5047. /**
  5048. * @hidden
  5049. */
  5050. static _RemoveTagFrom(obj: any, tag: string): void;
  5051. /**
  5052. * Defines if tags hosted on an object match a given query
  5053. * @param obj defines the object to use
  5054. * @param tagsQuery defines the tag query
  5055. * @returns a boolean
  5056. */
  5057. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  5058. }
  5059. }
  5060. declare module "babylonjs/Materials/materialDefines" {
  5061. /**
  5062. * Manages the defines for the Material
  5063. */
  5064. export class MaterialDefines {
  5065. private _keys;
  5066. private _isDirty;
  5067. /** @hidden */
  5068. _renderId: number;
  5069. /** @hidden */
  5070. _areLightsDirty: boolean;
  5071. /** @hidden */
  5072. _areAttributesDirty: boolean;
  5073. /** @hidden */
  5074. _areTexturesDirty: boolean;
  5075. /** @hidden */
  5076. _areFresnelDirty: boolean;
  5077. /** @hidden */
  5078. _areMiscDirty: boolean;
  5079. /** @hidden */
  5080. _areImageProcessingDirty: boolean;
  5081. /** @hidden */
  5082. _normals: boolean;
  5083. /** @hidden */
  5084. _uvs: boolean;
  5085. /** @hidden */
  5086. _needNormals: boolean;
  5087. /** @hidden */
  5088. _needUVs: boolean;
  5089. /**
  5090. * Specifies if the material needs to be re-calculated
  5091. */
  5092. readonly isDirty: boolean;
  5093. /**
  5094. * Marks the material to indicate that it has been re-calculated
  5095. */
  5096. markAsProcessed(): void;
  5097. /**
  5098. * Marks the material to indicate that it needs to be re-calculated
  5099. */
  5100. markAsUnprocessed(): void;
  5101. /**
  5102. * Marks the material to indicate all of its defines need to be re-calculated
  5103. */
  5104. markAllAsDirty(): void;
  5105. /**
  5106. * Marks the material to indicate that image processing needs to be re-calculated
  5107. */
  5108. markAsImageProcessingDirty(): void;
  5109. /**
  5110. * Marks the material to indicate the lights need to be re-calculated
  5111. */
  5112. markAsLightDirty(): void;
  5113. /**
  5114. * Marks the attribute state as changed
  5115. */
  5116. markAsAttributesDirty(): void;
  5117. /**
  5118. * Marks the texture state as changed
  5119. */
  5120. markAsTexturesDirty(): void;
  5121. /**
  5122. * Marks the fresnel state as changed
  5123. */
  5124. markAsFresnelDirty(): void;
  5125. /**
  5126. * Marks the misc state as changed
  5127. */
  5128. markAsMiscDirty(): void;
  5129. /**
  5130. * Rebuilds the material defines
  5131. */
  5132. rebuild(): void;
  5133. /**
  5134. * Specifies if two material defines are equal
  5135. * @param other - A material define instance to compare to
  5136. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  5137. */
  5138. isEqual(other: MaterialDefines): boolean;
  5139. /**
  5140. * Clones this instance's defines to another instance
  5141. * @param other - material defines to clone values to
  5142. */
  5143. cloneTo(other: MaterialDefines): void;
  5144. /**
  5145. * Resets the material define values
  5146. */
  5147. reset(): void;
  5148. /**
  5149. * Converts the material define values to a string
  5150. * @returns - String of material define information
  5151. */
  5152. toString(): string;
  5153. }
  5154. }
  5155. declare module "babylonjs/Misc/performanceMonitor" {
  5156. /**
  5157. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  5158. */
  5159. export class PerformanceMonitor {
  5160. private _enabled;
  5161. private _rollingFrameTime;
  5162. private _lastFrameTimeMs;
  5163. /**
  5164. * constructor
  5165. * @param frameSampleSize The number of samples required to saturate the sliding window
  5166. */
  5167. constructor(frameSampleSize?: number);
  5168. /**
  5169. * Samples current frame
  5170. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  5171. */
  5172. sampleFrame(timeMs?: number): void;
  5173. /**
  5174. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5175. */
  5176. readonly averageFrameTime: number;
  5177. /**
  5178. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5179. */
  5180. readonly averageFrameTimeVariance: number;
  5181. /**
  5182. * Returns the frame time of the most recent frame
  5183. */
  5184. readonly instantaneousFrameTime: number;
  5185. /**
  5186. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  5187. */
  5188. readonly averageFPS: number;
  5189. /**
  5190. * Returns the average framerate in frames per second using the most recent frame time
  5191. */
  5192. readonly instantaneousFPS: number;
  5193. /**
  5194. * Returns true if enough samples have been taken to completely fill the sliding window
  5195. */
  5196. readonly isSaturated: boolean;
  5197. /**
  5198. * Enables contributions to the sliding window sample set
  5199. */
  5200. enable(): void;
  5201. /**
  5202. * Disables contributions to the sliding window sample set
  5203. * Samples will not be interpolated over the disabled period
  5204. */
  5205. disable(): void;
  5206. /**
  5207. * Returns true if sampling is enabled
  5208. */
  5209. readonly isEnabled: boolean;
  5210. /**
  5211. * Resets performance monitor
  5212. */
  5213. reset(): void;
  5214. }
  5215. /**
  5216. * RollingAverage
  5217. *
  5218. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  5219. */
  5220. export class RollingAverage {
  5221. /**
  5222. * Current average
  5223. */
  5224. average: number;
  5225. /**
  5226. * Current variance
  5227. */
  5228. variance: number;
  5229. protected _samples: Array<number>;
  5230. protected _sampleCount: number;
  5231. protected _pos: number;
  5232. protected _m2: number;
  5233. /**
  5234. * constructor
  5235. * @param length The number of samples required to saturate the sliding window
  5236. */
  5237. constructor(length: number);
  5238. /**
  5239. * Adds a sample to the sample set
  5240. * @param v The sample value
  5241. */
  5242. add(v: number): void;
  5243. /**
  5244. * Returns previously added values or null if outside of history or outside the sliding window domain
  5245. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  5246. * @return Value previously recorded with add() or null if outside of range
  5247. */
  5248. history(i: number): number;
  5249. /**
  5250. * Returns true if enough samples have been taken to completely fill the sliding window
  5251. * @return true if sample-set saturated
  5252. */
  5253. isSaturated(): boolean;
  5254. /**
  5255. * Resets the rolling average (equivalent to 0 samples taken so far)
  5256. */
  5257. reset(): void;
  5258. /**
  5259. * Wraps a value around the sample range boundaries
  5260. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  5261. * @return Wrapped position in sample range
  5262. */
  5263. protected _wrapPosition(i: number): number;
  5264. }
  5265. }
  5266. declare module "babylonjs/Misc/stringDictionary" {
  5267. import { Nullable } from "babylonjs/types";
  5268. /**
  5269. * This class implement a typical dictionary using a string as key and the generic type T as value.
  5270. * The underlying implementation relies on an associative array to ensure the best performances.
  5271. * The value can be anything including 'null' but except 'undefined'
  5272. */
  5273. export class StringDictionary<T> {
  5274. /**
  5275. * This will clear this dictionary and copy the content from the 'source' one.
  5276. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  5277. * @param source the dictionary to take the content from and copy to this dictionary
  5278. */
  5279. copyFrom(source: StringDictionary<T>): void;
  5280. /**
  5281. * Get a value based from its key
  5282. * @param key the given key to get the matching value from
  5283. * @return the value if found, otherwise undefined is returned
  5284. */
  5285. get(key: string): T | undefined;
  5286. /**
  5287. * Get a value from its key or add it if it doesn't exist.
  5288. * This method will ensure you that a given key/data will be present in the dictionary.
  5289. * @param key the given key to get the matching value from
  5290. * @param factory the factory that will create the value if the key is not present in the dictionary.
  5291. * The factory will only be invoked if there's no data for the given key.
  5292. * @return the value corresponding to the key.
  5293. */
  5294. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  5295. /**
  5296. * Get a value from its key if present in the dictionary otherwise add it
  5297. * @param key the key to get the value from
  5298. * @param val if there's no such key/value pair in the dictionary add it with this value
  5299. * @return the value corresponding to the key
  5300. */
  5301. getOrAdd(key: string, val: T): T;
  5302. /**
  5303. * Check if there's a given key in the dictionary
  5304. * @param key the key to check for
  5305. * @return true if the key is present, false otherwise
  5306. */
  5307. contains(key: string): boolean;
  5308. /**
  5309. * Add a new key and its corresponding value
  5310. * @param key the key to add
  5311. * @param value the value corresponding to the key
  5312. * @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
  5313. */
  5314. add(key: string, value: T): boolean;
  5315. /**
  5316. * Update a specific value associated to a key
  5317. * @param key defines the key to use
  5318. * @param value defines the value to store
  5319. * @returns true if the value was updated (or false if the key was not found)
  5320. */
  5321. set(key: string, value: T): boolean;
  5322. /**
  5323. * Get the element of the given key and remove it from the dictionary
  5324. * @param key defines the key to search
  5325. * @returns the value associated with the key or null if not found
  5326. */
  5327. getAndRemove(key: string): Nullable<T>;
  5328. /**
  5329. * Remove a key/value from the dictionary.
  5330. * @param key the key to remove
  5331. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  5332. */
  5333. remove(key: string): boolean;
  5334. /**
  5335. * Clear the whole content of the dictionary
  5336. */
  5337. clear(): void;
  5338. /**
  5339. * Gets the current count
  5340. */
  5341. readonly count: number;
  5342. /**
  5343. * Execute a callback on each key/val of the dictionary.
  5344. * Note that you can remove any element in this dictionary in the callback implementation
  5345. * @param callback the callback to execute on a given key/value pair
  5346. */
  5347. forEach(callback: (key: string, val: T) => void): void;
  5348. /**
  5349. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  5350. * If the callback returns null or undefined the method will iterate to the next key/value pair
  5351. * Note that you can remove any element in this dictionary in the callback implementation
  5352. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  5353. * @returns the first item
  5354. */
  5355. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  5356. private _count;
  5357. private _data;
  5358. }
  5359. }
  5360. declare module "babylonjs/Misc/promise" {
  5361. /**
  5362. * Helper class that provides a small promise polyfill
  5363. */
  5364. export class PromisePolyfill {
  5365. /**
  5366. * Static function used to check if the polyfill is required
  5367. * If this is the case then the function will inject the polyfill to window.Promise
  5368. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  5369. */
  5370. static Apply(force?: boolean): void;
  5371. }
  5372. }
  5373. declare module "babylonjs/Meshes/buffer" {
  5374. import { Nullable, DataArray } from "babylonjs/types";
  5375. /**
  5376. * Class used to store data that will be store in GPU memory
  5377. */
  5378. export class Buffer {
  5379. private _engine;
  5380. private _buffer;
  5381. /** @hidden */
  5382. _data: Nullable<DataArray>;
  5383. private _updatable;
  5384. private _instanced;
  5385. /**
  5386. * Gets the byte stride.
  5387. */
  5388. readonly byteStride: number;
  5389. /**
  5390. * Constructor
  5391. * @param engine the engine
  5392. * @param data the data to use for this buffer
  5393. * @param updatable whether the data is updatable
  5394. * @param stride the stride (optional)
  5395. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5396. * @param instanced whether the buffer is instanced (optional)
  5397. * @param useBytes set to true if the stride in in bytes (optional)
  5398. */
  5399. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  5400. /**
  5401. * Create a new VertexBuffer based on the current buffer
  5402. * @param kind defines the vertex buffer kind (position, normal, etc.)
  5403. * @param offset defines offset in the buffer (0 by default)
  5404. * @param size defines the size in floats of attributes (position is 3 for instance)
  5405. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  5406. * @param instanced defines if the vertex buffer contains indexed data
  5407. * @param useBytes defines if the offset and stride are in bytes
  5408. * @returns the new vertex buffer
  5409. */
  5410. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  5411. /**
  5412. * Gets a boolean indicating if the Buffer is updatable?
  5413. * @returns true if the buffer is updatable
  5414. */
  5415. isUpdatable(): boolean;
  5416. /**
  5417. * Gets current buffer's data
  5418. * @returns a DataArray or null
  5419. */
  5420. getData(): Nullable<DataArray>;
  5421. /**
  5422. * Gets underlying native buffer
  5423. * @returns underlying native buffer
  5424. */
  5425. getBuffer(): Nullable<WebGLBuffer>;
  5426. /**
  5427. * Gets the stride in float32 units (i.e. byte stride / 4).
  5428. * May not be an integer if the byte stride is not divisible by 4.
  5429. * DEPRECATED. Use byteStride instead.
  5430. * @returns the stride in float32 units
  5431. */
  5432. getStrideSize(): number;
  5433. /**
  5434. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5435. * @param data defines the data to store
  5436. */
  5437. create(data?: Nullable<DataArray>): void;
  5438. /** @hidden */
  5439. _rebuild(): void;
  5440. /**
  5441. * Update current buffer data
  5442. * @param data defines the data to store
  5443. */
  5444. update(data: DataArray): void;
  5445. /**
  5446. * Updates the data directly.
  5447. * @param data the new data
  5448. * @param offset the new offset
  5449. * @param vertexCount the vertex count (optional)
  5450. * @param useBytes set to true if the offset is in bytes
  5451. */
  5452. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  5453. /**
  5454. * Release all resources
  5455. */
  5456. dispose(): void;
  5457. }
  5458. /**
  5459. * Specialized buffer used to store vertex data
  5460. */
  5461. export class VertexBuffer {
  5462. /** @hidden */
  5463. _buffer: Buffer;
  5464. private _kind;
  5465. private _size;
  5466. private _ownsBuffer;
  5467. private _instanced;
  5468. private _instanceDivisor;
  5469. /**
  5470. * The byte type.
  5471. */
  5472. static readonly BYTE: number;
  5473. /**
  5474. * The unsigned byte type.
  5475. */
  5476. static readonly UNSIGNED_BYTE: number;
  5477. /**
  5478. * The short type.
  5479. */
  5480. static readonly SHORT: number;
  5481. /**
  5482. * The unsigned short type.
  5483. */
  5484. static readonly UNSIGNED_SHORT: number;
  5485. /**
  5486. * The integer type.
  5487. */
  5488. static readonly INT: number;
  5489. /**
  5490. * The unsigned integer type.
  5491. */
  5492. static readonly UNSIGNED_INT: number;
  5493. /**
  5494. * The float type.
  5495. */
  5496. static readonly FLOAT: number;
  5497. /**
  5498. * Gets or sets the instance divisor when in instanced mode
  5499. */
  5500. instanceDivisor: number;
  5501. /**
  5502. * Gets the byte stride.
  5503. */
  5504. readonly byteStride: number;
  5505. /**
  5506. * Gets the byte offset.
  5507. */
  5508. readonly byteOffset: number;
  5509. /**
  5510. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  5511. */
  5512. readonly normalized: boolean;
  5513. /**
  5514. * Gets the data type of each component in the array.
  5515. */
  5516. readonly type: number;
  5517. /**
  5518. * Constructor
  5519. * @param engine the engine
  5520. * @param data the data to use for this vertex buffer
  5521. * @param kind the vertex buffer kind
  5522. * @param updatable whether the data is updatable
  5523. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5524. * @param stride the stride (optional)
  5525. * @param instanced whether the buffer is instanced (optional)
  5526. * @param offset the offset of the data (optional)
  5527. * @param size the number of components (optional)
  5528. * @param type the type of the component (optional)
  5529. * @param normalized whether the data contains normalized data (optional)
  5530. * @param useBytes set to true if stride and offset are in bytes (optional)
  5531. */
  5532. 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);
  5533. /** @hidden */
  5534. _rebuild(): void;
  5535. /**
  5536. * Returns the kind of the VertexBuffer (string)
  5537. * @returns a string
  5538. */
  5539. getKind(): string;
  5540. /**
  5541. * Gets a boolean indicating if the VertexBuffer is updatable?
  5542. * @returns true if the buffer is updatable
  5543. */
  5544. isUpdatable(): boolean;
  5545. /**
  5546. * Gets current buffer's data
  5547. * @returns a DataArray or null
  5548. */
  5549. getData(): Nullable<DataArray>;
  5550. /**
  5551. * Gets underlying native buffer
  5552. * @returns underlying native buffer
  5553. */
  5554. getBuffer(): Nullable<WebGLBuffer>;
  5555. /**
  5556. * Gets the stride in float32 units (i.e. byte stride / 4).
  5557. * May not be an integer if the byte stride is not divisible by 4.
  5558. * DEPRECATED. Use byteStride instead.
  5559. * @returns the stride in float32 units
  5560. */
  5561. getStrideSize(): number;
  5562. /**
  5563. * Returns the offset as a multiple of the type byte length.
  5564. * DEPRECATED. Use byteOffset instead.
  5565. * @returns the offset in bytes
  5566. */
  5567. getOffset(): number;
  5568. /**
  5569. * Returns the number of components per vertex attribute (integer)
  5570. * @returns the size in float
  5571. */
  5572. getSize(): number;
  5573. /**
  5574. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  5575. * @returns true if this buffer is instanced
  5576. */
  5577. getIsInstanced(): boolean;
  5578. /**
  5579. * Returns the instancing divisor, zero for non-instanced (integer).
  5580. * @returns a number
  5581. */
  5582. getInstanceDivisor(): number;
  5583. /**
  5584. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5585. * @param data defines the data to store
  5586. */
  5587. create(data?: DataArray): void;
  5588. /**
  5589. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  5590. * This function will create a new buffer if the current one is not updatable
  5591. * @param data defines the data to store
  5592. */
  5593. update(data: DataArray): void;
  5594. /**
  5595. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  5596. * Returns the directly updated WebGLBuffer.
  5597. * @param data the new data
  5598. * @param offset the new offset
  5599. * @param useBytes set to true if the offset is in bytes
  5600. */
  5601. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  5602. /**
  5603. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  5604. */
  5605. dispose(): void;
  5606. /**
  5607. * Enumerates each value of this vertex buffer as numbers.
  5608. * @param count the number of values to enumerate
  5609. * @param callback the callback function called for each value
  5610. */
  5611. forEach(count: number, callback: (value: number, index: number) => void): void;
  5612. /**
  5613. * Positions
  5614. */
  5615. static readonly PositionKind: string;
  5616. /**
  5617. * Normals
  5618. */
  5619. static readonly NormalKind: string;
  5620. /**
  5621. * Tangents
  5622. */
  5623. static readonly TangentKind: string;
  5624. /**
  5625. * Texture coordinates
  5626. */
  5627. static readonly UVKind: string;
  5628. /**
  5629. * Texture coordinates 2
  5630. */
  5631. static readonly UV2Kind: string;
  5632. /**
  5633. * Texture coordinates 3
  5634. */
  5635. static readonly UV3Kind: string;
  5636. /**
  5637. * Texture coordinates 4
  5638. */
  5639. static readonly UV4Kind: string;
  5640. /**
  5641. * Texture coordinates 5
  5642. */
  5643. static readonly UV5Kind: string;
  5644. /**
  5645. * Texture coordinates 6
  5646. */
  5647. static readonly UV6Kind: string;
  5648. /**
  5649. * Colors
  5650. */
  5651. static readonly ColorKind: string;
  5652. /**
  5653. * Matrix indices (for bones)
  5654. */
  5655. static readonly MatricesIndicesKind: string;
  5656. /**
  5657. * Matrix weights (for bones)
  5658. */
  5659. static readonly MatricesWeightsKind: string;
  5660. /**
  5661. * Additional matrix indices (for bones)
  5662. */
  5663. static readonly MatricesIndicesExtraKind: string;
  5664. /**
  5665. * Additional matrix weights (for bones)
  5666. */
  5667. static readonly MatricesWeightsExtraKind: string;
  5668. /**
  5669. * Deduces the stride given a kind.
  5670. * @param kind The kind string to deduce
  5671. * @returns The deduced stride
  5672. */
  5673. static DeduceStride(kind: string): number;
  5674. /**
  5675. * Gets the byte length of the given type.
  5676. * @param type the type
  5677. * @returns the number of bytes
  5678. */
  5679. static GetTypeByteLength(type: number): number;
  5680. /**
  5681. * Enumerates each value of the given parameters as numbers.
  5682. * @param data the data to enumerate
  5683. * @param byteOffset the byte offset of the data
  5684. * @param byteStride the byte stride of the data
  5685. * @param componentCount the number of components per element
  5686. * @param componentType the type of the component
  5687. * @param count the total number of components
  5688. * @param normalized whether the data is normalized
  5689. * @param callback the callback function called for each value
  5690. */
  5691. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  5692. private static _GetFloatValue;
  5693. }
  5694. }
  5695. declare module "babylonjs/Maths/sphericalPolynomial" {
  5696. import { Vector3, Color3 } from "babylonjs/Maths/math";
  5697. /**
  5698. * Class representing spherical polynomial coefficients to the 3rd degree
  5699. */
  5700. export class SphericalPolynomial {
  5701. /**
  5702. * The x coefficients of the spherical polynomial
  5703. */
  5704. x: Vector3;
  5705. /**
  5706. * The y coefficients of the spherical polynomial
  5707. */
  5708. y: Vector3;
  5709. /**
  5710. * The z coefficients of the spherical polynomial
  5711. */
  5712. z: Vector3;
  5713. /**
  5714. * The xx coefficients of the spherical polynomial
  5715. */
  5716. xx: Vector3;
  5717. /**
  5718. * The yy coefficients of the spherical polynomial
  5719. */
  5720. yy: Vector3;
  5721. /**
  5722. * The zz coefficients of the spherical polynomial
  5723. */
  5724. zz: Vector3;
  5725. /**
  5726. * The xy coefficients of the spherical polynomial
  5727. */
  5728. xy: Vector3;
  5729. /**
  5730. * The yz coefficients of the spherical polynomial
  5731. */
  5732. yz: Vector3;
  5733. /**
  5734. * The zx coefficients of the spherical polynomial
  5735. */
  5736. zx: Vector3;
  5737. /**
  5738. * Adds an ambient color to the spherical polynomial
  5739. * @param color the color to add
  5740. */
  5741. addAmbient(color: Color3): void;
  5742. /**
  5743. * Scales the spherical polynomial by the given amount
  5744. * @param scale the amount to scale
  5745. */
  5746. scale(scale: number): void;
  5747. /**
  5748. * Gets the spherical polynomial from harmonics
  5749. * @param harmonics the spherical harmonics
  5750. * @returns the spherical polynomial
  5751. */
  5752. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  5753. /**
  5754. * Constructs a spherical polynomial from an array.
  5755. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  5756. * @returns the spherical polynomial
  5757. */
  5758. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  5759. }
  5760. /**
  5761. * Class representing spherical harmonics coefficients to the 3rd degree
  5762. */
  5763. export class SphericalHarmonics {
  5764. /**
  5765. * The l0,0 coefficients of the spherical harmonics
  5766. */
  5767. l00: Vector3;
  5768. /**
  5769. * The l1,-1 coefficients of the spherical harmonics
  5770. */
  5771. l1_1: Vector3;
  5772. /**
  5773. * The l1,0 coefficients of the spherical harmonics
  5774. */
  5775. l10: Vector3;
  5776. /**
  5777. * The l1,1 coefficients of the spherical harmonics
  5778. */
  5779. l11: Vector3;
  5780. /**
  5781. * The l2,-2 coefficients of the spherical harmonics
  5782. */
  5783. l2_2: Vector3;
  5784. /**
  5785. * The l2,-1 coefficients of the spherical harmonics
  5786. */
  5787. l2_1: Vector3;
  5788. /**
  5789. * The l2,0 coefficients of the spherical harmonics
  5790. */
  5791. l20: Vector3;
  5792. /**
  5793. * The l2,1 coefficients of the spherical harmonics
  5794. */
  5795. l21: Vector3;
  5796. /**
  5797. * The l2,2 coefficients of the spherical harmonics
  5798. */
  5799. lL22: Vector3;
  5800. /**
  5801. * Adds a light to the spherical harmonics
  5802. * @param direction the direction of the light
  5803. * @param color the color of the light
  5804. * @param deltaSolidAngle the delta solid angle of the light
  5805. */
  5806. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  5807. /**
  5808. * Scales the spherical harmonics by the given amount
  5809. * @param scale the amount to scale
  5810. */
  5811. scale(scale: number): void;
  5812. /**
  5813. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  5814. *
  5815. * ```
  5816. * E_lm = A_l * L_lm
  5817. * ```
  5818. *
  5819. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  5820. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  5821. * the scaling factors are given in equation 9.
  5822. */
  5823. convertIncidentRadianceToIrradiance(): void;
  5824. /**
  5825. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  5826. *
  5827. * ```
  5828. * L = (1/pi) * E * rho
  5829. * ```
  5830. *
  5831. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  5832. */
  5833. convertIrradianceToLambertianRadiance(): void;
  5834. /**
  5835. * Gets the spherical harmonics from polynomial
  5836. * @param polynomial the spherical polynomial
  5837. * @returns the spherical harmonics
  5838. */
  5839. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  5840. /**
  5841. * Constructs a spherical harmonics from an array.
  5842. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  5843. * @returns the spherical harmonics
  5844. */
  5845. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  5846. }
  5847. }
  5848. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  5849. import { Nullable } from "babylonjs/types";
  5850. /**
  5851. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  5852. */
  5853. export interface CubeMapInfo {
  5854. /**
  5855. * The pixel array for the front face.
  5856. * This is stored in format, left to right, up to down format.
  5857. */
  5858. front: Nullable<ArrayBufferView>;
  5859. /**
  5860. * The pixel array for the back face.
  5861. * This is stored in format, left to right, up to down format.
  5862. */
  5863. back: Nullable<ArrayBufferView>;
  5864. /**
  5865. * The pixel array for the left face.
  5866. * This is stored in format, left to right, up to down format.
  5867. */
  5868. left: Nullable<ArrayBufferView>;
  5869. /**
  5870. * The pixel array for the right face.
  5871. * This is stored in format, left to right, up to down format.
  5872. */
  5873. right: Nullable<ArrayBufferView>;
  5874. /**
  5875. * The pixel array for the up face.
  5876. * This is stored in format, left to right, up to down format.
  5877. */
  5878. up: Nullable<ArrayBufferView>;
  5879. /**
  5880. * The pixel array for the down face.
  5881. * This is stored in format, left to right, up to down format.
  5882. */
  5883. down: Nullable<ArrayBufferView>;
  5884. /**
  5885. * The size of the cubemap stored.
  5886. *
  5887. * Each faces will be size * size pixels.
  5888. */
  5889. size: number;
  5890. /**
  5891. * The format of the texture.
  5892. *
  5893. * RGBA, RGB.
  5894. */
  5895. format: number;
  5896. /**
  5897. * The type of the texture data.
  5898. *
  5899. * UNSIGNED_INT, FLOAT.
  5900. */
  5901. type: number;
  5902. /**
  5903. * Specifies whether the texture is in gamma space.
  5904. */
  5905. gammaSpace: boolean;
  5906. }
  5907. /**
  5908. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  5909. */
  5910. export class PanoramaToCubeMapTools {
  5911. private static FACE_FRONT;
  5912. private static FACE_BACK;
  5913. private static FACE_RIGHT;
  5914. private static FACE_LEFT;
  5915. private static FACE_DOWN;
  5916. private static FACE_UP;
  5917. /**
  5918. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  5919. *
  5920. * @param float32Array The source data.
  5921. * @param inputWidth The width of the input panorama.
  5922. * @param inputHeight The height of the input panorama.
  5923. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  5924. * @return The cubemap data
  5925. */
  5926. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  5927. private static CreateCubemapTexture;
  5928. private static CalcProjectionSpherical;
  5929. }
  5930. }
  5931. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  5932. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  5933. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  5934. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  5935. /**
  5936. * Helper class dealing with the extraction of spherical polynomial dataArray
  5937. * from a cube map.
  5938. */
  5939. export class CubeMapToSphericalPolynomialTools {
  5940. private static FileFaces;
  5941. /**
  5942. * Converts a texture to the according Spherical Polynomial data.
  5943. * This extracts the first 3 orders only as they are the only one used in the lighting.
  5944. *
  5945. * @param texture The texture to extract the information from.
  5946. * @return The Spherical Polynomial data.
  5947. */
  5948. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  5949. /**
  5950. * Converts a cubemap to the according Spherical Polynomial data.
  5951. * This extracts the first 3 orders only as they are the only one used in the lighting.
  5952. *
  5953. * @param cubeInfo The Cube map to extract the information from.
  5954. * @return The Spherical Polynomial data.
  5955. */
  5956. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  5957. }
  5958. }
  5959. declare module "babylonjs/Engines/engineStore" {
  5960. import { Nullable } from "babylonjs/types";
  5961. import { Engine } from "babylonjs/Engines/engine";
  5962. import { Scene } from "babylonjs/scene";
  5963. /**
  5964. * The engine store class is responsible to hold all the instances of Engine and Scene created
  5965. * during the life time of the application.
  5966. */
  5967. export class EngineStore {
  5968. /** Gets the list of created engines */
  5969. static Instances: import("babylonjs/Engines/engine").Engine[];
  5970. /**
  5971. * Gets the latest created engine
  5972. */
  5973. static readonly LastCreatedEngine: Nullable<Engine>;
  5974. /**
  5975. * Gets the latest created scene
  5976. */
  5977. static readonly LastCreatedScene: Nullable<Scene>;
  5978. }
  5979. }
  5980. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  5981. /**
  5982. * Define options used to create a render target texture
  5983. */
  5984. export class RenderTargetCreationOptions {
  5985. /**
  5986. * Specifies is mipmaps must be generated
  5987. */
  5988. generateMipMaps?: boolean;
  5989. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  5990. generateDepthBuffer?: boolean;
  5991. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  5992. generateStencilBuffer?: boolean;
  5993. /** Defines texture type (int by default) */
  5994. type?: number;
  5995. /** Defines sampling mode (trilinear by default) */
  5996. samplingMode?: number;
  5997. /** Defines format (RGBA by default) */
  5998. format?: number;
  5999. }
  6000. }
  6001. declare module "babylonjs/States/alphaCullingState" {
  6002. /**
  6003. * @hidden
  6004. **/
  6005. export class _AlphaState {
  6006. private _isAlphaBlendDirty;
  6007. private _isBlendFunctionParametersDirty;
  6008. private _isBlendEquationParametersDirty;
  6009. private _isBlendConstantsDirty;
  6010. private _alphaBlend;
  6011. private _blendFunctionParameters;
  6012. private _blendEquationParameters;
  6013. private _blendConstants;
  6014. /**
  6015. * Initializes the state.
  6016. */
  6017. constructor();
  6018. readonly isDirty: boolean;
  6019. alphaBlend: boolean;
  6020. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  6021. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  6022. setAlphaEquationParameters(rgb: number, alpha: number): void;
  6023. reset(): void;
  6024. apply(gl: WebGLRenderingContext): void;
  6025. }
  6026. }
  6027. declare module "babylonjs/States/depthCullingState" {
  6028. import { Nullable } from "babylonjs/types";
  6029. /**
  6030. * @hidden
  6031. **/
  6032. export class _DepthCullingState {
  6033. private _isDepthTestDirty;
  6034. private _isDepthMaskDirty;
  6035. private _isDepthFuncDirty;
  6036. private _isCullFaceDirty;
  6037. private _isCullDirty;
  6038. private _isZOffsetDirty;
  6039. private _isFrontFaceDirty;
  6040. private _depthTest;
  6041. private _depthMask;
  6042. private _depthFunc;
  6043. private _cull;
  6044. private _cullFace;
  6045. private _zOffset;
  6046. private _frontFace;
  6047. /**
  6048. * Initializes the state.
  6049. */
  6050. constructor();
  6051. readonly isDirty: boolean;
  6052. zOffset: number;
  6053. cullFace: Nullable<number>;
  6054. cull: Nullable<boolean>;
  6055. depthFunc: Nullable<number>;
  6056. depthMask: boolean;
  6057. depthTest: boolean;
  6058. frontFace: Nullable<number>;
  6059. reset(): void;
  6060. apply(gl: WebGLRenderingContext): void;
  6061. }
  6062. }
  6063. declare module "babylonjs/States/stencilState" {
  6064. /**
  6065. * @hidden
  6066. **/
  6067. export class _StencilState {
  6068. /** 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 */
  6069. static readonly ALWAYS: number;
  6070. /** Passed to stencilOperation to specify that stencil value must be kept */
  6071. static readonly KEEP: number;
  6072. /** Passed to stencilOperation to specify that stencil value must be replaced */
  6073. static readonly REPLACE: number;
  6074. private _isStencilTestDirty;
  6075. private _isStencilMaskDirty;
  6076. private _isStencilFuncDirty;
  6077. private _isStencilOpDirty;
  6078. private _stencilTest;
  6079. private _stencilMask;
  6080. private _stencilFunc;
  6081. private _stencilFuncRef;
  6082. private _stencilFuncMask;
  6083. private _stencilOpStencilFail;
  6084. private _stencilOpDepthFail;
  6085. private _stencilOpStencilDepthPass;
  6086. readonly isDirty: boolean;
  6087. stencilFunc: number;
  6088. stencilFuncRef: number;
  6089. stencilFuncMask: number;
  6090. stencilOpStencilFail: number;
  6091. stencilOpDepthFail: number;
  6092. stencilOpStencilDepthPass: number;
  6093. stencilMask: number;
  6094. stencilTest: boolean;
  6095. constructor();
  6096. reset(): void;
  6097. apply(gl: WebGLRenderingContext): void;
  6098. }
  6099. }
  6100. declare module "babylonjs/States/index" {
  6101. export * from "babylonjs/States/alphaCullingState";
  6102. export * from "babylonjs/States/depthCullingState";
  6103. export * from "babylonjs/States/stencilState";
  6104. }
  6105. declare module "babylonjs/Instrumentation/timeToken" {
  6106. import { Nullable } from "babylonjs/types";
  6107. /**
  6108. * @hidden
  6109. **/
  6110. export class _TimeToken {
  6111. _startTimeQuery: Nullable<WebGLQuery>;
  6112. _endTimeQuery: Nullable<WebGLQuery>;
  6113. _timeElapsedQuery: Nullable<WebGLQuery>;
  6114. _timeElapsedQueryEnded: boolean;
  6115. }
  6116. }
  6117. declare module "babylonjs/Materials/Textures/internalTextureTracker" {
  6118. import { Nullable } from "babylonjs/types";
  6119. /**
  6120. * Internal interface used to track InternalTexture already bound to the GL context
  6121. */
  6122. export interface IInternalTextureTracker {
  6123. /**
  6124. * Gets or set the previous tracker in the list
  6125. */
  6126. previous: Nullable<IInternalTextureTracker>;
  6127. /**
  6128. * Gets or set the next tracker in the list
  6129. */
  6130. next: Nullable<IInternalTextureTracker>;
  6131. }
  6132. /**
  6133. * Internal class used by the engine to get list of InternalTexture already bound to the GL context
  6134. */
  6135. export class DummyInternalTextureTracker {
  6136. /**
  6137. * Gets or set the previous tracker in the list
  6138. */
  6139. previous: Nullable<IInternalTextureTracker>;
  6140. /**
  6141. * Gets or set the next tracker in the list
  6142. */
  6143. next: Nullable<IInternalTextureTracker>;
  6144. }
  6145. }
  6146. declare module "babylonjs/Materials/Textures/internalTexture" {
  6147. import { Observable } from "babylonjs/Misc/observable";
  6148. import { Nullable, int } from "babylonjs/types";
  6149. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  6150. import { IInternalTextureTracker } from "babylonjs/Materials/Textures/internalTextureTracker";
  6151. import { Engine } from "babylonjs/Engines/engine";
  6152. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  6153. /**
  6154. * Class used to store data associated with WebGL texture data for the engine
  6155. * This class should not be used directly
  6156. */
  6157. export class InternalTexture implements IInternalTextureTracker {
  6158. /** hidden */
  6159. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  6160. /**
  6161. * The source of the texture data is unknown
  6162. */
  6163. static DATASOURCE_UNKNOWN: number;
  6164. /**
  6165. * Texture data comes from an URL
  6166. */
  6167. static DATASOURCE_URL: number;
  6168. /**
  6169. * Texture data is only used for temporary storage
  6170. */
  6171. static DATASOURCE_TEMP: number;
  6172. /**
  6173. * Texture data comes from raw data (ArrayBuffer)
  6174. */
  6175. static DATASOURCE_RAW: number;
  6176. /**
  6177. * Texture content is dynamic (video or dynamic texture)
  6178. */
  6179. static DATASOURCE_DYNAMIC: number;
  6180. /**
  6181. * Texture content is generated by rendering to it
  6182. */
  6183. static DATASOURCE_RENDERTARGET: number;
  6184. /**
  6185. * Texture content is part of a multi render target process
  6186. */
  6187. static DATASOURCE_MULTIRENDERTARGET: number;
  6188. /**
  6189. * Texture data comes from a cube data file
  6190. */
  6191. static DATASOURCE_CUBE: number;
  6192. /**
  6193. * Texture data comes from a raw cube data
  6194. */
  6195. static DATASOURCE_CUBERAW: number;
  6196. /**
  6197. * Texture data come from a prefiltered cube data file
  6198. */
  6199. static DATASOURCE_CUBEPREFILTERED: number;
  6200. /**
  6201. * Texture content is raw 3D data
  6202. */
  6203. static DATASOURCE_RAW3D: number;
  6204. /**
  6205. * Texture content is a depth texture
  6206. */
  6207. static DATASOURCE_DEPTHTEXTURE: number;
  6208. /**
  6209. * Texture data comes from a raw cube data encoded with RGBD
  6210. */
  6211. static DATASOURCE_CUBERAW_RGBD: number;
  6212. /**
  6213. * Defines if the texture is ready
  6214. */
  6215. isReady: boolean;
  6216. /**
  6217. * Defines if the texture is a cube texture
  6218. */
  6219. isCube: boolean;
  6220. /**
  6221. * Defines if the texture contains 3D data
  6222. */
  6223. is3D: boolean;
  6224. /**
  6225. * Gets the URL used to load this texture
  6226. */
  6227. url: string;
  6228. /**
  6229. * Gets the sampling mode of the texture
  6230. */
  6231. samplingMode: number;
  6232. /**
  6233. * Gets a boolean indicating if the texture needs mipmaps generation
  6234. */
  6235. generateMipMaps: boolean;
  6236. /**
  6237. * Gets the number of samples used by the texture (WebGL2+ only)
  6238. */
  6239. samples: number;
  6240. /**
  6241. * Gets the type of the texture (int, float...)
  6242. */
  6243. type: number;
  6244. /**
  6245. * Gets the format of the texture (RGB, RGBA...)
  6246. */
  6247. format: number;
  6248. /**
  6249. * Observable called when the texture is loaded
  6250. */
  6251. onLoadedObservable: Observable<InternalTexture>;
  6252. /**
  6253. * Gets the width of the texture
  6254. */
  6255. width: number;
  6256. /**
  6257. * Gets the height of the texture
  6258. */
  6259. height: number;
  6260. /**
  6261. * Gets the depth of the texture
  6262. */
  6263. depth: number;
  6264. /**
  6265. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  6266. */
  6267. baseWidth: number;
  6268. /**
  6269. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  6270. */
  6271. baseHeight: number;
  6272. /**
  6273. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  6274. */
  6275. baseDepth: number;
  6276. /**
  6277. * Gets a boolean indicating if the texture is inverted on Y axis
  6278. */
  6279. invertY: boolean;
  6280. /**
  6281. * Gets or set the previous tracker in the list
  6282. */
  6283. previous: Nullable<IInternalTextureTracker>;
  6284. /**
  6285. * Gets or set the next tracker in the list
  6286. */
  6287. next: Nullable<IInternalTextureTracker>;
  6288. /** @hidden */
  6289. _invertVScale: boolean;
  6290. /** @hidden */
  6291. _initialSlot: number;
  6292. /** @hidden */
  6293. _designatedSlot: number;
  6294. /** @hidden */
  6295. _dataSource: number;
  6296. /** @hidden */
  6297. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  6298. /** @hidden */
  6299. _bufferView: Nullable<ArrayBufferView>;
  6300. /** @hidden */
  6301. _bufferViewArray: Nullable<ArrayBufferView[]>;
  6302. /** @hidden */
  6303. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  6304. /** @hidden */
  6305. _size: number;
  6306. /** @hidden */
  6307. _extension: string;
  6308. /** @hidden */
  6309. _files: Nullable<string[]>;
  6310. /** @hidden */
  6311. _workingCanvas: HTMLCanvasElement;
  6312. /** @hidden */
  6313. _workingContext: CanvasRenderingContext2D;
  6314. /** @hidden */
  6315. _framebuffer: Nullable<WebGLFramebuffer>;
  6316. /** @hidden */
  6317. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  6318. /** @hidden */
  6319. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  6320. /** @hidden */
  6321. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  6322. /** @hidden */
  6323. _attachments: Nullable<number[]>;
  6324. /** @hidden */
  6325. _cachedCoordinatesMode: Nullable<number>;
  6326. /** @hidden */
  6327. _cachedWrapU: Nullable<number>;
  6328. /** @hidden */
  6329. _cachedWrapV: Nullable<number>;
  6330. /** @hidden */
  6331. _cachedWrapR: Nullable<number>;
  6332. /** @hidden */
  6333. _cachedAnisotropicFilteringLevel: Nullable<number>;
  6334. /** @hidden */
  6335. _isDisabled: boolean;
  6336. /** @hidden */
  6337. _compression: Nullable<string>;
  6338. /** @hidden */
  6339. _generateStencilBuffer: boolean;
  6340. /** @hidden */
  6341. _generateDepthBuffer: boolean;
  6342. /** @hidden */
  6343. _comparisonFunction: number;
  6344. /** @hidden */
  6345. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  6346. /** @hidden */
  6347. _lodGenerationScale: number;
  6348. /** @hidden */
  6349. _lodGenerationOffset: number;
  6350. /** @hidden */
  6351. _lodTextureHigh: BaseTexture;
  6352. /** @hidden */
  6353. _lodTextureMid: BaseTexture;
  6354. /** @hidden */
  6355. _lodTextureLow: BaseTexture;
  6356. /** @hidden */
  6357. _isRGBD: boolean;
  6358. /** @hidden */
  6359. _webGLTexture: Nullable<WebGLTexture>;
  6360. /** @hidden */
  6361. _references: number;
  6362. private _engine;
  6363. /**
  6364. * Gets the Engine the texture belongs to.
  6365. * @returns The babylon engine
  6366. */
  6367. getEngine(): Engine;
  6368. /**
  6369. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  6370. */
  6371. readonly dataSource: number;
  6372. /**
  6373. * Creates a new InternalTexture
  6374. * @param engine defines the engine to use
  6375. * @param dataSource defines the type of data that will be used
  6376. * @param delayAllocation if the texture allocation should be delayed (default: false)
  6377. */
  6378. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  6379. /**
  6380. * Increments the number of references (ie. the number of Texture that point to it)
  6381. */
  6382. incrementReferences(): void;
  6383. /**
  6384. * Change the size of the texture (not the size of the content)
  6385. * @param width defines the new width
  6386. * @param height defines the new height
  6387. * @param depth defines the new depth (1 by default)
  6388. */
  6389. updateSize(width: int, height: int, depth?: int): void;
  6390. /** @hidden */
  6391. _rebuild(): void;
  6392. /** @hidden */
  6393. _swapAndDie(target: InternalTexture): void;
  6394. /**
  6395. * Dispose the current allocated resources
  6396. */
  6397. dispose(): void;
  6398. }
  6399. }
  6400. declare module "babylonjs/Animations/easing" {
  6401. /**
  6402. * This represents the main contract an easing function should follow.
  6403. * Easing functions are used throughout the animation system.
  6404. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6405. */
  6406. export interface IEasingFunction {
  6407. /**
  6408. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6409. * of the easing function.
  6410. * The link below provides some of the most common examples of easing functions.
  6411. * @see https://easings.net/
  6412. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6413. * @returns the corresponding value on the curve defined by the easing function
  6414. */
  6415. ease(gradient: number): number;
  6416. }
  6417. /**
  6418. * Base class used for every default easing function.
  6419. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6420. */
  6421. export class EasingFunction implements IEasingFunction {
  6422. /**
  6423. * Interpolation follows the mathematical formula associated with the easing function.
  6424. */
  6425. static readonly EASINGMODE_EASEIN: number;
  6426. /**
  6427. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  6428. */
  6429. static readonly EASINGMODE_EASEOUT: number;
  6430. /**
  6431. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  6432. */
  6433. static readonly EASINGMODE_EASEINOUT: number;
  6434. private _easingMode;
  6435. /**
  6436. * Sets the easing mode of the current function.
  6437. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  6438. */
  6439. setEasingMode(easingMode: number): void;
  6440. /**
  6441. * Gets the current easing mode.
  6442. * @returns the easing mode
  6443. */
  6444. getEasingMode(): number;
  6445. /**
  6446. * @hidden
  6447. */
  6448. easeInCore(gradient: number): number;
  6449. /**
  6450. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6451. * of the easing function.
  6452. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6453. * @returns the corresponding value on the curve defined by the easing function
  6454. */
  6455. ease(gradient: number): number;
  6456. }
  6457. /**
  6458. * Easing function with a circle shape (see link below).
  6459. * @see https://easings.net/#easeInCirc
  6460. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6461. */
  6462. export class CircleEase extends EasingFunction implements IEasingFunction {
  6463. /** @hidden */
  6464. easeInCore(gradient: number): number;
  6465. }
  6466. /**
  6467. * Easing function with a ease back shape (see link below).
  6468. * @see https://easings.net/#easeInBack
  6469. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6470. */
  6471. export class BackEase extends EasingFunction implements IEasingFunction {
  6472. /** Defines the amplitude of the function */
  6473. amplitude: number;
  6474. /**
  6475. * Instantiates a back ease easing
  6476. * @see https://easings.net/#easeInBack
  6477. * @param amplitude Defines the amplitude of the function
  6478. */
  6479. constructor(
  6480. /** Defines the amplitude of the function */
  6481. amplitude?: number);
  6482. /** @hidden */
  6483. easeInCore(gradient: number): number;
  6484. }
  6485. /**
  6486. * Easing function with a bouncing shape (see link below).
  6487. * @see https://easings.net/#easeInBounce
  6488. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6489. */
  6490. export class BounceEase extends EasingFunction implements IEasingFunction {
  6491. /** Defines the number of bounces */
  6492. bounces: number;
  6493. /** Defines the amplitude of the bounce */
  6494. bounciness: number;
  6495. /**
  6496. * Instantiates a bounce easing
  6497. * @see https://easings.net/#easeInBounce
  6498. * @param bounces Defines the number of bounces
  6499. * @param bounciness Defines the amplitude of the bounce
  6500. */
  6501. constructor(
  6502. /** Defines the number of bounces */
  6503. bounces?: number,
  6504. /** Defines the amplitude of the bounce */
  6505. bounciness?: number);
  6506. /** @hidden */
  6507. easeInCore(gradient: number): number;
  6508. }
  6509. /**
  6510. * Easing function with a power of 3 shape (see link below).
  6511. * @see https://easings.net/#easeInCubic
  6512. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6513. */
  6514. export class CubicEase extends EasingFunction implements IEasingFunction {
  6515. /** @hidden */
  6516. easeInCore(gradient: number): number;
  6517. }
  6518. /**
  6519. * Easing function with an elastic shape (see link below).
  6520. * @see https://easings.net/#easeInElastic
  6521. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6522. */
  6523. export class ElasticEase extends EasingFunction implements IEasingFunction {
  6524. /** Defines the number of oscillations*/
  6525. oscillations: number;
  6526. /** Defines the amplitude of the oscillations*/
  6527. springiness: number;
  6528. /**
  6529. * Instantiates an elastic easing function
  6530. * @see https://easings.net/#easeInElastic
  6531. * @param oscillations Defines the number of oscillations
  6532. * @param springiness Defines the amplitude of the oscillations
  6533. */
  6534. constructor(
  6535. /** Defines the number of oscillations*/
  6536. oscillations?: number,
  6537. /** Defines the amplitude of the oscillations*/
  6538. springiness?: number);
  6539. /** @hidden */
  6540. easeInCore(gradient: number): number;
  6541. }
  6542. /**
  6543. * Easing function with an exponential shape (see link below).
  6544. * @see https://easings.net/#easeInExpo
  6545. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6546. */
  6547. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  6548. /** Defines the exponent of the function */
  6549. exponent: number;
  6550. /**
  6551. * Instantiates an exponential easing function
  6552. * @see https://easings.net/#easeInExpo
  6553. * @param exponent Defines the exponent of the function
  6554. */
  6555. constructor(
  6556. /** Defines the exponent of the function */
  6557. exponent?: number);
  6558. /** @hidden */
  6559. easeInCore(gradient: number): number;
  6560. }
  6561. /**
  6562. * Easing function with a power shape (see link below).
  6563. * @see https://easings.net/#easeInQuad
  6564. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6565. */
  6566. export class PowerEase extends EasingFunction implements IEasingFunction {
  6567. /** Defines the power of the function */
  6568. power: number;
  6569. /**
  6570. * Instantiates an power base easing function
  6571. * @see https://easings.net/#easeInQuad
  6572. * @param power Defines the power of the function
  6573. */
  6574. constructor(
  6575. /** Defines the power of the function */
  6576. power?: number);
  6577. /** @hidden */
  6578. easeInCore(gradient: number): number;
  6579. }
  6580. /**
  6581. * Easing function with a power of 2 shape (see link below).
  6582. * @see https://easings.net/#easeInQuad
  6583. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6584. */
  6585. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  6586. /** @hidden */
  6587. easeInCore(gradient: number): number;
  6588. }
  6589. /**
  6590. * Easing function with a power of 4 shape (see link below).
  6591. * @see https://easings.net/#easeInQuart
  6592. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6593. */
  6594. export class QuarticEase extends EasingFunction implements IEasingFunction {
  6595. /** @hidden */
  6596. easeInCore(gradient: number): number;
  6597. }
  6598. /**
  6599. * Easing function with a power of 5 shape (see link below).
  6600. * @see https://easings.net/#easeInQuint
  6601. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6602. */
  6603. export class QuinticEase extends EasingFunction implements IEasingFunction {
  6604. /** @hidden */
  6605. easeInCore(gradient: number): number;
  6606. }
  6607. /**
  6608. * Easing function with a sin shape (see link below).
  6609. * @see https://easings.net/#easeInSine
  6610. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6611. */
  6612. export class SineEase extends EasingFunction implements IEasingFunction {
  6613. /** @hidden */
  6614. easeInCore(gradient: number): number;
  6615. }
  6616. /**
  6617. * Easing function with a bezier shape (see link below).
  6618. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6619. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6620. */
  6621. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  6622. /** Defines the x component of the start tangent in the bezier curve */
  6623. x1: number;
  6624. /** Defines the y component of the start tangent in the bezier curve */
  6625. y1: number;
  6626. /** Defines the x component of the end tangent in the bezier curve */
  6627. x2: number;
  6628. /** Defines the y component of the end tangent in the bezier curve */
  6629. y2: number;
  6630. /**
  6631. * Instantiates a bezier function
  6632. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6633. * @param x1 Defines the x component of the start tangent in the bezier curve
  6634. * @param y1 Defines the y component of the start tangent in the bezier curve
  6635. * @param x2 Defines the x component of the end tangent in the bezier curve
  6636. * @param y2 Defines the y component of the end tangent in the bezier curve
  6637. */
  6638. constructor(
  6639. /** Defines the x component of the start tangent in the bezier curve */
  6640. x1?: number,
  6641. /** Defines the y component of the start tangent in the bezier curve */
  6642. y1?: number,
  6643. /** Defines the x component of the end tangent in the bezier curve */
  6644. x2?: number,
  6645. /** Defines the y component of the end tangent in the bezier curve */
  6646. y2?: number);
  6647. /** @hidden */
  6648. easeInCore(gradient: number): number;
  6649. }
  6650. }
  6651. declare module "babylonjs/Animations/animationKey" {
  6652. /**
  6653. * Defines an interface which represents an animation key frame
  6654. */
  6655. export interface IAnimationKey {
  6656. /**
  6657. * Frame of the key frame
  6658. */
  6659. frame: number;
  6660. /**
  6661. * Value at the specifies key frame
  6662. */
  6663. value: any;
  6664. /**
  6665. * The input tangent for the cubic hermite spline
  6666. */
  6667. inTangent?: any;
  6668. /**
  6669. * The output tangent for the cubic hermite spline
  6670. */
  6671. outTangent?: any;
  6672. /**
  6673. * The animation interpolation type
  6674. */
  6675. interpolation?: AnimationKeyInterpolation;
  6676. }
  6677. /**
  6678. * Enum for the animation key frame interpolation type
  6679. */
  6680. export enum AnimationKeyInterpolation {
  6681. /**
  6682. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6683. */
  6684. STEP = 1
  6685. }
  6686. }
  6687. declare module "babylonjs/Animations/animationRange" {
  6688. /**
  6689. * Represents the range of an animation
  6690. */
  6691. export class AnimationRange {
  6692. /**The name of the animation range**/
  6693. name: string;
  6694. /**The starting frame of the animation */
  6695. from: number;
  6696. /**The ending frame of the animation*/
  6697. to: number;
  6698. /**
  6699. * Initializes the range of an animation
  6700. * @param name The name of the animation range
  6701. * @param from The starting frame of the animation
  6702. * @param to The ending frame of the animation
  6703. */
  6704. constructor(
  6705. /**The name of the animation range**/
  6706. name: string,
  6707. /**The starting frame of the animation */
  6708. from: number,
  6709. /**The ending frame of the animation*/
  6710. to: number);
  6711. /**
  6712. * Makes a copy of the animation range
  6713. * @returns A copy of the animation range
  6714. */
  6715. clone(): AnimationRange;
  6716. }
  6717. }
  6718. declare module "babylonjs/Animations/animationEvent" {
  6719. /**
  6720. * Composed of a frame, and an action function
  6721. */
  6722. export class AnimationEvent {
  6723. /** The frame for which the event is triggered **/
  6724. frame: number;
  6725. /** The event to perform when triggered **/
  6726. action: (currentFrame: number) => void;
  6727. /** Specifies if the event should be triggered only once**/
  6728. onlyOnce?: boolean | undefined;
  6729. /**
  6730. * Specifies if the animation event is done
  6731. */
  6732. isDone: boolean;
  6733. /**
  6734. * Initializes the animation event
  6735. * @param frame The frame for which the event is triggered
  6736. * @param action The event to perform when triggered
  6737. * @param onlyOnce Specifies if the event should be triggered only once
  6738. */
  6739. constructor(
  6740. /** The frame for which the event is triggered **/
  6741. frame: number,
  6742. /** The event to perform when triggered **/
  6743. action: (currentFrame: number) => void,
  6744. /** Specifies if the event should be triggered only once**/
  6745. onlyOnce?: boolean | undefined);
  6746. /** @hidden */
  6747. _clone(): AnimationEvent;
  6748. }
  6749. }
  6750. declare module "babylonjs/Behaviors/behavior" {
  6751. import { Nullable } from "babylonjs/types";
  6752. /**
  6753. * Interface used to define a behavior
  6754. */
  6755. export interface Behavior<T> {
  6756. /** gets or sets behavior's name */
  6757. name: string;
  6758. /**
  6759. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6760. */
  6761. init(): void;
  6762. /**
  6763. * Called when the behavior is attached to a target
  6764. * @param target defines the target where the behavior is attached to
  6765. */
  6766. attach(target: T): void;
  6767. /**
  6768. * Called when the behavior is detached from its target
  6769. */
  6770. detach(): void;
  6771. }
  6772. /**
  6773. * Interface implemented by classes supporting behaviors
  6774. */
  6775. export interface IBehaviorAware<T> {
  6776. /**
  6777. * Attach a behavior
  6778. * @param behavior defines the behavior to attach
  6779. * @returns the current host
  6780. */
  6781. addBehavior(behavior: Behavior<T>): T;
  6782. /**
  6783. * Remove a behavior from the current object
  6784. * @param behavior defines the behavior to detach
  6785. * @returns the current host
  6786. */
  6787. removeBehavior(behavior: Behavior<T>): T;
  6788. /**
  6789. * Gets a behavior using its name to search
  6790. * @param name defines the name to search
  6791. * @returns the behavior or null if not found
  6792. */
  6793. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6794. }
  6795. }
  6796. declare module "babylonjs/Collisions/intersectionInfo" {
  6797. import { Nullable } from "babylonjs/types";
  6798. /**
  6799. * @hidden
  6800. */
  6801. export class IntersectionInfo {
  6802. bu: Nullable<number>;
  6803. bv: Nullable<number>;
  6804. distance: number;
  6805. faceId: number;
  6806. subMeshId: number;
  6807. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6808. }
  6809. }
  6810. declare module "babylonjs/Culling/boundingSphere" {
  6811. import { DeepImmutable } from "babylonjs/types";
  6812. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  6813. /**
  6814. * Class used to store bounding sphere information
  6815. */
  6816. export class BoundingSphere {
  6817. /**
  6818. * Gets the center of the bounding sphere in local space
  6819. */
  6820. readonly center: Vector3;
  6821. /**
  6822. * Radius of the bounding sphere in local space
  6823. */
  6824. radius: number;
  6825. /**
  6826. * Gets the center of the bounding sphere in world space
  6827. */
  6828. readonly centerWorld: Vector3;
  6829. /**
  6830. * Radius of the bounding sphere in world space
  6831. */
  6832. radiusWorld: number;
  6833. /**
  6834. * Gets the minimum vector in local space
  6835. */
  6836. readonly minimum: Vector3;
  6837. /**
  6838. * Gets the maximum vector in local space
  6839. */
  6840. readonly maximum: Vector3;
  6841. private _worldMatrix;
  6842. private static readonly TmpVector3;
  6843. /**
  6844. * Creates a new bounding sphere
  6845. * @param min defines the minimum vector (in local space)
  6846. * @param max defines the maximum vector (in local space)
  6847. * @param worldMatrix defines the new world matrix
  6848. */
  6849. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6850. /**
  6851. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6852. * @param min defines the new minimum vector (in local space)
  6853. * @param max defines the new maximum vector (in local space)
  6854. * @param worldMatrix defines the new world matrix
  6855. */
  6856. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6857. /**
  6858. * Scale the current bounding sphere by applying a scale factor
  6859. * @param factor defines the scale factor to apply
  6860. * @returns the current bounding box
  6861. */
  6862. scale(factor: number): BoundingSphere;
  6863. /**
  6864. * Gets the world matrix of the bounding box
  6865. * @returns a matrix
  6866. */
  6867. getWorldMatrix(): DeepImmutable<Matrix>;
  6868. /** @hidden */
  6869. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6870. /**
  6871. * Tests if the bounding sphere is intersecting the frustum planes
  6872. * @param frustumPlanes defines the frustum planes to test
  6873. * @returns true if there is an intersection
  6874. */
  6875. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6876. /**
  6877. * Tests if the bounding sphere center is in between the frustum planes.
  6878. * Used for optimistic fast inclusion.
  6879. * @param frustumPlanes defines the frustum planes to test
  6880. * @returns true if the sphere center is in between the frustum planes
  6881. */
  6882. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6883. /**
  6884. * Tests if a point is inside the bounding sphere
  6885. * @param point defines the point to test
  6886. * @returns true if the point is inside the bounding sphere
  6887. */
  6888. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6889. /**
  6890. * Checks if two sphere intersct
  6891. * @param sphere0 sphere 0
  6892. * @param sphere1 sphere 1
  6893. * @returns true if the speres intersect
  6894. */
  6895. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6896. }
  6897. }
  6898. declare module "babylonjs/Culling/boundingBox" {
  6899. import { DeepImmutable } from "babylonjs/types";
  6900. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  6901. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6902. import { ICullable } from "babylonjs/Culling/boundingInfo";
  6903. /**
  6904. * Class used to store bounding box information
  6905. */
  6906. export class BoundingBox implements ICullable {
  6907. /**
  6908. * Gets the 8 vectors representing the bounding box in local space
  6909. */
  6910. readonly vectors: Vector3[];
  6911. /**
  6912. * Gets the center of the bounding box in local space
  6913. */
  6914. readonly center: Vector3;
  6915. /**
  6916. * Gets the center of the bounding box in world space
  6917. */
  6918. readonly centerWorld: Vector3;
  6919. /**
  6920. * Gets the extend size in local space
  6921. */
  6922. readonly extendSize: Vector3;
  6923. /**
  6924. * Gets the extend size in world space
  6925. */
  6926. readonly extendSizeWorld: Vector3;
  6927. /**
  6928. * Gets the OBB (object bounding box) directions
  6929. */
  6930. readonly directions: Vector3[];
  6931. /**
  6932. * Gets the 8 vectors representing the bounding box in world space
  6933. */
  6934. readonly vectorsWorld: Vector3[];
  6935. /**
  6936. * Gets the minimum vector in world space
  6937. */
  6938. readonly minimumWorld: Vector3;
  6939. /**
  6940. * Gets the maximum vector in world space
  6941. */
  6942. readonly maximumWorld: Vector3;
  6943. /**
  6944. * Gets the minimum vector in local space
  6945. */
  6946. readonly minimum: Vector3;
  6947. /**
  6948. * Gets the maximum vector in local space
  6949. */
  6950. readonly maximum: Vector3;
  6951. private _worldMatrix;
  6952. private static readonly TmpVector3;
  6953. /**
  6954. * @hidden
  6955. */
  6956. _tag: number;
  6957. /**
  6958. * Creates a new bounding box
  6959. * @param min defines the minimum vector (in local space)
  6960. * @param max defines the maximum vector (in local space)
  6961. * @param worldMatrix defines the new world matrix
  6962. */
  6963. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6964. /**
  6965. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6966. * @param min defines the new minimum vector (in local space)
  6967. * @param max defines the new maximum vector (in local space)
  6968. * @param worldMatrix defines the new world matrix
  6969. */
  6970. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6971. /**
  6972. * Scale the current bounding box by applying a scale factor
  6973. * @param factor defines the scale factor to apply
  6974. * @returns the current bounding box
  6975. */
  6976. scale(factor: number): BoundingBox;
  6977. /**
  6978. * Gets the world matrix of the bounding box
  6979. * @returns a matrix
  6980. */
  6981. getWorldMatrix(): DeepImmutable<Matrix>;
  6982. /** @hidden */
  6983. _update(world: DeepImmutable<Matrix>): void;
  6984. /**
  6985. * Tests if the bounding box is intersecting the frustum planes
  6986. * @param frustumPlanes defines the frustum planes to test
  6987. * @returns true if there is an intersection
  6988. */
  6989. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6990. /**
  6991. * Tests if the bounding box is entirely inside the frustum planes
  6992. * @param frustumPlanes defines the frustum planes to test
  6993. * @returns true if there is an inclusion
  6994. */
  6995. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6996. /**
  6997. * Tests if a point is inside the bounding box
  6998. * @param point defines the point to test
  6999. * @returns true if the point is inside the bounding box
  7000. */
  7001. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7002. /**
  7003. * Tests if the bounding box intersects with a bounding sphere
  7004. * @param sphere defines the sphere to test
  7005. * @returns true if there is an intersection
  7006. */
  7007. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7008. /**
  7009. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7010. * @param min defines the min vector to use
  7011. * @param max defines the max vector to use
  7012. * @returns true if there is an intersection
  7013. */
  7014. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7015. /**
  7016. * Tests if two bounding boxes are intersections
  7017. * @param box0 defines the first box to test
  7018. * @param box1 defines the second box to test
  7019. * @returns true if there is an intersection
  7020. */
  7021. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7022. /**
  7023. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7024. * @param minPoint defines the minimum vector of the bounding box
  7025. * @param maxPoint defines the maximum vector of the bounding box
  7026. * @param sphereCenter defines the sphere center
  7027. * @param sphereRadius defines the sphere radius
  7028. * @returns true if there is an intersection
  7029. */
  7030. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7031. /**
  7032. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7033. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7034. * @param frustumPlanes defines the frustum planes to test
  7035. * @return true if there is an inclusion
  7036. */
  7037. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7038. /**
  7039. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7040. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7041. * @param frustumPlanes defines the frustum planes to test
  7042. * @return true if there is an intersection
  7043. */
  7044. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7045. }
  7046. }
  7047. declare module "babylonjs/Collisions/collider" {
  7048. import { Nullable, IndicesArray } from "babylonjs/types";
  7049. import { Vector3, Plane } from "babylonjs/Maths/math";
  7050. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7051. /** @hidden */
  7052. export class Collider {
  7053. /** Define if a collision was found */
  7054. collisionFound: boolean;
  7055. /**
  7056. * Define last intersection point in local space
  7057. */
  7058. intersectionPoint: Vector3;
  7059. /**
  7060. * Define last collided mesh
  7061. */
  7062. collidedMesh: Nullable<AbstractMesh>;
  7063. private _collisionPoint;
  7064. private _planeIntersectionPoint;
  7065. private _tempVector;
  7066. private _tempVector2;
  7067. private _tempVector3;
  7068. private _tempVector4;
  7069. private _edge;
  7070. private _baseToVertex;
  7071. private _destinationPoint;
  7072. private _slidePlaneNormal;
  7073. private _displacementVector;
  7074. /** @hidden */
  7075. _radius: Vector3;
  7076. /** @hidden */
  7077. _retry: number;
  7078. private _velocity;
  7079. private _basePoint;
  7080. private _epsilon;
  7081. /** @hidden */
  7082. _velocityWorldLength: number;
  7083. /** @hidden */
  7084. _basePointWorld: Vector3;
  7085. private _velocityWorld;
  7086. private _normalizedVelocity;
  7087. /** @hidden */
  7088. _initialVelocity: Vector3;
  7089. /** @hidden */
  7090. _initialPosition: Vector3;
  7091. private _nearestDistance;
  7092. private _collisionMask;
  7093. collisionMask: number;
  7094. /**
  7095. * Gets the plane normal used to compute the sliding response (in local space)
  7096. */
  7097. readonly slidePlaneNormal: Vector3;
  7098. /** @hidden */
  7099. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7100. /** @hidden */
  7101. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7102. /** @hidden */
  7103. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7104. /** @hidden */
  7105. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  7106. /** @hidden */
  7107. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  7108. /** @hidden */
  7109. _getResponse(pos: Vector3, vel: Vector3): void;
  7110. }
  7111. }
  7112. declare module "babylonjs/Culling/boundingInfo" {
  7113. import { DeepImmutable } from "babylonjs/types";
  7114. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  7115. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7116. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7117. import { Collider } from "babylonjs/Collisions/collider";
  7118. /**
  7119. * Interface for cullable objects
  7120. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7121. */
  7122. export interface ICullable {
  7123. /**
  7124. * Checks if the object or part of the object is in the frustum
  7125. * @param frustumPlanes Camera near/planes
  7126. * @returns true if the object is in frustum otherwise false
  7127. */
  7128. isInFrustum(frustumPlanes: Plane[]): boolean;
  7129. /**
  7130. * Checks if a cullable object (mesh...) is in the camera frustum
  7131. * Unlike isInFrustum this cheks the full bounding box
  7132. * @param frustumPlanes Camera near/planes
  7133. * @returns true if the object is in frustum otherwise false
  7134. */
  7135. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7136. }
  7137. /**
  7138. * Info for a bounding data of a mesh
  7139. */
  7140. export class BoundingInfo implements ICullable {
  7141. /**
  7142. * Bounding box for the mesh
  7143. */
  7144. readonly boundingBox: BoundingBox;
  7145. /**
  7146. * Bounding sphere for the mesh
  7147. */
  7148. readonly boundingSphere: BoundingSphere;
  7149. private _isLocked;
  7150. private static readonly TmpVector3;
  7151. /**
  7152. * Constructs bounding info
  7153. * @param minimum min vector of the bounding box/sphere
  7154. * @param maximum max vector of the bounding box/sphere
  7155. * @param worldMatrix defines the new world matrix
  7156. */
  7157. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7158. /**
  7159. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7160. * @param min defines the new minimum vector (in local space)
  7161. * @param max defines the new maximum vector (in local space)
  7162. * @param worldMatrix defines the new world matrix
  7163. */
  7164. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7165. /**
  7166. * min vector of the bounding box/sphere
  7167. */
  7168. readonly minimum: Vector3;
  7169. /**
  7170. * max vector of the bounding box/sphere
  7171. */
  7172. readonly maximum: Vector3;
  7173. /**
  7174. * If the info is locked and won't be updated to avoid perf overhead
  7175. */
  7176. isLocked: boolean;
  7177. /**
  7178. * Updates the bounding sphere and box
  7179. * @param world world matrix to be used to update
  7180. */
  7181. update(world: DeepImmutable<Matrix>): void;
  7182. /**
  7183. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7184. * @param center New center of the bounding info
  7185. * @param extend New extend of the bounding info
  7186. * @returns the current bounding info
  7187. */
  7188. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7189. /**
  7190. * Scale the current bounding info by applying a scale factor
  7191. * @param factor defines the scale factor to apply
  7192. * @returns the current bounding info
  7193. */
  7194. scale(factor: number): BoundingInfo;
  7195. /**
  7196. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7197. * @param frustumPlanes defines the frustum to test
  7198. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7199. * @returns true if the bounding info is in the frustum planes
  7200. */
  7201. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7202. /**
  7203. * Gets the world distance between the min and max points of the bounding box
  7204. */
  7205. readonly diagonalLength: number;
  7206. /**
  7207. * Checks if a cullable object (mesh...) is in the camera frustum
  7208. * Unlike isInFrustum this cheks the full bounding box
  7209. * @param frustumPlanes Camera near/planes
  7210. * @returns true if the object is in frustum otherwise false
  7211. */
  7212. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7213. /** @hidden */
  7214. _checkCollision(collider: Collider): boolean;
  7215. /**
  7216. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7217. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7218. * @param point the point to check intersection with
  7219. * @returns if the point intersects
  7220. */
  7221. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7222. /**
  7223. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7224. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7225. * @param boundingInfo the bounding info to check intersection with
  7226. * @param precise if the intersection should be done using OBB
  7227. * @returns if the bounding info intersects
  7228. */
  7229. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7230. }
  7231. }
  7232. declare module "babylonjs/Misc/smartArray" {
  7233. /**
  7234. * Defines an array and its length.
  7235. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  7236. */
  7237. export interface ISmartArrayLike<T> {
  7238. /**
  7239. * The data of the array.
  7240. */
  7241. data: Array<T>;
  7242. /**
  7243. * The active length of the array.
  7244. */
  7245. length: number;
  7246. }
  7247. /**
  7248. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7249. */
  7250. export class SmartArray<T> implements ISmartArrayLike<T> {
  7251. /**
  7252. * The full set of data from the array.
  7253. */
  7254. data: Array<T>;
  7255. /**
  7256. * The active length of the array.
  7257. */
  7258. length: number;
  7259. protected _id: number;
  7260. /**
  7261. * Instantiates a Smart Array.
  7262. * @param capacity defines the default capacity of the array.
  7263. */
  7264. constructor(capacity: number);
  7265. /**
  7266. * Pushes a value at the end of the active data.
  7267. * @param value defines the object to push in the array.
  7268. */
  7269. push(value: T): void;
  7270. /**
  7271. * Iterates over the active data and apply the lambda to them.
  7272. * @param func defines the action to apply on each value.
  7273. */
  7274. forEach(func: (content: T) => void): void;
  7275. /**
  7276. * Sorts the full sets of data.
  7277. * @param compareFn defines the comparison function to apply.
  7278. */
  7279. sort(compareFn: (a: T, b: T) => number): void;
  7280. /**
  7281. * Resets the active data to an empty array.
  7282. */
  7283. reset(): void;
  7284. /**
  7285. * Releases all the data from the array as well as the array.
  7286. */
  7287. dispose(): void;
  7288. /**
  7289. * Concats the active data with a given array.
  7290. * @param array defines the data to concatenate with.
  7291. */
  7292. concat(array: any): void;
  7293. /**
  7294. * Returns the position of a value in the active data.
  7295. * @param value defines the value to find the index for
  7296. * @returns the index if found in the active data otherwise -1
  7297. */
  7298. indexOf(value: T): number;
  7299. /**
  7300. * Returns whether an element is part of the active data.
  7301. * @param value defines the value to look for
  7302. * @returns true if found in the active data otherwise false
  7303. */
  7304. contains(value: T): boolean;
  7305. private static _GlobalId;
  7306. }
  7307. /**
  7308. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7309. * The data in this array can only be present once
  7310. */
  7311. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  7312. private _duplicateId;
  7313. /**
  7314. * Pushes a value at the end of the active data.
  7315. * THIS DOES NOT PREVENT DUPPLICATE DATA
  7316. * @param value defines the object to push in the array.
  7317. */
  7318. push(value: T): void;
  7319. /**
  7320. * Pushes a value at the end of the active data.
  7321. * If the data is already present, it won t be added again
  7322. * @param value defines the object to push in the array.
  7323. * @returns true if added false if it was already present
  7324. */
  7325. pushNoDuplicate(value: T): boolean;
  7326. /**
  7327. * Resets the active data to an empty array.
  7328. */
  7329. reset(): void;
  7330. /**
  7331. * Concats the active data with a given array.
  7332. * This ensures no dupplicate will be present in the result.
  7333. * @param array defines the data to concatenate with.
  7334. */
  7335. concatWithNoDuplicate(array: any): void;
  7336. }
  7337. }
  7338. declare module "babylonjs/Materials/multiMaterial" {
  7339. import { Nullable } from "babylonjs/types";
  7340. import { Scene } from "babylonjs/scene";
  7341. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7342. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  7343. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7344. import { Material } from "babylonjs/Materials/material";
  7345. /**
  7346. * A multi-material is used to apply different materials to different parts of the same object without the need of
  7347. * separate meshes. This can be use to improve performances.
  7348. * @see http://doc.babylonjs.com/how_to/multi_materials
  7349. */
  7350. export class MultiMaterial extends Material {
  7351. private _subMaterials;
  7352. /**
  7353. * Gets or Sets the list of Materials used within the multi material.
  7354. * They need to be ordered according to the submeshes order in the associated mesh
  7355. */
  7356. subMaterials: Nullable<Material>[];
  7357. /**
  7358. * Function used to align with Node.getChildren()
  7359. * @returns the list of Materials used within the multi material
  7360. */
  7361. getChildren(): Nullable<Material>[];
  7362. /**
  7363. * Instantiates a new Multi Material
  7364. * A multi-material is used to apply different materials to different parts of the same object without the need of
  7365. * separate meshes. This can be use to improve performances.
  7366. * @see http://doc.babylonjs.com/how_to/multi_materials
  7367. * @param name Define the name in the scene
  7368. * @param scene Define the scene the material belongs to
  7369. */
  7370. constructor(name: string, scene: Scene);
  7371. private _hookArray;
  7372. /**
  7373. * Get one of the submaterial by its index in the submaterials array
  7374. * @param index The index to look the sub material at
  7375. * @returns The Material if the index has been defined
  7376. */
  7377. getSubMaterial(index: number): Nullable<Material>;
  7378. /**
  7379. * Get the list of active textures for the whole sub materials list.
  7380. * @returns All the textures that will be used during the rendering
  7381. */
  7382. getActiveTextures(): BaseTexture[];
  7383. /**
  7384. * Gets the current class name of the material e.g. "MultiMaterial"
  7385. * Mainly use in serialization.
  7386. * @returns the class name
  7387. */
  7388. getClassName(): string;
  7389. /**
  7390. * Checks if the material is ready to render the requested sub mesh
  7391. * @param mesh Define the mesh the submesh belongs to
  7392. * @param subMesh Define the sub mesh to look readyness for
  7393. * @param useInstances Define whether or not the material is used with instances
  7394. * @returns true if ready, otherwise false
  7395. */
  7396. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  7397. /**
  7398. * Clones the current material and its related sub materials
  7399. * @param name Define the name of the newly cloned material
  7400. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  7401. * @returns the cloned material
  7402. */
  7403. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  7404. /**
  7405. * Serializes the materials into a JSON representation.
  7406. * @returns the JSON representation
  7407. */
  7408. serialize(): any;
  7409. /**
  7410. * Dispose the material and release its associated resources
  7411. * @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)
  7412. * @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)
  7413. * @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)
  7414. */
  7415. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  7416. /**
  7417. * Creates a MultiMaterial from parsed MultiMaterial data.
  7418. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  7419. * @param scene defines the hosting scene
  7420. * @returns a new MultiMaterial
  7421. */
  7422. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  7423. }
  7424. }
  7425. declare module "babylonjs/Loading/sceneLoaderFlags" {
  7426. /**
  7427. * Class used to represent data loading progression
  7428. */
  7429. export class SceneLoaderFlags {
  7430. private static _ForceFullSceneLoadingForIncremental;
  7431. private static _ShowLoadingScreen;
  7432. private static _CleanBoneMatrixWeights;
  7433. private static _loggingLevel;
  7434. /**
  7435. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  7436. */
  7437. static ForceFullSceneLoadingForIncremental: boolean;
  7438. /**
  7439. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  7440. */
  7441. static ShowLoadingScreen: boolean;
  7442. /**
  7443. * Defines the current logging level (while loading the scene)
  7444. * @ignorenaming
  7445. */
  7446. static loggingLevel: number;
  7447. /**
  7448. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  7449. */
  7450. static CleanBoneMatrixWeights: boolean;
  7451. }
  7452. }
  7453. declare module "babylonjs/Meshes/transformNode" {
  7454. import { DeepImmutable } from "babylonjs/types";
  7455. import { Observable } from "babylonjs/Misc/observable";
  7456. import { Nullable } from "babylonjs/types";
  7457. import { Camera } from "babylonjs/Cameras/camera";
  7458. import { Scene } from "babylonjs/scene";
  7459. import { Quaternion, Matrix, Vector3, Space } from "babylonjs/Maths/math";
  7460. import { Node } from "babylonjs/node";
  7461. import { Bone } from "babylonjs/Bones/bone";
  7462. /**
  7463. * 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.
  7464. * @see https://doc.babylonjs.com/how_to/transformnode
  7465. */
  7466. export class TransformNode extends Node {
  7467. /**
  7468. * Object will not rotate to face the camera
  7469. */
  7470. static BILLBOARDMODE_NONE: number;
  7471. /**
  7472. * Object will rotate to face the camera but only on the x axis
  7473. */
  7474. static BILLBOARDMODE_X: number;
  7475. /**
  7476. * Object will rotate to face the camera but only on the y axis
  7477. */
  7478. static BILLBOARDMODE_Y: number;
  7479. /**
  7480. * Object will rotate to face the camera but only on the z axis
  7481. */
  7482. static BILLBOARDMODE_Z: number;
  7483. /**
  7484. * Object will rotate to face the camera
  7485. */
  7486. static BILLBOARDMODE_ALL: number;
  7487. private _forward;
  7488. private _forwardInverted;
  7489. private _up;
  7490. private _right;
  7491. private _rightInverted;
  7492. private _position;
  7493. private _rotation;
  7494. private _rotationQuaternion;
  7495. protected _scaling: Vector3;
  7496. protected _isDirty: boolean;
  7497. private _transformToBoneReferal;
  7498. /**
  7499. * Set the billboard mode. Default is 0.
  7500. *
  7501. * | Value | Type | Description |
  7502. * | --- | --- | --- |
  7503. * | 0 | BILLBOARDMODE_NONE | |
  7504. * | 1 | BILLBOARDMODE_X | |
  7505. * | 2 | BILLBOARDMODE_Y | |
  7506. * | 4 | BILLBOARDMODE_Z | |
  7507. * | 7 | BILLBOARDMODE_ALL | |
  7508. *
  7509. */
  7510. billboardMode: number;
  7511. /**
  7512. * 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
  7513. */
  7514. scalingDeterminant: number;
  7515. /**
  7516. * Sets the distance of the object to max, often used by skybox
  7517. */
  7518. infiniteDistance: boolean;
  7519. /**
  7520. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  7521. * By default the system will update normals to compensate
  7522. */
  7523. ignoreNonUniformScaling: boolean;
  7524. /** @hidden */
  7525. _poseMatrix: Matrix;
  7526. /** @hidden */
  7527. _localMatrix: Matrix;
  7528. private _absolutePosition;
  7529. private _pivotMatrix;
  7530. private _pivotMatrixInverse;
  7531. protected _postMultiplyPivotMatrix: boolean;
  7532. private _tempMatrix;
  7533. private _tempMatrix2;
  7534. protected _isWorldMatrixFrozen: boolean;
  7535. /** @hidden */
  7536. _indexInSceneTransformNodesArray: number;
  7537. /**
  7538. * An event triggered after the world matrix is updated
  7539. */
  7540. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  7541. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  7542. /**
  7543. * Gets a string identifying the name of the class
  7544. * @returns "TransformNode" string
  7545. */
  7546. getClassName(): string;
  7547. /**
  7548. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  7549. */
  7550. position: Vector3;
  7551. /**
  7552. * 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)).
  7553. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  7554. */
  7555. rotation: Vector3;
  7556. /**
  7557. * 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)).
  7558. */
  7559. scaling: Vector3;
  7560. /**
  7561. * 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).
  7562. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  7563. */
  7564. rotationQuaternion: Nullable<Quaternion>;
  7565. /**
  7566. * The forward direction of that transform in world space.
  7567. */
  7568. readonly forward: Vector3;
  7569. /**
  7570. * The up direction of that transform in world space.
  7571. */
  7572. readonly up: Vector3;
  7573. /**
  7574. * The right direction of that transform in world space.
  7575. */
  7576. readonly right: Vector3;
  7577. /**
  7578. * Copies the parameter passed Matrix into the mesh Pose matrix.
  7579. * @param matrix the matrix to copy the pose from
  7580. * @returns this TransformNode.
  7581. */
  7582. updatePoseMatrix(matrix: Matrix): TransformNode;
  7583. /**
  7584. * Returns the mesh Pose matrix.
  7585. * @returns the pose matrix
  7586. */
  7587. getPoseMatrix(): Matrix;
  7588. /** @hidden */
  7589. _isSynchronized(): boolean;
  7590. /** @hidden */
  7591. _initCache(): void;
  7592. /**
  7593. * Flag the transform node as dirty (Forcing it to update everything)
  7594. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  7595. * @returns this transform node
  7596. */
  7597. markAsDirty(property: string): TransformNode;
  7598. /**
  7599. * Returns the current mesh absolute position.
  7600. * Returns a Vector3.
  7601. */
  7602. readonly absolutePosition: Vector3;
  7603. /**
  7604. * Sets a new matrix to apply before all other transformation
  7605. * @param matrix defines the transform matrix
  7606. * @returns the current TransformNode
  7607. */
  7608. setPreTransformMatrix(matrix: Matrix): TransformNode;
  7609. /**
  7610. * Sets a new pivot matrix to the current node
  7611. * @param matrix defines the new pivot matrix to use
  7612. * @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
  7613. * @returns the current TransformNode
  7614. */
  7615. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  7616. /**
  7617. * Returns the mesh pivot matrix.
  7618. * Default : Identity.
  7619. * @returns the matrix
  7620. */
  7621. getPivotMatrix(): Matrix;
  7622. /**
  7623. * Prevents the World matrix to be computed any longer.
  7624. * @returns the TransformNode.
  7625. */
  7626. freezeWorldMatrix(): TransformNode;
  7627. /**
  7628. * Allows back the World matrix computation.
  7629. * @returns the TransformNode.
  7630. */
  7631. unfreezeWorldMatrix(): this;
  7632. /**
  7633. * True if the World matrix has been frozen.
  7634. */
  7635. readonly isWorldMatrixFrozen: boolean;
  7636. /**
  7637. * Retuns the mesh absolute position in the World.
  7638. * @returns a Vector3.
  7639. */
  7640. getAbsolutePosition(): Vector3;
  7641. /**
  7642. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  7643. * @param absolutePosition the absolute position to set
  7644. * @returns the TransformNode.
  7645. */
  7646. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  7647. /**
  7648. * Sets the mesh position in its local space.
  7649. * @param vector3 the position to set in localspace
  7650. * @returns the TransformNode.
  7651. */
  7652. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  7653. /**
  7654. * Returns the mesh position in the local space from the current World matrix values.
  7655. * @returns a new Vector3.
  7656. */
  7657. getPositionExpressedInLocalSpace(): Vector3;
  7658. /**
  7659. * Translates the mesh along the passed Vector3 in its local space.
  7660. * @param vector3 the distance to translate in localspace
  7661. * @returns the TransformNode.
  7662. */
  7663. locallyTranslate(vector3: Vector3): TransformNode;
  7664. private static _lookAtVectorCache;
  7665. /**
  7666. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  7667. * @param targetPoint the position (must be in same space as current mesh) to look at
  7668. * @param yawCor optional yaw (y-axis) correction in radians
  7669. * @param pitchCor optional pitch (x-axis) correction in radians
  7670. * @param rollCor optional roll (z-axis) correction in radians
  7671. * @param space the choosen space of the target
  7672. * @returns the TransformNode.
  7673. */
  7674. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  7675. /**
  7676. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  7677. * This Vector3 is expressed in the World space.
  7678. * @param localAxis axis to rotate
  7679. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  7680. */
  7681. getDirection(localAxis: Vector3): Vector3;
  7682. /**
  7683. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  7684. * localAxis is expressed in the mesh local space.
  7685. * result is computed in the Wordl space from the mesh World matrix.
  7686. * @param localAxis axis to rotate
  7687. * @param result the resulting transformnode
  7688. * @returns this TransformNode.
  7689. */
  7690. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  7691. /**
  7692. * Sets this transform node rotation to the given local axis.
  7693. * @param localAxis the axis in local space
  7694. * @param yawCor optional yaw (y-axis) correction in radians
  7695. * @param pitchCor optional pitch (x-axis) correction in radians
  7696. * @param rollCor optional roll (z-axis) correction in radians
  7697. * @returns this TransformNode
  7698. */
  7699. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  7700. /**
  7701. * Sets a new pivot point to the current node
  7702. * @param point defines the new pivot point to use
  7703. * @param space defines if the point is in world or local space (local by default)
  7704. * @returns the current TransformNode
  7705. */
  7706. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  7707. /**
  7708. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  7709. * @returns the pivot point
  7710. */
  7711. getPivotPoint(): Vector3;
  7712. /**
  7713. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  7714. * @param result the vector3 to store the result
  7715. * @returns this TransformNode.
  7716. */
  7717. getPivotPointToRef(result: Vector3): TransformNode;
  7718. /**
  7719. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  7720. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  7721. */
  7722. getAbsolutePivotPoint(): Vector3;
  7723. /**
  7724. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  7725. * @param result vector3 to store the result
  7726. * @returns this TransformNode.
  7727. */
  7728. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  7729. /**
  7730. * Defines the passed node as the parent of the current node.
  7731. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  7732. * @param node the node ot set as the parent
  7733. * @returns this TransformNode.
  7734. */
  7735. setParent(node: Nullable<Node>): TransformNode;
  7736. private _nonUniformScaling;
  7737. /**
  7738. * True if the scaling property of this object is non uniform eg. (1,2,1)
  7739. */
  7740. readonly nonUniformScaling: boolean;
  7741. /** @hidden */
  7742. _updateNonUniformScalingState(value: boolean): boolean;
  7743. /**
  7744. * Attach the current TransformNode to another TransformNode associated with a bone
  7745. * @param bone Bone affecting the TransformNode
  7746. * @param affectedTransformNode TransformNode associated with the bone
  7747. * @returns this object
  7748. */
  7749. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  7750. /**
  7751. * Detach the transform node if its associated with a bone
  7752. * @returns this object
  7753. */
  7754. detachFromBone(): TransformNode;
  7755. private static _rotationAxisCache;
  7756. /**
  7757. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  7758. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  7759. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  7760. * The passed axis is also normalized.
  7761. * @param axis the axis to rotate around
  7762. * @param amount the amount to rotate in radians
  7763. * @param space Space to rotate in (Default: local)
  7764. * @returns the TransformNode.
  7765. */
  7766. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  7767. /**
  7768. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  7769. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  7770. * The passed axis is also normalized. .
  7771. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  7772. * @param point the point to rotate around
  7773. * @param axis the axis to rotate around
  7774. * @param amount the amount to rotate in radians
  7775. * @returns the TransformNode
  7776. */
  7777. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  7778. /**
  7779. * Translates the mesh along the axis vector for the passed distance in the given space.
  7780. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  7781. * @param axis the axis to translate in
  7782. * @param distance the distance to translate
  7783. * @param space Space to rotate in (Default: local)
  7784. * @returns the TransformNode.
  7785. */
  7786. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  7787. /**
  7788. * Adds a rotation step to the mesh current rotation.
  7789. * x, y, z are Euler angles expressed in radians.
  7790. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  7791. * This means this rotation is made in the mesh local space only.
  7792. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  7793. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  7794. * ```javascript
  7795. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  7796. * ```
  7797. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  7798. * 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.
  7799. * @param x Rotation to add
  7800. * @param y Rotation to add
  7801. * @param z Rotation to add
  7802. * @returns the TransformNode.
  7803. */
  7804. addRotation(x: number, y: number, z: number): TransformNode;
  7805. /**
  7806. * Computes the world matrix of the node
  7807. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  7808. * @returns the world matrix
  7809. */
  7810. computeWorldMatrix(force?: boolean): Matrix;
  7811. protected _afterComputeWorldMatrix(): void;
  7812. /**
  7813. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  7814. * @param func callback function to add
  7815. *
  7816. * @returns the TransformNode.
  7817. */
  7818. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  7819. /**
  7820. * Removes a registered callback function.
  7821. * @param func callback function to remove
  7822. * @returns the TransformNode.
  7823. */
  7824. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  7825. /**
  7826. * Gets the position of the current mesh in camera space
  7827. * @param camera defines the camera to use
  7828. * @returns a position
  7829. */
  7830. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  7831. /**
  7832. * Returns the distance from the mesh to the active camera
  7833. * @param camera defines the camera to use
  7834. * @returns the distance
  7835. */
  7836. getDistanceToCamera(camera?: Nullable<Camera>): number;
  7837. /**
  7838. * Clone the current transform node
  7839. * @param name Name of the new clone
  7840. * @param newParent New parent for the clone
  7841. * @param doNotCloneChildren Do not clone children hierarchy
  7842. * @returns the new transform node
  7843. */
  7844. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  7845. /**
  7846. * Serializes the objects information.
  7847. * @param currentSerializationObject defines the object to serialize in
  7848. * @returns the serialized object
  7849. */
  7850. serialize(currentSerializationObject?: any): any;
  7851. /**
  7852. * Returns a new TransformNode object parsed from the source provided.
  7853. * @param parsedTransformNode is the source.
  7854. * @param scene the scne the object belongs to
  7855. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  7856. * @returns a new TransformNode object parsed from the source provided.
  7857. */
  7858. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  7859. /**
  7860. * Get all child-transformNodes of this node
  7861. * @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
  7862. * @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
  7863. * @returns an array of TransformNode
  7864. */
  7865. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  7866. /**
  7867. * Releases resources associated with this transform node.
  7868. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  7869. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  7870. */
  7871. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  7872. }
  7873. }
  7874. declare module "babylonjs/Animations/animationPropertiesOverride" {
  7875. /**
  7876. * Class used to override all child animations of a given target
  7877. */
  7878. export class AnimationPropertiesOverride {
  7879. /**
  7880. * Gets or sets a value indicating if animation blending must be used
  7881. */
  7882. enableBlending: boolean;
  7883. /**
  7884. * Gets or sets the blending speed to use when enableBlending is true
  7885. */
  7886. blendingSpeed: number;
  7887. /**
  7888. * Gets or sets the default loop mode to use
  7889. */
  7890. loopMode: number;
  7891. }
  7892. }
  7893. declare module "babylonjs/Bones/bone" {
  7894. import { Skeleton } from "babylonjs/Bones/skeleton";
  7895. import { Vector3, Quaternion, Matrix, Space } from "babylonjs/Maths/math";
  7896. import { Nullable } from "babylonjs/types";
  7897. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7898. import { TransformNode } from "babylonjs/Meshes/transformNode";
  7899. import { Node } from "babylonjs/node";
  7900. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  7901. /**
  7902. * Class used to store bone information
  7903. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  7904. */
  7905. export class Bone extends Node {
  7906. /**
  7907. * defines the bone name
  7908. */
  7909. name: string;
  7910. private static _tmpVecs;
  7911. private static _tmpQuat;
  7912. private static _tmpMats;
  7913. /**
  7914. * Gets the list of child bones
  7915. */
  7916. children: Bone[];
  7917. /** Gets the animations associated with this bone */
  7918. animations: import("babylonjs/Animations/animation").Animation[];
  7919. /**
  7920. * Gets or sets bone length
  7921. */
  7922. length: number;
  7923. /**
  7924. * @hidden Internal only
  7925. * Set this value to map this bone to a different index in the transform matrices
  7926. * Set this value to -1 to exclude the bone from the transform matrices
  7927. */
  7928. _index: Nullable<number>;
  7929. private _skeleton;
  7930. private _localMatrix;
  7931. private _restPose;
  7932. private _baseMatrix;
  7933. private _absoluteTransform;
  7934. private _invertedAbsoluteTransform;
  7935. private _parent;
  7936. private _scalingDeterminant;
  7937. private _worldTransform;
  7938. private _localScaling;
  7939. private _localRotation;
  7940. private _localPosition;
  7941. private _needToDecompose;
  7942. private _needToCompose;
  7943. /** @hidden */
  7944. _linkedTransformNode: Nullable<TransformNode>;
  7945. /** @hidden */
  7946. /** @hidden */
  7947. _matrix: Matrix;
  7948. /**
  7949. * Create a new bone
  7950. * @param name defines the bone name
  7951. * @param skeleton defines the parent skeleton
  7952. * @param parentBone defines the parent (can be null if the bone is the root)
  7953. * @param localMatrix defines the local matrix
  7954. * @param restPose defines the rest pose matrix
  7955. * @param baseMatrix defines the base matrix
  7956. * @param index defines index of the bone in the hiearchy
  7957. */
  7958. constructor(
  7959. /**
  7960. * defines the bone name
  7961. */
  7962. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  7963. /**
  7964. * Gets the current object class name.
  7965. * @return the class name
  7966. */
  7967. getClassName(): string;
  7968. /**
  7969. * Gets the parent skeleton
  7970. * @returns a skeleton
  7971. */
  7972. getSkeleton(): Skeleton;
  7973. /**
  7974. * Gets parent bone
  7975. * @returns a bone or null if the bone is the root of the bone hierarchy
  7976. */
  7977. getParent(): Nullable<Bone>;
  7978. /**
  7979. * Returns an array containing the root bones
  7980. * @returns an array containing the root bones
  7981. */
  7982. getChildren(): Array<Bone>;
  7983. /**
  7984. * Sets the parent bone
  7985. * @param parent defines the parent (can be null if the bone is the root)
  7986. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  7987. */
  7988. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  7989. /**
  7990. * Gets the local matrix
  7991. * @returns a matrix
  7992. */
  7993. getLocalMatrix(): Matrix;
  7994. /**
  7995. * Gets the base matrix (initial matrix which remains unchanged)
  7996. * @returns a matrix
  7997. */
  7998. getBaseMatrix(): Matrix;
  7999. /**
  8000. * Gets the rest pose matrix
  8001. * @returns a matrix
  8002. */
  8003. getRestPose(): Matrix;
  8004. /**
  8005. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  8006. */
  8007. getWorldMatrix(): Matrix;
  8008. /**
  8009. * Sets the local matrix to rest pose matrix
  8010. */
  8011. returnToRest(): void;
  8012. /**
  8013. * Gets the inverse of the absolute transform matrix.
  8014. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  8015. * @returns a matrix
  8016. */
  8017. getInvertedAbsoluteTransform(): Matrix;
  8018. /**
  8019. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  8020. * @returns a matrix
  8021. */
  8022. getAbsoluteTransform(): Matrix;
  8023. /**
  8024. * Links with the given transform node.
  8025. * The local matrix of this bone is copied from the transform node every frame.
  8026. * @param transformNode defines the transform node to link to
  8027. */
  8028. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  8029. /** Gets or sets current position (in local space) */
  8030. position: Vector3;
  8031. /** Gets or sets current rotation (in local space) */
  8032. rotation: Vector3;
  8033. /** Gets or sets current rotation quaternion (in local space) */
  8034. rotationQuaternion: Quaternion;
  8035. /** Gets or sets current scaling (in local space) */
  8036. scaling: Vector3;
  8037. /**
  8038. * Gets the animation properties override
  8039. */
  8040. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  8041. private _decompose;
  8042. private _compose;
  8043. /**
  8044. * Update the base and local matrices
  8045. * @param matrix defines the new base or local matrix
  8046. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  8047. * @param updateLocalMatrix defines if the local matrix should be updated
  8048. */
  8049. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  8050. /** @hidden */
  8051. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  8052. /**
  8053. * Flag the bone as dirty (Forcing it to update everything)
  8054. */
  8055. markAsDirty(): void;
  8056. private _markAsDirtyAndCompose;
  8057. private _markAsDirtyAndDecompose;
  8058. /**
  8059. * Translate the bone in local or world space
  8060. * @param vec The amount to translate the bone
  8061. * @param space The space that the translation is in
  8062. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8063. */
  8064. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8065. /**
  8066. * Set the postion of the bone in local or world space
  8067. * @param position The position to set the bone
  8068. * @param space The space that the position is in
  8069. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8070. */
  8071. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8072. /**
  8073. * Set the absolute position of the bone (world space)
  8074. * @param position The position to set the bone
  8075. * @param mesh The mesh that this bone is attached to
  8076. */
  8077. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  8078. /**
  8079. * Scale the bone on the x, y and z axes (in local space)
  8080. * @param x The amount to scale the bone on the x axis
  8081. * @param y The amount to scale the bone on the y axis
  8082. * @param z The amount to scale the bone on the z axis
  8083. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  8084. */
  8085. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  8086. /**
  8087. * Set the bone scaling in local space
  8088. * @param scale defines the scaling vector
  8089. */
  8090. setScale(scale: Vector3): void;
  8091. /**
  8092. * Gets the current scaling in local space
  8093. * @returns the current scaling vector
  8094. */
  8095. getScale(): Vector3;
  8096. /**
  8097. * Gets the current scaling in local space and stores it in a target vector
  8098. * @param result defines the target vector
  8099. */
  8100. getScaleToRef(result: Vector3): void;
  8101. /**
  8102. * Set the yaw, pitch, and roll of the bone in local or world space
  8103. * @param yaw The rotation of the bone on the y axis
  8104. * @param pitch The rotation of the bone on the x axis
  8105. * @param roll The rotation of the bone on the z axis
  8106. * @param space The space that the axes of rotation are in
  8107. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8108. */
  8109. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  8110. /**
  8111. * Add a rotation to the bone on an axis in local or world space
  8112. * @param axis The axis to rotate the bone on
  8113. * @param amount The amount to rotate the bone
  8114. * @param space The space that the axis is in
  8115. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8116. */
  8117. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  8118. /**
  8119. * Set the rotation of the bone to a particular axis angle in local or world space
  8120. * @param axis The axis to rotate the bone on
  8121. * @param angle The angle that the bone should be rotated to
  8122. * @param space The space that the axis is in
  8123. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8124. */
  8125. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  8126. /**
  8127. * Set the euler rotation of the bone in local of world space
  8128. * @param rotation The euler rotation that the bone should be set to
  8129. * @param space The space that the rotation is in
  8130. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8131. */
  8132. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8133. /**
  8134. * Set the quaternion rotation of the bone in local of world space
  8135. * @param quat The quaternion rotation that the bone should be set to
  8136. * @param space The space that the rotation is in
  8137. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8138. */
  8139. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  8140. /**
  8141. * Set the rotation matrix of the bone in local of world space
  8142. * @param rotMat The rotation matrix that the bone should be set to
  8143. * @param space The space that the rotation is in
  8144. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8145. */
  8146. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  8147. private _rotateWithMatrix;
  8148. private _getNegativeRotationToRef;
  8149. /**
  8150. * Get the position of the bone in local or world space
  8151. * @param space The space that the returned position is in
  8152. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8153. * @returns The position of the bone
  8154. */
  8155. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  8156. /**
  8157. * Copy the position of the bone to a vector3 in local or world space
  8158. * @param space The space that the returned position is in
  8159. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8160. * @param result The vector3 to copy the position to
  8161. */
  8162. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  8163. /**
  8164. * Get the absolute position of the bone (world space)
  8165. * @param mesh The mesh that this bone is attached to
  8166. * @returns The absolute position of the bone
  8167. */
  8168. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  8169. /**
  8170. * Copy the absolute position of the bone (world space) to the result param
  8171. * @param mesh The mesh that this bone is attached to
  8172. * @param result The vector3 to copy the absolute position to
  8173. */
  8174. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  8175. /**
  8176. * Compute the absolute transforms of this bone and its children
  8177. */
  8178. computeAbsoluteTransforms(): void;
  8179. /**
  8180. * Get the world direction from an axis that is in the local space of the bone
  8181. * @param localAxis The local direction that is used to compute the world direction
  8182. * @param mesh The mesh that this bone is attached to
  8183. * @returns The world direction
  8184. */
  8185. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8186. /**
  8187. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  8188. * @param localAxis The local direction that is used to compute the world direction
  8189. * @param mesh The mesh that this bone is attached to
  8190. * @param result The vector3 that the world direction will be copied to
  8191. */
  8192. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8193. /**
  8194. * Get the euler rotation of the bone in local or world space
  8195. * @param space The space that the rotation should be in
  8196. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8197. * @returns The euler rotation
  8198. */
  8199. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  8200. /**
  8201. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  8202. * @param space The space that the rotation should be in
  8203. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8204. * @param result The vector3 that the rotation should be copied to
  8205. */
  8206. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8207. /**
  8208. * Get the quaternion rotation of the bone in either local or world space
  8209. * @param space The space that the rotation should be in
  8210. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8211. * @returns The quaternion rotation
  8212. */
  8213. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  8214. /**
  8215. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  8216. * @param space The space that the rotation should be in
  8217. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8218. * @param result The quaternion that the rotation should be copied to
  8219. */
  8220. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  8221. /**
  8222. * Get the rotation matrix of the bone in local or world space
  8223. * @param space The space that the rotation should be in
  8224. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8225. * @returns The rotation matrix
  8226. */
  8227. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  8228. /**
  8229. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  8230. * @param space The space that the rotation should be in
  8231. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8232. * @param result The quaternion that the rotation should be copied to
  8233. */
  8234. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  8235. /**
  8236. * Get the world position of a point that is in the local space of the bone
  8237. * @param position The local position
  8238. * @param mesh The mesh that this bone is attached to
  8239. * @returns The world position
  8240. */
  8241. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8242. /**
  8243. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  8244. * @param position The local position
  8245. * @param mesh The mesh that this bone is attached to
  8246. * @param result The vector3 that the world position should be copied to
  8247. */
  8248. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8249. /**
  8250. * Get the local position of a point that is in world space
  8251. * @param position The world position
  8252. * @param mesh The mesh that this bone is attached to
  8253. * @returns The local position
  8254. */
  8255. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8256. /**
  8257. * Get the local position of a point that is in world space and copy it to the result param
  8258. * @param position The world position
  8259. * @param mesh The mesh that this bone is attached to
  8260. * @param result The vector3 that the local position should be copied to
  8261. */
  8262. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8263. }
  8264. }
  8265. declare module "babylonjs/Materials/Textures/cubeTexture" {
  8266. import { Nullable } from "babylonjs/types";
  8267. import { Scene } from "babylonjs/scene";
  8268. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  8269. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8270. /**
  8271. * Class for creating a cube texture
  8272. */
  8273. export class CubeTexture extends BaseTexture {
  8274. private _delayedOnLoad;
  8275. /**
  8276. * The url of the texture
  8277. */
  8278. url: string;
  8279. /**
  8280. * Gets or sets the center of the bounding box associated with the cube texture.
  8281. * It must define where the camera used to render the texture was set
  8282. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  8283. */
  8284. boundingBoxPosition: Vector3;
  8285. private _boundingBoxSize;
  8286. /**
  8287. * Gets or sets the size of the bounding box associated with the cube texture
  8288. * When defined, the cubemap will switch to local mode
  8289. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  8290. * @example https://www.babylonjs-playground.com/#RNASML
  8291. */
  8292. /**
  8293. * Returns the bounding box size
  8294. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  8295. */
  8296. boundingBoxSize: Vector3;
  8297. protected _rotationY: number;
  8298. /**
  8299. * Sets texture matrix rotation angle around Y axis in radians.
  8300. */
  8301. /**
  8302. * Gets texture matrix rotation angle around Y axis radians.
  8303. */
  8304. rotationY: number;
  8305. /**
  8306. * Are mip maps generated for this texture or not.
  8307. */
  8308. readonly noMipmap: boolean;
  8309. private _noMipmap;
  8310. private _files;
  8311. private _extensions;
  8312. private _textureMatrix;
  8313. private _format;
  8314. private _createPolynomials;
  8315. /** @hidden */
  8316. _prefiltered: boolean;
  8317. /**
  8318. * Creates a cube texture from an array of image urls
  8319. * @param files defines an array of image urls
  8320. * @param scene defines the hosting scene
  8321. * @param noMipmap specifies if mip maps are not used
  8322. * @returns a cube texture
  8323. */
  8324. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  8325. /**
  8326. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  8327. * @param url defines the url of the prefiltered texture
  8328. * @param scene defines the scene the texture is attached to
  8329. * @param forcedExtension defines the extension of the file if different from the url
  8330. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8331. * @return the prefiltered texture
  8332. */
  8333. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  8334. /**
  8335. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  8336. * as prefiltered data.
  8337. * @param rootUrl defines the url of the texture or the root name of the six images
  8338. * @param scene defines the scene the texture is attached to
  8339. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  8340. * @param noMipmap defines if mipmaps should be created or not
  8341. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  8342. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  8343. * @param onError defines a callback triggered in case of error during load
  8344. * @param format defines the internal format to use for the texture once loaded
  8345. * @param prefiltered defines whether or not the texture is created from prefiltered data
  8346. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  8347. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8348. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8349. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8350. * @return the cube texture
  8351. */
  8352. 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);
  8353. /**
  8354. * Get the current class name of the texture useful for serialization or dynamic coding.
  8355. * @returns "CubeTexture"
  8356. */
  8357. getClassName(): string;
  8358. /**
  8359. * Update the url (and optional buffer) of this texture if url was null during construction.
  8360. * @param url the url of the texture
  8361. * @param forcedExtension defines the extension to use
  8362. * @param onLoad callback called when the texture is loaded (defaults to null)
  8363. */
  8364. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  8365. /**
  8366. * Delays loading of the cube texture
  8367. * @param forcedExtension defines the extension to use
  8368. */
  8369. delayLoad(forcedExtension?: string): void;
  8370. /**
  8371. * Returns the reflection texture matrix
  8372. * @returns the reflection texture matrix
  8373. */
  8374. getReflectionTextureMatrix(): Matrix;
  8375. /**
  8376. * Sets the reflection texture matrix
  8377. * @param value Reflection texture matrix
  8378. */
  8379. setReflectionTextureMatrix(value: Matrix): void;
  8380. /**
  8381. * Parses text to create a cube texture
  8382. * @param parsedTexture define the serialized text to read from
  8383. * @param scene defines the hosting scene
  8384. * @param rootUrl defines the root url of the cube texture
  8385. * @returns a cube texture
  8386. */
  8387. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  8388. /**
  8389. * Makes a clone, or deep copy, of the cube texture
  8390. * @returns a new cube texture
  8391. */
  8392. clone(): CubeTexture;
  8393. }
  8394. }
  8395. declare module "babylonjs/Shaders/postprocess.vertex" {
  8396. /** @hidden */
  8397. export var postprocessVertexShader: {
  8398. name: string;
  8399. shader: string;
  8400. };
  8401. }
  8402. declare module "babylonjs/Cameras/targetCamera" {
  8403. import { Nullable } from "babylonjs/types";
  8404. import { Camera } from "babylonjs/Cameras/camera";
  8405. import { Scene } from "babylonjs/scene";
  8406. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math";
  8407. /**
  8408. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8409. * This is the base of the follow, arc rotate cameras and Free camera
  8410. * @see http://doc.babylonjs.com/features/cameras
  8411. */
  8412. export class TargetCamera extends Camera {
  8413. private static _RigCamTransformMatrix;
  8414. private static _TargetTransformMatrix;
  8415. private static _TargetFocalPoint;
  8416. /**
  8417. * Define the current direction the camera is moving to
  8418. */
  8419. cameraDirection: Vector3;
  8420. /**
  8421. * Define the current rotation the camera is rotating to
  8422. */
  8423. cameraRotation: Vector2;
  8424. /**
  8425. * When set, the up vector of the camera will be updated by the rotation of the camera
  8426. */
  8427. updateUpVectorFromRotation: boolean;
  8428. private _tmpQuaternion;
  8429. /**
  8430. * Define the current rotation of the camera
  8431. */
  8432. rotation: Vector3;
  8433. /**
  8434. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8435. */
  8436. rotationQuaternion: Quaternion;
  8437. /**
  8438. * Define the current speed of the camera
  8439. */
  8440. speed: number;
  8441. /**
  8442. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8443. * around all axis.
  8444. */
  8445. noRotationConstraint: boolean;
  8446. /**
  8447. * Define the current target of the camera as an object or a position.
  8448. */
  8449. lockedTarget: any;
  8450. /** @hidden */
  8451. _currentTarget: Vector3;
  8452. /** @hidden */
  8453. _initialFocalDistance: number;
  8454. /** @hidden */
  8455. _viewMatrix: Matrix;
  8456. /** @hidden */
  8457. _camMatrix: Matrix;
  8458. /** @hidden */
  8459. _cameraTransformMatrix: Matrix;
  8460. /** @hidden */
  8461. _cameraRotationMatrix: Matrix;
  8462. /** @hidden */
  8463. _referencePoint: Vector3;
  8464. /** @hidden */
  8465. _transformedReferencePoint: Vector3;
  8466. protected _globalCurrentTarget: Vector3;
  8467. protected _globalCurrentUpVector: Vector3;
  8468. /** @hidden */
  8469. _reset: () => void;
  8470. private _defaultUp;
  8471. /**
  8472. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  8473. * This is the base of the follow, arc rotate cameras and Free camera
  8474. * @see http://doc.babylonjs.com/features/cameras
  8475. * @param name Defines the name of the camera in the scene
  8476. * @param position Defines the start position of the camera in the scene
  8477. * @param scene Defines the scene the camera belongs to
  8478. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8479. */
  8480. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8481. /**
  8482. * Gets the position in front of the camera at a given distance.
  8483. * @param distance The distance from the camera we want the position to be
  8484. * @returns the position
  8485. */
  8486. getFrontPosition(distance: number): Vector3;
  8487. /** @hidden */
  8488. _getLockedTargetPosition(): Nullable<Vector3>;
  8489. private _storedPosition;
  8490. private _storedRotation;
  8491. private _storedRotationQuaternion;
  8492. /**
  8493. * Store current camera state of the camera (fov, position, rotation, etc..)
  8494. * @returns the camera
  8495. */
  8496. storeState(): Camera;
  8497. /**
  8498. * Restored camera state. You must call storeState() first
  8499. * @returns whether it was successful or not
  8500. * @hidden
  8501. */
  8502. _restoreStateValues(): boolean;
  8503. /** @hidden */
  8504. _initCache(): void;
  8505. /** @hidden */
  8506. _updateCache(ignoreParentClass?: boolean): void;
  8507. /** @hidden */
  8508. _isSynchronizedViewMatrix(): boolean;
  8509. /** @hidden */
  8510. _computeLocalCameraSpeed(): number;
  8511. /**
  8512. * Defines the target the camera should look at.
  8513. * This will automatically adapt alpha beta and radius to fit within the new target.
  8514. * @param target Defines the new target as a Vector or a mesh
  8515. */
  8516. setTarget(target: Vector3): void;
  8517. /**
  8518. * Return the current target position of the camera. This value is expressed in local space.
  8519. * @returns the target position
  8520. */
  8521. getTarget(): Vector3;
  8522. /** @hidden */
  8523. _decideIfNeedsToMove(): boolean;
  8524. /** @hidden */
  8525. _updatePosition(): void;
  8526. /** @hidden */
  8527. _checkInputs(): void;
  8528. protected _updateCameraRotationMatrix(): void;
  8529. /**
  8530. * 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)
  8531. * @returns the current camera
  8532. */
  8533. private _rotateUpVectorWithCameraRotationMatrix;
  8534. private _cachedRotationZ;
  8535. private _cachedQuaternionRotationZ;
  8536. /** @hidden */
  8537. _getViewMatrix(): Matrix;
  8538. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8539. /**
  8540. * @hidden
  8541. */
  8542. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8543. /**
  8544. * @hidden
  8545. */
  8546. _updateRigCameras(): void;
  8547. private _getRigCamPositionAndTarget;
  8548. /**
  8549. * Gets the current object class name.
  8550. * @return the class name
  8551. */
  8552. getClassName(): string;
  8553. }
  8554. }
  8555. declare module "babylonjs/Cameras/cameraInputsManager" {
  8556. import { Nullable } from "babylonjs/types";
  8557. import { Camera } from "babylonjs/Cameras/camera";
  8558. /**
  8559. * @ignore
  8560. * This is a list of all the different input types that are available in the application.
  8561. * Fo instance: ArcRotateCameraGamepadInput...
  8562. */
  8563. export var CameraInputTypes: {};
  8564. /**
  8565. * This is the contract to implement in order to create a new input class.
  8566. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  8567. */
  8568. export interface ICameraInput<TCamera extends Camera> {
  8569. /**
  8570. * Defines the camera the input is attached to.
  8571. */
  8572. camera: Nullable<TCamera>;
  8573. /**
  8574. * Gets the class name of the current intput.
  8575. * @returns the class name
  8576. */
  8577. getClassName(): string;
  8578. /**
  8579. * Get the friendly name associated with the input class.
  8580. * @returns the input friendly name
  8581. */
  8582. getSimpleName(): string;
  8583. /**
  8584. * Attach the input controls to a specific dom element to get the input from.
  8585. * @param element Defines the element the controls should be listened from
  8586. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8587. */
  8588. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8589. /**
  8590. * Detach the current controls from the specified dom element.
  8591. * @param element Defines the element to stop listening the inputs from
  8592. */
  8593. detachControl(element: Nullable<HTMLElement>): void;
  8594. /**
  8595. * Update the current camera state depending on the inputs that have been used this frame.
  8596. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8597. */
  8598. checkInputs?: () => void;
  8599. }
  8600. /**
  8601. * Represents a map of input types to input instance or input index to input instance.
  8602. */
  8603. export interface CameraInputsMap<TCamera extends Camera> {
  8604. /**
  8605. * Accessor to the input by input type.
  8606. */
  8607. [name: string]: ICameraInput<TCamera>;
  8608. /**
  8609. * Accessor to the input by input index.
  8610. */
  8611. [idx: number]: ICameraInput<TCamera>;
  8612. }
  8613. /**
  8614. * This represents the input manager used within a camera.
  8615. * It helps dealing with all the different kind of input attached to a camera.
  8616. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8617. */
  8618. export class CameraInputsManager<TCamera extends Camera> {
  8619. /**
  8620. * Defines the list of inputs attahed to the camera.
  8621. */
  8622. attached: CameraInputsMap<TCamera>;
  8623. /**
  8624. * Defines the dom element the camera is collecting inputs from.
  8625. * This is null if the controls have not been attached.
  8626. */
  8627. attachedElement: Nullable<HTMLElement>;
  8628. /**
  8629. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8630. */
  8631. noPreventDefault: boolean;
  8632. /**
  8633. * Defined the camera the input manager belongs to.
  8634. */
  8635. camera: TCamera;
  8636. /**
  8637. * Update the current camera state depending on the inputs that have been used this frame.
  8638. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8639. */
  8640. checkInputs: () => void;
  8641. /**
  8642. * Instantiate a new Camera Input Manager.
  8643. * @param camera Defines the camera the input manager blongs to
  8644. */
  8645. constructor(camera: TCamera);
  8646. /**
  8647. * Add an input method to a camera
  8648. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8649. * @param input camera input method
  8650. */
  8651. add(input: ICameraInput<TCamera>): void;
  8652. /**
  8653. * Remove a specific input method from a camera
  8654. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  8655. * @param inputToRemove camera input method
  8656. */
  8657. remove(inputToRemove: ICameraInput<TCamera>): void;
  8658. /**
  8659. * Remove a specific input type from a camera
  8660. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  8661. * @param inputType the type of the input to remove
  8662. */
  8663. removeByType(inputType: string): void;
  8664. private _addCheckInputs;
  8665. /**
  8666. * Attach the input controls to the currently attached dom element to listen the events from.
  8667. * @param input Defines the input to attach
  8668. */
  8669. attachInput(input: ICameraInput<TCamera>): void;
  8670. /**
  8671. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  8672. * @param element Defines the dom element to collect the events from
  8673. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8674. */
  8675. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  8676. /**
  8677. * Detach the current manager inputs controls from a specific dom element.
  8678. * @param element Defines the dom element to collect the events from
  8679. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  8680. */
  8681. detachElement(element: HTMLElement, disconnect?: boolean): void;
  8682. /**
  8683. * Rebuild the dynamic inputCheck function from the current list of
  8684. * defined inputs in the manager.
  8685. */
  8686. rebuildInputCheck(): void;
  8687. /**
  8688. * Remove all attached input methods from a camera
  8689. */
  8690. clear(): void;
  8691. /**
  8692. * Serialize the current input manager attached to a camera.
  8693. * This ensures than once parsed,
  8694. * the input associated to the camera will be identical to the current ones
  8695. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  8696. */
  8697. serialize(serializedCamera: any): void;
  8698. /**
  8699. * Parses an input manager serialized JSON to restore the previous list of inputs
  8700. * and states associated to a camera.
  8701. * @param parsedCamera Defines the JSON to parse
  8702. */
  8703. parse(parsedCamera: any): void;
  8704. }
  8705. }
  8706. declare module "babylonjs/Events/keyboardEvents" {
  8707. /**
  8708. * Gather the list of keyboard event types as constants.
  8709. */
  8710. export class KeyboardEventTypes {
  8711. /**
  8712. * The keydown event is fired when a key becomes active (pressed).
  8713. */
  8714. static readonly KEYDOWN: number;
  8715. /**
  8716. * The keyup event is fired when a key has been released.
  8717. */
  8718. static readonly KEYUP: number;
  8719. }
  8720. /**
  8721. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8722. */
  8723. export class KeyboardInfo {
  8724. /**
  8725. * Defines the type of event (KeyboardEventTypes)
  8726. */
  8727. type: number;
  8728. /**
  8729. * Defines the related dom event
  8730. */
  8731. event: KeyboardEvent;
  8732. /**
  8733. * Instantiates a new keyboard info.
  8734. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8735. * @param type Defines the type of event (KeyboardEventTypes)
  8736. * @param event Defines the related dom event
  8737. */
  8738. constructor(
  8739. /**
  8740. * Defines the type of event (KeyboardEventTypes)
  8741. */
  8742. type: number,
  8743. /**
  8744. * Defines the related dom event
  8745. */
  8746. event: KeyboardEvent);
  8747. }
  8748. /**
  8749. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8750. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8751. */
  8752. export class KeyboardInfoPre extends KeyboardInfo {
  8753. /**
  8754. * Defines the type of event (KeyboardEventTypes)
  8755. */
  8756. type: number;
  8757. /**
  8758. * Defines the related dom event
  8759. */
  8760. event: KeyboardEvent;
  8761. /**
  8762. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8763. */
  8764. skipOnPointerObservable: boolean;
  8765. /**
  8766. * Instantiates a new keyboard pre info.
  8767. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8768. * @param type Defines the type of event (KeyboardEventTypes)
  8769. * @param event Defines the related dom event
  8770. */
  8771. constructor(
  8772. /**
  8773. * Defines the type of event (KeyboardEventTypes)
  8774. */
  8775. type: number,
  8776. /**
  8777. * Defines the related dom event
  8778. */
  8779. event: KeyboardEvent);
  8780. }
  8781. }
  8782. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  8783. import { Nullable } from "babylonjs/types";
  8784. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  8785. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8786. /**
  8787. * Manage the keyboard inputs to control the movement of a free camera.
  8788. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8789. */
  8790. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8791. /**
  8792. * Defines the camera the input is attached to.
  8793. */
  8794. camera: FreeCamera;
  8795. /**
  8796. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8797. */
  8798. keysUp: number[];
  8799. /**
  8800. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8801. */
  8802. keysDown: number[];
  8803. /**
  8804. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8805. */
  8806. keysLeft: number[];
  8807. /**
  8808. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8809. */
  8810. keysRight: number[];
  8811. private _keys;
  8812. private _onCanvasBlurObserver;
  8813. private _onKeyboardObserver;
  8814. private _engine;
  8815. private _scene;
  8816. /**
  8817. * Attach the input controls to a specific dom element to get the input from.
  8818. * @param element Defines the element the controls should be listened from
  8819. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8820. */
  8821. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8822. /**
  8823. * Detach the current controls from the specified dom element.
  8824. * @param element Defines the element to stop listening the inputs from
  8825. */
  8826. detachControl(element: Nullable<HTMLElement>): void;
  8827. /**
  8828. * Update the current camera state depending on the inputs that have been used this frame.
  8829. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8830. */
  8831. checkInputs(): void;
  8832. /**
  8833. * Gets the class name of the current intput.
  8834. * @returns the class name
  8835. */
  8836. getClassName(): string;
  8837. /** @hidden */
  8838. _onLostFocus(): void;
  8839. /**
  8840. * Get the friendly name associated with the input class.
  8841. * @returns the input friendly name
  8842. */
  8843. getSimpleName(): string;
  8844. }
  8845. }
  8846. declare module "babylonjs/Lights/shadowLight" {
  8847. import { Camera } from "babylonjs/Cameras/camera";
  8848. import { Scene } from "babylonjs/scene";
  8849. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  8850. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8851. import { Light } from "babylonjs/Lights/light";
  8852. /**
  8853. * Interface describing all the common properties and methods a shadow light needs to implement.
  8854. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8855. * as well as binding the different shadow properties to the effects.
  8856. */
  8857. export interface IShadowLight extends Light {
  8858. /**
  8859. * The light id in the scene (used in scene.findLighById for instance)
  8860. */
  8861. id: string;
  8862. /**
  8863. * The position the shdow will be casted from.
  8864. */
  8865. position: Vector3;
  8866. /**
  8867. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8868. */
  8869. direction: Vector3;
  8870. /**
  8871. * The transformed position. Position of the light in world space taking parenting in account.
  8872. */
  8873. transformedPosition: Vector3;
  8874. /**
  8875. * The transformed direction. Direction of the light in world space taking parenting in account.
  8876. */
  8877. transformedDirection: Vector3;
  8878. /**
  8879. * The friendly name of the light in the scene.
  8880. */
  8881. name: string;
  8882. /**
  8883. * Defines the shadow projection clipping minimum z value.
  8884. */
  8885. shadowMinZ: number;
  8886. /**
  8887. * Defines the shadow projection clipping maximum z value.
  8888. */
  8889. shadowMaxZ: number;
  8890. /**
  8891. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8892. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8893. */
  8894. computeTransformedInformation(): boolean;
  8895. /**
  8896. * Gets the scene the light belongs to.
  8897. * @returns The scene
  8898. */
  8899. getScene(): Scene;
  8900. /**
  8901. * Callback defining a custom Projection Matrix Builder.
  8902. * This can be used to override the default projection matrix computation.
  8903. */
  8904. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8905. /**
  8906. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8907. * @param matrix The materix to updated with the projection information
  8908. * @param viewMatrix The transform matrix of the light
  8909. * @param renderList The list of mesh to render in the map
  8910. * @returns The current light
  8911. */
  8912. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8913. /**
  8914. * Gets the current depth scale used in ESM.
  8915. * @returns The scale
  8916. */
  8917. getDepthScale(): number;
  8918. /**
  8919. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8920. * @returns true if a cube texture needs to be use
  8921. */
  8922. needCube(): boolean;
  8923. /**
  8924. * Detects if the projection matrix requires to be recomputed this frame.
  8925. * @returns true if it requires to be recomputed otherwise, false.
  8926. */
  8927. needProjectionMatrixCompute(): boolean;
  8928. /**
  8929. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8930. */
  8931. forceProjectionMatrixCompute(): void;
  8932. /**
  8933. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8934. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8935. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8936. */
  8937. getShadowDirection(faceIndex?: number): Vector3;
  8938. /**
  8939. * Gets the minZ used for shadow according to both the scene and the light.
  8940. * @param activeCamera The camera we are returning the min for
  8941. * @returns the depth min z
  8942. */
  8943. getDepthMinZ(activeCamera: Camera): number;
  8944. /**
  8945. * Gets the maxZ used for shadow according to both the scene and the light.
  8946. * @param activeCamera The camera we are returning the max for
  8947. * @returns the depth max z
  8948. */
  8949. getDepthMaxZ(activeCamera: Camera): number;
  8950. }
  8951. /**
  8952. * Base implementation IShadowLight
  8953. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8954. */
  8955. export abstract class ShadowLight extends Light implements IShadowLight {
  8956. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8957. protected _position: Vector3;
  8958. protected _setPosition(value: Vector3): void;
  8959. /**
  8960. * Sets the position the shadow will be casted from. Also use as the light position for both
  8961. * point and spot lights.
  8962. */
  8963. /**
  8964. * Sets the position the shadow will be casted from. Also use as the light position for both
  8965. * point and spot lights.
  8966. */
  8967. position: Vector3;
  8968. protected _direction: Vector3;
  8969. protected _setDirection(value: Vector3): void;
  8970. /**
  8971. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8972. * Also use as the light direction on spot and directional lights.
  8973. */
  8974. /**
  8975. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8976. * Also use as the light direction on spot and directional lights.
  8977. */
  8978. direction: Vector3;
  8979. private _shadowMinZ;
  8980. /**
  8981. * Gets the shadow projection clipping minimum z value.
  8982. */
  8983. /**
  8984. * Sets the shadow projection clipping minimum z value.
  8985. */
  8986. shadowMinZ: number;
  8987. private _shadowMaxZ;
  8988. /**
  8989. * Sets the shadow projection clipping maximum z value.
  8990. */
  8991. /**
  8992. * Gets the shadow projection clipping maximum z value.
  8993. */
  8994. shadowMaxZ: number;
  8995. /**
  8996. * Callback defining a custom Projection Matrix Builder.
  8997. * This can be used to override the default projection matrix computation.
  8998. */
  8999. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9000. /**
  9001. * The transformed position. Position of the light in world space taking parenting in account.
  9002. */
  9003. transformedPosition: Vector3;
  9004. /**
  9005. * The transformed direction. Direction of the light in world space taking parenting in account.
  9006. */
  9007. transformedDirection: Vector3;
  9008. private _needProjectionMatrixCompute;
  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. * Return the depth scale used for the shadow map.
  9016. * @returns the depth scale.
  9017. */
  9018. getDepthScale(): number;
  9019. /**
  9020. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9021. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9022. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9023. */
  9024. getShadowDirection(faceIndex?: number): Vector3;
  9025. /**
  9026. * Returns the ShadowLight absolute position in the World.
  9027. * @returns the position vector in world space
  9028. */
  9029. getAbsolutePosition(): Vector3;
  9030. /**
  9031. * Sets the ShadowLight direction toward the passed target.
  9032. * @param target The point to target in local space
  9033. * @returns the updated ShadowLight direction
  9034. */
  9035. setDirectionToTarget(target: Vector3): Vector3;
  9036. /**
  9037. * Returns the light rotation in euler definition.
  9038. * @returns the x y z rotation in local space.
  9039. */
  9040. getRotation(): Vector3;
  9041. /**
  9042. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9043. * @returns true if a cube texture needs to be use
  9044. */
  9045. needCube(): boolean;
  9046. /**
  9047. * Detects if the projection matrix requires to be recomputed this frame.
  9048. * @returns true if it requires to be recomputed otherwise, false.
  9049. */
  9050. needProjectionMatrixCompute(): boolean;
  9051. /**
  9052. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9053. */
  9054. forceProjectionMatrixCompute(): void;
  9055. /** @hidden */
  9056. _initCache(): void;
  9057. /** @hidden */
  9058. _isSynchronized(): boolean;
  9059. /**
  9060. * Computes the world matrix of the node
  9061. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9062. * @returns the world matrix
  9063. */
  9064. computeWorldMatrix(force?: boolean): Matrix;
  9065. /**
  9066. * Gets the minZ used for shadow according to both the scene and the light.
  9067. * @param activeCamera The camera we are returning the min for
  9068. * @returns the depth min z
  9069. */
  9070. getDepthMinZ(activeCamera: Camera): number;
  9071. /**
  9072. * Gets the maxZ used for shadow according to both the scene and the light.
  9073. * @param activeCamera The camera we are returning the max for
  9074. * @returns the depth max z
  9075. */
  9076. getDepthMaxZ(activeCamera: Camera): number;
  9077. /**
  9078. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9079. * @param matrix The materix to updated with the projection information
  9080. * @param viewMatrix The transform matrix of the light
  9081. * @param renderList The list of mesh to render in the map
  9082. * @returns The current light
  9083. */
  9084. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9085. }
  9086. }
  9087. declare module "babylonjs/Materials/materialHelper" {
  9088. import { Nullable } from "babylonjs/types";
  9089. import { Scene } from "babylonjs/scene";
  9090. import { Engine } from "babylonjs/Engines/engine";
  9091. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9092. import { Light } from "babylonjs/Lights/light";
  9093. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9094. import { Effect, EffectFallbacks, EffectCreationOptions } from "babylonjs/Materials/effect";
  9095. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  9096. /**
  9097. * "Static Class" containing the most commonly used helper while dealing with material for
  9098. * rendering purpose.
  9099. *
  9100. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9101. *
  9102. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9103. */
  9104. export class MaterialHelper {
  9105. /**
  9106. * Bind the current view position to an effect.
  9107. * @param effect The effect to be bound
  9108. * @param scene The scene the eyes position is used from
  9109. */
  9110. static BindEyePosition(effect: Effect, scene: Scene): void;
  9111. /**
  9112. * Helps preparing the defines values about the UVs in used in the effect.
  9113. * UVs are shared as much as we can accross channels in the shaders.
  9114. * @param texture The texture we are preparing the UVs for
  9115. * @param defines The defines to update
  9116. * @param key The channel key "diffuse", "specular"... used in the shader
  9117. */
  9118. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9119. /**
  9120. * Binds a texture matrix value to its corrsponding uniform
  9121. * @param texture The texture to bind the matrix for
  9122. * @param uniformBuffer The uniform buffer receivin the data
  9123. * @param key The channel key "diffuse", "specular"... used in the shader
  9124. */
  9125. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9126. /**
  9127. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9128. * @param mesh defines the current mesh
  9129. * @param scene defines the current scene
  9130. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9131. * @param pointsCloud defines if point cloud rendering has to be turned on
  9132. * @param fogEnabled defines if fog has to be turned on
  9133. * @param alphaTest defines if alpha testing has to be turned on
  9134. * @param defines defines the current list of defines
  9135. */
  9136. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9137. /**
  9138. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9139. * @param scene defines the current scene
  9140. * @param engine defines the current engine
  9141. * @param defines specifies the list of active defines
  9142. * @param useInstances defines if instances have to be turned on
  9143. * @param useClipPlane defines if clip plane have to be turned on
  9144. */
  9145. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9146. /**
  9147. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9148. * @param mesh The mesh containing the geometry data we will draw
  9149. * @param defines The defines to update
  9150. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9151. * @param useBones Precise whether bones should be used or not (override mesh info)
  9152. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9153. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9154. * @returns false if defines are considered not dirty and have not been checked
  9155. */
  9156. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9157. /**
  9158. * Prepares the defines related to the light information passed in parameter
  9159. * @param scene The scene we are intending to draw
  9160. * @param mesh The mesh the effect is compiling for
  9161. * @param defines The defines to update
  9162. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9163. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9164. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9165. * @returns true if normals will be required for the rest of the effect
  9166. */
  9167. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9168. /**
  9169. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  9170. * that won t be acctive due to defines being turned off.
  9171. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9172. * @param samplersList The samplers list
  9173. * @param defines The defines helping in the list generation
  9174. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9175. */
  9176. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9177. /**
  9178. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9179. * @param defines The defines to update while falling back
  9180. * @param fallbacks The authorized effect fallbacks
  9181. * @param maxSimultaneousLights The maximum number of lights allowed
  9182. * @param rank the current rank of the Effect
  9183. * @returns The newly affected rank
  9184. */
  9185. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9186. /**
  9187. * Prepares the list of attributes required for morph targets according to the effect defines.
  9188. * @param attribs The current list of supported attribs
  9189. * @param mesh The mesh to prepare the morph targets attributes for
  9190. * @param defines The current Defines of the effect
  9191. */
  9192. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9193. /**
  9194. * Prepares the list of attributes required for bones according to the effect defines.
  9195. * @param attribs The current list of supported attribs
  9196. * @param mesh The mesh to prepare the bones attributes for
  9197. * @param defines The current Defines of the effect
  9198. * @param fallbacks The current efffect fallback strategy
  9199. */
  9200. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9201. /**
  9202. * Prepares the list of attributes required for instances according to the effect defines.
  9203. * @param attribs The current list of supported attribs
  9204. * @param defines The current Defines of the effect
  9205. */
  9206. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  9207. /**
  9208. * Binds the light shadow information to the effect for the given mesh.
  9209. * @param light The light containing the generator
  9210. * @param scene The scene the lights belongs to
  9211. * @param mesh The mesh we are binding the information to render
  9212. * @param lightIndex The light index in the effect used to render the mesh
  9213. * @param effect The effect we are binding the data to
  9214. */
  9215. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  9216. /**
  9217. * Binds the light information to the effect.
  9218. * @param light The light containing the generator
  9219. * @param effect The effect we are binding the data to
  9220. * @param lightIndex The light index in the effect used to render
  9221. */
  9222. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9223. /**
  9224. * Binds the lights information from the scene to the effect for the given mesh.
  9225. * @param scene The scene the lights belongs to
  9226. * @param mesh The mesh we are binding the information to render
  9227. * @param effect The effect we are binding the data to
  9228. * @param defines The generated defines for the effect
  9229. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9230. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9231. */
  9232. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  9233. private static _tempFogColor;
  9234. /**
  9235. * Binds the fog information from the scene to the effect for the given mesh.
  9236. * @param scene The scene the lights belongs to
  9237. * @param mesh The mesh we are binding the information to render
  9238. * @param effect The effect we are binding the data to
  9239. * @param linearSpace Defines if the fog effect is applied in linear space
  9240. */
  9241. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9242. /**
  9243. * Binds the bones information from the mesh to the effect.
  9244. * @param mesh The mesh we are binding the information to render
  9245. * @param effect The effect we are binding the data to
  9246. */
  9247. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9248. /**
  9249. * Binds the morph targets information from the mesh to the effect.
  9250. * @param abstractMesh The mesh we are binding the information to render
  9251. * @param effect The effect we are binding the data to
  9252. */
  9253. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9254. /**
  9255. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9256. * @param defines The generated defines used in the effect
  9257. * @param effect The effect we are binding the data to
  9258. * @param scene The scene we are willing to render with logarithmic scale for
  9259. */
  9260. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9261. /**
  9262. * Binds the clip plane information from the scene to the effect.
  9263. * @param scene The scene the clip plane information are extracted from
  9264. * @param effect The effect we are binding the data to
  9265. */
  9266. static BindClipPlane(effect: Effect, scene: Scene): void;
  9267. }
  9268. }
  9269. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  9270. /** @hidden */
  9271. export var kernelBlurVaryingDeclaration: {
  9272. name: string;
  9273. shader: string;
  9274. };
  9275. }
  9276. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  9277. /** @hidden */
  9278. export var kernelBlurFragment: {
  9279. name: string;
  9280. shader: string;
  9281. };
  9282. }
  9283. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  9284. /** @hidden */
  9285. export var kernelBlurFragment2: {
  9286. name: string;
  9287. shader: string;
  9288. };
  9289. }
  9290. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  9291. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  9292. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  9293. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  9294. /** @hidden */
  9295. export var kernelBlurPixelShader: {
  9296. name: string;
  9297. shader: string;
  9298. };
  9299. }
  9300. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  9301. /** @hidden */
  9302. export var kernelBlurVertex: {
  9303. name: string;
  9304. shader: string;
  9305. };
  9306. }
  9307. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  9308. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  9309. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  9310. /** @hidden */
  9311. export var kernelBlurVertexShader: {
  9312. name: string;
  9313. shader: string;
  9314. };
  9315. }
  9316. declare module "babylonjs/PostProcesses/blurPostProcess" {
  9317. import { Vector2 } from "babylonjs/Maths/math";
  9318. import { Nullable } from "babylonjs/types";
  9319. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  9320. import { Camera } from "babylonjs/Cameras/camera";
  9321. import { Effect } from "babylonjs/Materials/effect";
  9322. import { Engine } from "babylonjs/Engines/engine";
  9323. import "babylonjs/Shaders/kernelBlur.fragment";
  9324. import "babylonjs/Shaders/kernelBlur.vertex";
  9325. /**
  9326. * The Blur Post Process which blurs an image based on a kernel and direction.
  9327. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  9328. */
  9329. export class BlurPostProcess extends PostProcess {
  9330. /** The direction in which to blur the image. */
  9331. direction: Vector2;
  9332. private blockCompilation;
  9333. protected _kernel: number;
  9334. protected _idealKernel: number;
  9335. protected _packedFloat: boolean;
  9336. private _staticDefines;
  9337. /**
  9338. * Sets the length in pixels of the blur sample region
  9339. */
  9340. /**
  9341. * Gets the length in pixels of the blur sample region
  9342. */
  9343. kernel: number;
  9344. /**
  9345. * Sets wether or not the blur needs to unpack/repack floats
  9346. */
  9347. /**
  9348. * Gets wether or not the blur is unpacking/repacking floats
  9349. */
  9350. packedFloat: boolean;
  9351. /**
  9352. * Creates a new instance BlurPostProcess
  9353. * @param name The name of the effect.
  9354. * @param direction The direction in which to blur the image.
  9355. * @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.
  9356. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  9357. * @param camera The camera to apply the render pass to.
  9358. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  9359. * @param engine The engine which the post process will be applied. (default: current engine)
  9360. * @param reusable If the post process can be reused on the same frame. (default: false)
  9361. * @param textureType Type of textures used when performing the post process. (default: 0)
  9362. * @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)
  9363. */
  9364. constructor(name: string,
  9365. /** The direction in which to blur the image. */
  9366. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  9367. /**
  9368. * Updates the effect with the current post process compile time values and recompiles the shader.
  9369. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  9370. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  9371. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  9372. * @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
  9373. * @param onCompiled Called when the shader has been compiled.
  9374. * @param onError Called if there is an error when compiling a shader.
  9375. */
  9376. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  9377. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  9378. /**
  9379. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  9380. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  9381. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  9382. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  9383. * The gaps between physical kernels are compensated for in the weighting of the samples
  9384. * @param idealKernel Ideal blur kernel.
  9385. * @return Nearest best kernel.
  9386. */
  9387. protected _nearestBestKernel(idealKernel: number): number;
  9388. /**
  9389. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  9390. * @param x The point on the Gaussian distribution to sample.
  9391. * @return the value of the Gaussian function at x.
  9392. */
  9393. protected _gaussianWeight(x: number): number;
  9394. /**
  9395. * Generates a string that can be used as a floating point number in GLSL.
  9396. * @param x Value to print.
  9397. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  9398. * @return GLSL float string.
  9399. */
  9400. protected _glslFloat(x: number, decimalFigures?: number): string;
  9401. }
  9402. }
  9403. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9404. /** @hidden */
  9405. export var shadowMapPixelShader: {
  9406. name: string;
  9407. shader: string;
  9408. };
  9409. }
  9410. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9411. /** @hidden */
  9412. export var bonesDeclaration: {
  9413. name: string;
  9414. shader: string;
  9415. };
  9416. }
  9417. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9418. /** @hidden */
  9419. export var morphTargetsVertexGlobalDeclaration: {
  9420. name: string;
  9421. shader: string;
  9422. };
  9423. }
  9424. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9425. /** @hidden */
  9426. export var morphTargetsVertexDeclaration: {
  9427. name: string;
  9428. shader: string;
  9429. };
  9430. }
  9431. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9432. /** @hidden */
  9433. export var instancesDeclaration: {
  9434. name: string;
  9435. shader: string;
  9436. };
  9437. }
  9438. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9439. /** @hidden */
  9440. export var helperFunctions: {
  9441. name: string;
  9442. shader: string;
  9443. };
  9444. }
  9445. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9446. /** @hidden */
  9447. export var morphTargetsVertex: {
  9448. name: string;
  9449. shader: string;
  9450. };
  9451. }
  9452. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9453. /** @hidden */
  9454. export var instancesVertex: {
  9455. name: string;
  9456. shader: string;
  9457. };
  9458. }
  9459. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9460. /** @hidden */
  9461. export var bonesVertex: {
  9462. name: string;
  9463. shader: string;
  9464. };
  9465. }
  9466. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9467. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9468. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9469. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9470. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9471. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9472. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9473. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9474. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9475. /** @hidden */
  9476. export var shadowMapVertexShader: {
  9477. name: string;
  9478. shader: string;
  9479. };
  9480. }
  9481. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9482. /** @hidden */
  9483. export var depthBoxBlurPixelShader: {
  9484. name: string;
  9485. shader: string;
  9486. };
  9487. }
  9488. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  9489. import { Nullable } from "babylonjs/types";
  9490. import { Scene } from "babylonjs/scene";
  9491. import { Matrix } from "babylonjs/Maths/math";
  9492. import { SubMesh } from "babylonjs/Meshes/subMesh";
  9493. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9494. import { Mesh } from "babylonjs/Meshes/mesh";
  9495. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  9496. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9497. import { Effect } from "babylonjs/Materials/effect";
  9498. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  9499. import "babylonjs/Shaders/shadowMap.fragment";
  9500. import "babylonjs/Shaders/shadowMap.vertex";
  9501. import "babylonjs/Shaders/depthBoxBlur.fragment";
  9502. import { Observable } from "babylonjs/Misc/observable";
  9503. /**
  9504. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9505. */
  9506. export interface ICustomShaderOptions {
  9507. /**
  9508. * Gets or sets the custom shader name to use
  9509. */
  9510. shaderName: string;
  9511. /**
  9512. * The list of attribute names used in the shader
  9513. */
  9514. attributes?: string[];
  9515. /**
  9516. * The list of unifrom names used in the shader
  9517. */
  9518. uniforms?: string[];
  9519. /**
  9520. * The list of sampler names used in the shader
  9521. */
  9522. samplers?: string[];
  9523. /**
  9524. * The list of defines used in the shader
  9525. */
  9526. defines?: string[];
  9527. }
  9528. /**
  9529. * Interface to implement to create a shadow generator compatible with BJS.
  9530. */
  9531. export interface IShadowGenerator {
  9532. /**
  9533. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9534. * @returns The render target texture if present otherwise, null
  9535. */
  9536. getShadowMap(): Nullable<RenderTargetTexture>;
  9537. /**
  9538. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9539. * @returns The render target texture if the shadow map is present otherwise, null
  9540. */
  9541. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9542. /**
  9543. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9544. * @param subMesh The submesh we want to render in the shadow map
  9545. * @param useInstances Defines wether will draw in the map using instances
  9546. * @returns true if ready otherwise, false
  9547. */
  9548. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9549. /**
  9550. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9551. * @param defines Defines of the material we want to update
  9552. * @param lightIndex Index of the light in the enabled light list of the material
  9553. */
  9554. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9555. /**
  9556. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9557. * defined in the generator but impacting the effect).
  9558. * It implies the unifroms available on the materials are the standard BJS ones.
  9559. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9560. * @param effect The effect we are binfing the information for
  9561. */
  9562. bindShadowLight(lightIndex: string, effect: Effect): void;
  9563. /**
  9564. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9565. * (eq to shadow prjection matrix * light transform matrix)
  9566. * @returns The transform matrix used to create the shadow map
  9567. */
  9568. getTransformMatrix(): Matrix;
  9569. /**
  9570. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9571. * Cube and 2D textures for instance.
  9572. */
  9573. recreateShadowMap(): void;
  9574. /**
  9575. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9576. * @param onCompiled Callback triggered at the and of the effects compilation
  9577. * @param options Sets of optional options forcing the compilation with different modes
  9578. */
  9579. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9580. useInstances: boolean;
  9581. }>): void;
  9582. /**
  9583. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9584. * @param options Sets of optional options forcing the compilation with different modes
  9585. * @returns A promise that resolves when the compilation completes
  9586. */
  9587. forceCompilationAsync(options?: Partial<{
  9588. useInstances: boolean;
  9589. }>): Promise<void>;
  9590. /**
  9591. * Serializes the shadow generator setup to a json object.
  9592. * @returns The serialized JSON object
  9593. */
  9594. serialize(): any;
  9595. /**
  9596. * Disposes the Shadow map and related Textures and effects.
  9597. */
  9598. dispose(): void;
  9599. }
  9600. /**
  9601. * Default implementation IShadowGenerator.
  9602. * This is the main object responsible of generating shadows in the framework.
  9603. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9604. */
  9605. export class ShadowGenerator implements IShadowGenerator {
  9606. /**
  9607. * Shadow generator mode None: no filtering applied.
  9608. */
  9609. static readonly FILTER_NONE: number;
  9610. /**
  9611. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9612. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9613. */
  9614. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9615. /**
  9616. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9617. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9618. */
  9619. static readonly FILTER_POISSONSAMPLING: number;
  9620. /**
  9621. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9622. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9623. */
  9624. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9625. /**
  9626. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9627. * edge artifacts on steep falloff.
  9628. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9629. */
  9630. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9631. /**
  9632. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9633. * edge artifacts on steep falloff.
  9634. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9635. */
  9636. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9637. /**
  9638. * Shadow generator mode PCF: Percentage Closer Filtering
  9639. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9640. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9641. */
  9642. static readonly FILTER_PCF: number;
  9643. /**
  9644. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9645. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9646. * Contact Hardening
  9647. */
  9648. static readonly FILTER_PCSS: number;
  9649. /**
  9650. * Reserved for PCF and PCSS
  9651. * Highest Quality.
  9652. *
  9653. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9654. *
  9655. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9656. */
  9657. static readonly QUALITY_HIGH: number;
  9658. /**
  9659. * Reserved for PCF and PCSS
  9660. * Good tradeoff for quality/perf cross devices
  9661. *
  9662. * Execute PCF on a 3*3 kernel.
  9663. *
  9664. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9665. */
  9666. static readonly QUALITY_MEDIUM: number;
  9667. /**
  9668. * Reserved for PCF and PCSS
  9669. * The lowest quality but the fastest.
  9670. *
  9671. * Execute PCF on a 1*1 kernel.
  9672. *
  9673. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9674. */
  9675. static readonly QUALITY_LOW: number;
  9676. /** Gets or sets the custom shader name to use */
  9677. customShaderOptions: ICustomShaderOptions;
  9678. /**
  9679. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9680. */
  9681. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9682. /**
  9683. * Observable triggered before a mesh is rendered in the shadow map.
  9684. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9685. */
  9686. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9687. private _bias;
  9688. /**
  9689. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9690. */
  9691. /**
  9692. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9693. */
  9694. bias: number;
  9695. private _normalBias;
  9696. /**
  9697. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9698. */
  9699. /**
  9700. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9701. */
  9702. normalBias: number;
  9703. private _blurBoxOffset;
  9704. /**
  9705. * Gets the blur box offset: offset applied during the blur pass.
  9706. * Only useful if useKernelBlur = false
  9707. */
  9708. /**
  9709. * Sets the blur box offset: offset applied during the blur pass.
  9710. * Only useful if useKernelBlur = false
  9711. */
  9712. blurBoxOffset: number;
  9713. private _blurScale;
  9714. /**
  9715. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9716. * 2 means half of the size.
  9717. */
  9718. /**
  9719. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9720. * 2 means half of the size.
  9721. */
  9722. blurScale: number;
  9723. private _blurKernel;
  9724. /**
  9725. * Gets the blur kernel: kernel size of the blur pass.
  9726. * Only useful if useKernelBlur = true
  9727. */
  9728. /**
  9729. * Sets the blur kernel: kernel size of the blur pass.
  9730. * Only useful if useKernelBlur = true
  9731. */
  9732. blurKernel: number;
  9733. private _useKernelBlur;
  9734. /**
  9735. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9736. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9737. */
  9738. /**
  9739. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9740. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9741. */
  9742. useKernelBlur: boolean;
  9743. private _depthScale;
  9744. /**
  9745. * Gets the depth scale used in ESM mode.
  9746. */
  9747. /**
  9748. * Sets the depth scale used in ESM mode.
  9749. * This can override the scale stored on the light.
  9750. */
  9751. depthScale: number;
  9752. private _filter;
  9753. /**
  9754. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9755. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9756. */
  9757. /**
  9758. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9759. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9760. */
  9761. filter: number;
  9762. /**
  9763. * Gets if the current filter is set to Poisson Sampling.
  9764. */
  9765. /**
  9766. * Sets the current filter to Poisson Sampling.
  9767. */
  9768. usePoissonSampling: boolean;
  9769. /**
  9770. * Gets if the current filter is set to ESM.
  9771. */
  9772. /**
  9773. * Sets the current filter is to ESM.
  9774. */
  9775. useExponentialShadowMap: boolean;
  9776. /**
  9777. * Gets if the current filter is set to filtered ESM.
  9778. */
  9779. /**
  9780. * Gets if the current filter is set to filtered ESM.
  9781. */
  9782. useBlurExponentialShadowMap: boolean;
  9783. /**
  9784. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9785. * exponential to prevent steep falloff artifacts).
  9786. */
  9787. /**
  9788. * Sets the current filter to "close ESM" (using the inverse of the
  9789. * exponential to prevent steep falloff artifacts).
  9790. */
  9791. useCloseExponentialShadowMap: boolean;
  9792. /**
  9793. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9794. * exponential to prevent steep falloff artifacts).
  9795. */
  9796. /**
  9797. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9798. * exponential to prevent steep falloff artifacts).
  9799. */
  9800. useBlurCloseExponentialShadowMap: boolean;
  9801. /**
  9802. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9803. */
  9804. /**
  9805. * Sets the current filter to "PCF" (percentage closer filtering).
  9806. */
  9807. usePercentageCloserFiltering: boolean;
  9808. private _filteringQuality;
  9809. /**
  9810. * Gets the PCF or PCSS Quality.
  9811. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9812. */
  9813. /**
  9814. * Sets the PCF or PCSS Quality.
  9815. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9816. */
  9817. filteringQuality: number;
  9818. /**
  9819. * Gets if the current filter is set to "PCSS" (contact hardening).
  9820. */
  9821. /**
  9822. * Sets the current filter to "PCSS" (contact hardening).
  9823. */
  9824. useContactHardeningShadow: boolean;
  9825. private _contactHardeningLightSizeUVRatio;
  9826. /**
  9827. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9828. * Using a ratio helps keeping shape stability independently of the map size.
  9829. *
  9830. * It does not account for the light projection as it was having too much
  9831. * instability during the light setup or during light position changes.
  9832. *
  9833. * Only valid if useContactHardeningShadow is true.
  9834. */
  9835. /**
  9836. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9837. * Using a ratio helps keeping shape stability independently of the map size.
  9838. *
  9839. * It does not account for the light projection as it was having too much
  9840. * instability during the light setup or during light position changes.
  9841. *
  9842. * Only valid if useContactHardeningShadow is true.
  9843. */
  9844. contactHardeningLightSizeUVRatio: number;
  9845. private _darkness;
  9846. /**
  9847. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9848. * 0 means strongest and 1 would means no shadow.
  9849. * @returns the darkness.
  9850. */
  9851. getDarkness(): number;
  9852. /**
  9853. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9854. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9855. * @returns the shadow generator allowing fluent coding.
  9856. */
  9857. setDarkness(darkness: number): ShadowGenerator;
  9858. private _transparencyShadow;
  9859. /**
  9860. * Sets the ability to have transparent shadow (boolean).
  9861. * @param transparent True if transparent else False
  9862. * @returns the shadow generator allowing fluent coding
  9863. */
  9864. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9865. private _shadowMap;
  9866. private _shadowMap2;
  9867. /**
  9868. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9869. * @returns The render target texture if present otherwise, null
  9870. */
  9871. getShadowMap(): Nullable<RenderTargetTexture>;
  9872. /**
  9873. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9874. * @returns The render target texture if the shadow map is present otherwise, null
  9875. */
  9876. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9877. /**
  9878. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9879. * @param mesh Mesh to add
  9880. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9881. * @returns the Shadow Generator itself
  9882. */
  9883. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9884. /**
  9885. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9886. * @param mesh Mesh to remove
  9887. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9888. * @returns the Shadow Generator itself
  9889. */
  9890. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9891. /**
  9892. * Controls the extent to which the shadows fade out at the edge of the frustum
  9893. * Used only by directionals and spots
  9894. */
  9895. frustumEdgeFalloff: number;
  9896. private _light;
  9897. /**
  9898. * Returns the associated light object.
  9899. * @returns the light generating the shadow
  9900. */
  9901. getLight(): IShadowLight;
  9902. /**
  9903. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9904. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9905. * It might on the other hand introduce peter panning.
  9906. */
  9907. forceBackFacesOnly: boolean;
  9908. private _scene;
  9909. private _lightDirection;
  9910. private _effect;
  9911. private _viewMatrix;
  9912. private _projectionMatrix;
  9913. private _transformMatrix;
  9914. private _cachedPosition;
  9915. private _cachedDirection;
  9916. private _cachedDefines;
  9917. private _currentRenderID;
  9918. private _boxBlurPostprocess;
  9919. private _kernelBlurXPostprocess;
  9920. private _kernelBlurYPostprocess;
  9921. private _blurPostProcesses;
  9922. private _mapSize;
  9923. private _currentFaceIndex;
  9924. private _currentFaceIndexCache;
  9925. private _textureType;
  9926. private _defaultTextureMatrix;
  9927. /** @hidden */
  9928. static _SceneComponentInitialization: (scene: Scene) => void;
  9929. /**
  9930. * Creates a ShadowGenerator object.
  9931. * A ShadowGenerator is the required tool to use the shadows.
  9932. * Each light casting shadows needs to use its own ShadowGenerator.
  9933. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9934. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9935. * @param light The light object generating the shadows.
  9936. * @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.
  9937. */
  9938. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9939. private _initializeGenerator;
  9940. private _initializeShadowMap;
  9941. private _initializeBlurRTTAndPostProcesses;
  9942. private _renderForShadowMap;
  9943. private _renderSubMeshForShadowMap;
  9944. private _applyFilterValues;
  9945. /**
  9946. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9947. * @param onCompiled Callback triggered at the and of the effects compilation
  9948. * @param options Sets of optional options forcing the compilation with different modes
  9949. */
  9950. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9951. useInstances: boolean;
  9952. }>): void;
  9953. /**
  9954. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9955. * @param options Sets of optional options forcing the compilation with different modes
  9956. * @returns A promise that resolves when the compilation completes
  9957. */
  9958. forceCompilationAsync(options?: Partial<{
  9959. useInstances: boolean;
  9960. }>): Promise<void>;
  9961. /**
  9962. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9963. * @param subMesh The submesh we want to render in the shadow map
  9964. * @param useInstances Defines wether will draw in the map using instances
  9965. * @returns true if ready otherwise, false
  9966. */
  9967. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9968. /**
  9969. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9970. * @param defines Defines of the material we want to update
  9971. * @param lightIndex Index of the light in the enabled light list of the material
  9972. */
  9973. prepareDefines(defines: any, lightIndex: number): void;
  9974. /**
  9975. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9976. * defined in the generator but impacting the effect).
  9977. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9978. * @param effect The effect we are binfing the information for
  9979. */
  9980. bindShadowLight(lightIndex: string, effect: Effect): void;
  9981. /**
  9982. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9983. * (eq to shadow prjection matrix * light transform matrix)
  9984. * @returns The transform matrix used to create the shadow map
  9985. */
  9986. getTransformMatrix(): Matrix;
  9987. /**
  9988. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9989. * Cube and 2D textures for instance.
  9990. */
  9991. recreateShadowMap(): void;
  9992. private _disposeBlurPostProcesses;
  9993. private _disposeRTTandPostProcesses;
  9994. /**
  9995. * Disposes the ShadowGenerator.
  9996. * Returns nothing.
  9997. */
  9998. dispose(): void;
  9999. /**
  10000. * Serializes the shadow generator setup to a json object.
  10001. * @returns The serialized JSON object
  10002. */
  10003. serialize(): any;
  10004. /**
  10005. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  10006. * @param parsedShadowGenerator The JSON object to parse
  10007. * @param scene The scene to create the shadow map for
  10008. * @returns The parsed shadow generator
  10009. */
  10010. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  10011. }
  10012. }
  10013. declare module "babylonjs/Lights/light" {
  10014. import { Nullable } from "babylonjs/types";
  10015. import { Scene } from "babylonjs/scene";
  10016. import { Vector3, Color3 } from "babylonjs/Maths/math";
  10017. import { Node } from "babylonjs/node";
  10018. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10019. import { Effect } from "babylonjs/Materials/effect";
  10020. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  10021. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  10022. /**
  10023. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  10024. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  10025. * 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.
  10026. */
  10027. export abstract class Light extends Node {
  10028. /**
  10029. * Falloff Default: light is falling off following the material specification:
  10030. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  10031. */
  10032. static readonly FALLOFF_DEFAULT: number;
  10033. /**
  10034. * Falloff Physical: light is falling off following the inverse squared distance law.
  10035. */
  10036. static readonly FALLOFF_PHYSICAL: number;
  10037. /**
  10038. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  10039. * to enhance interoperability with other engines.
  10040. */
  10041. static readonly FALLOFF_GLTF: number;
  10042. /**
  10043. * Falloff Standard: light is falling off like in the standard material
  10044. * to enhance interoperability with other materials.
  10045. */
  10046. static readonly FALLOFF_STANDARD: number;
  10047. /**
  10048. * If every light affecting the material is in this lightmapMode,
  10049. * material.lightmapTexture adds or multiplies
  10050. * (depends on material.useLightmapAsShadowmap)
  10051. * after every other light calculations.
  10052. */
  10053. static readonly LIGHTMAP_DEFAULT: number;
  10054. /**
  10055. * material.lightmapTexture as only diffuse lighting from this light
  10056. * adds only specular lighting from this light
  10057. * adds dynamic shadows
  10058. */
  10059. static readonly LIGHTMAP_SPECULAR: number;
  10060. /**
  10061. * material.lightmapTexture as only lighting
  10062. * no light calculation from this light
  10063. * only adds dynamic shadows from this light
  10064. */
  10065. static readonly LIGHTMAP_SHADOWSONLY: number;
  10066. /**
  10067. * Each light type uses the default quantity according to its type:
  10068. * point/spot lights use luminous intensity
  10069. * directional lights use illuminance
  10070. */
  10071. static readonly INTENSITYMODE_AUTOMATIC: number;
  10072. /**
  10073. * lumen (lm)
  10074. */
  10075. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  10076. /**
  10077. * candela (lm/sr)
  10078. */
  10079. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  10080. /**
  10081. * lux (lm/m^2)
  10082. */
  10083. static readonly INTENSITYMODE_ILLUMINANCE: number;
  10084. /**
  10085. * nit (cd/m^2)
  10086. */
  10087. static readonly INTENSITYMODE_LUMINANCE: number;
  10088. /**
  10089. * Light type const id of the point light.
  10090. */
  10091. static readonly LIGHTTYPEID_POINTLIGHT: number;
  10092. /**
  10093. * Light type const id of the directional light.
  10094. */
  10095. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  10096. /**
  10097. * Light type const id of the spot light.
  10098. */
  10099. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  10100. /**
  10101. * Light type const id of the hemispheric light.
  10102. */
  10103. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  10104. /**
  10105. * Diffuse gives the basic color to an object.
  10106. */
  10107. diffuse: Color3;
  10108. /**
  10109. * Specular produces a highlight color on an object.
  10110. * Note: This is note affecting PBR materials.
  10111. */
  10112. specular: Color3;
  10113. /**
  10114. * Defines the falloff type for this light. This lets overrriding how punctual light are
  10115. * falling off base on range or angle.
  10116. * This can be set to any values in Light.FALLOFF_x.
  10117. *
  10118. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  10119. * other types of materials.
  10120. */
  10121. falloffType: number;
  10122. /**
  10123. * Strength of the light.
  10124. * Note: By default it is define in the framework own unit.
  10125. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  10126. */
  10127. intensity: number;
  10128. private _range;
  10129. protected _inverseSquaredRange: number;
  10130. /**
  10131. * Defines how far from the source the light is impacting in scene units.
  10132. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10133. */
  10134. /**
  10135. * Defines how far from the source the light is impacting in scene units.
  10136. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10137. */
  10138. range: number;
  10139. /**
  10140. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  10141. * of light.
  10142. */
  10143. private _photometricScale;
  10144. private _intensityMode;
  10145. /**
  10146. * Gets the photometric scale used to interpret the intensity.
  10147. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10148. */
  10149. /**
  10150. * Sets the photometric scale used to interpret the intensity.
  10151. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10152. */
  10153. intensityMode: number;
  10154. private _radius;
  10155. /**
  10156. * Gets the light radius used by PBR Materials to simulate soft area lights.
  10157. */
  10158. /**
  10159. * sets the light radius used by PBR Materials to simulate soft area lights.
  10160. */
  10161. radius: number;
  10162. private _renderPriority;
  10163. /**
  10164. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  10165. * exceeding the number allowed of the materials.
  10166. */
  10167. renderPriority: number;
  10168. private _shadowEnabled;
  10169. /**
  10170. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10171. * the current shadow generator.
  10172. */
  10173. /**
  10174. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10175. * the current shadow generator.
  10176. */
  10177. shadowEnabled: boolean;
  10178. private _includedOnlyMeshes;
  10179. /**
  10180. * Gets the only meshes impacted by this light.
  10181. */
  10182. /**
  10183. * Sets the only meshes impacted by this light.
  10184. */
  10185. includedOnlyMeshes: AbstractMesh[];
  10186. private _excludedMeshes;
  10187. /**
  10188. * Gets the meshes not impacted by this light.
  10189. */
  10190. /**
  10191. * Sets the meshes not impacted by this light.
  10192. */
  10193. excludedMeshes: AbstractMesh[];
  10194. private _excludeWithLayerMask;
  10195. /**
  10196. * Gets the layer id use to find what meshes are not impacted by the light.
  10197. * Inactive if 0
  10198. */
  10199. /**
  10200. * Sets the layer id use to find what meshes are not impacted by the light.
  10201. * Inactive if 0
  10202. */
  10203. excludeWithLayerMask: number;
  10204. private _includeOnlyWithLayerMask;
  10205. /**
  10206. * Gets the layer id use to find what meshes are impacted by the light.
  10207. * Inactive if 0
  10208. */
  10209. /**
  10210. * Sets the layer id use to find what meshes are impacted by the light.
  10211. * Inactive if 0
  10212. */
  10213. includeOnlyWithLayerMask: number;
  10214. private _lightmapMode;
  10215. /**
  10216. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10217. */
  10218. /**
  10219. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10220. */
  10221. lightmapMode: number;
  10222. /**
  10223. * Shadow generator associted to the light.
  10224. * @hidden Internal use only.
  10225. */
  10226. _shadowGenerator: Nullable<IShadowGenerator>;
  10227. /**
  10228. * @hidden Internal use only.
  10229. */
  10230. _excludedMeshesIds: string[];
  10231. /**
  10232. * @hidden Internal use only.
  10233. */
  10234. _includedOnlyMeshesIds: string[];
  10235. /**
  10236. * The current light unifom buffer.
  10237. * @hidden Internal use only.
  10238. */
  10239. _uniformBuffer: UniformBuffer;
  10240. /**
  10241. * Creates a Light object in the scene.
  10242. * Documentation : https://doc.babylonjs.com/babylon101/lights
  10243. * @param name The firendly name of the light
  10244. * @param scene The scene the light belongs too
  10245. */
  10246. constructor(name: string, scene: Scene);
  10247. protected abstract _buildUniformLayout(): void;
  10248. /**
  10249. * Sets the passed Effect "effect" with the Light information.
  10250. * @param effect The effect to update
  10251. * @param lightIndex The index of the light in the effect to update
  10252. * @returns The light
  10253. */
  10254. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10255. /**
  10256. * Returns the string "Light".
  10257. * @returns the class name
  10258. */
  10259. getClassName(): string;
  10260. /** @hidden */
  10261. readonly _isLight: boolean;
  10262. /**
  10263. * Converts the light information to a readable string for debug purpose.
  10264. * @param fullDetails Supports for multiple levels of logging within scene loading
  10265. * @returns the human readable light info
  10266. */
  10267. toString(fullDetails?: boolean): string;
  10268. /** @hidden */
  10269. protected _syncParentEnabledState(): void;
  10270. /**
  10271. * Set the enabled state of this node.
  10272. * @param value - the new enabled state
  10273. */
  10274. setEnabled(value: boolean): void;
  10275. /**
  10276. * Returns the Light associated shadow generator if any.
  10277. * @return the associated shadow generator.
  10278. */
  10279. getShadowGenerator(): Nullable<IShadowGenerator>;
  10280. /**
  10281. * Returns a Vector3, the absolute light position in the World.
  10282. * @returns the world space position of the light
  10283. */
  10284. getAbsolutePosition(): Vector3;
  10285. /**
  10286. * Specifies if the light will affect the passed mesh.
  10287. * @param mesh The mesh to test against the light
  10288. * @return true the mesh is affected otherwise, false.
  10289. */
  10290. canAffectMesh(mesh: AbstractMesh): boolean;
  10291. /**
  10292. * Sort function to order lights for rendering.
  10293. * @param a First Light object to compare to second.
  10294. * @param b Second Light object to compare first.
  10295. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10296. */
  10297. static CompareLightsPriority(a: Light, b: Light): number;
  10298. /**
  10299. * Releases resources associated with this node.
  10300. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10301. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10302. */
  10303. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10304. /**
  10305. * Returns the light type ID (integer).
  10306. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10307. */
  10308. getTypeID(): number;
  10309. /**
  10310. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10311. * @returns the scaled intensity in intensity mode unit
  10312. */
  10313. getScaledIntensity(): number;
  10314. /**
  10315. * Returns a new Light object, named "name", from the current one.
  10316. * @param name The name of the cloned light
  10317. * @returns the new created light
  10318. */
  10319. clone(name: string): Nullable<Light>;
  10320. /**
  10321. * Serializes the current light into a Serialization object.
  10322. * @returns the serialized object.
  10323. */
  10324. serialize(): any;
  10325. /**
  10326. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10327. * This new light is named "name" and added to the passed scene.
  10328. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10329. * @param name The friendly name of the light
  10330. * @param scene The scene the new light will belong to
  10331. * @returns the constructor function
  10332. */
  10333. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10334. /**
  10335. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10336. * @param parsedLight The JSON representation of the light
  10337. * @param scene The scene to create the parsed light in
  10338. * @returns the created light after parsing
  10339. */
  10340. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10341. private _hookArrayForExcluded;
  10342. private _hookArrayForIncludedOnly;
  10343. private _resyncMeshes;
  10344. /**
  10345. * Forces the meshes to update their light related information in their rendering used effects
  10346. * @hidden Internal Use Only
  10347. */
  10348. _markMeshesAsLightDirty(): void;
  10349. /**
  10350. * Recomputes the cached photometric scale if needed.
  10351. */
  10352. private _computePhotometricScale;
  10353. /**
  10354. * Returns the Photometric Scale according to the light type and intensity mode.
  10355. */
  10356. private _getPhotometricScale;
  10357. /**
  10358. * Reorder the light in the scene according to their defined priority.
  10359. * @hidden Internal Use Only
  10360. */
  10361. _reorderLightsInScene(): void;
  10362. /**
  10363. * Prepares the list of defines specific to the light type.
  10364. * @param defines the list of defines
  10365. * @param lightIndex defines the index of the light for the effect
  10366. */
  10367. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10368. }
  10369. }
  10370. declare module "babylonjs/Actions/action" {
  10371. import { Observable } from "babylonjs/Misc/observable";
  10372. import { Condition } from "babylonjs/Actions/condition";
  10373. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10374. import { ActionManager } from "babylonjs/Actions/actionManager";
  10375. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10376. /**
  10377. * Interface used to define Action
  10378. */
  10379. export interface IAction {
  10380. /**
  10381. * Trigger for the action
  10382. */
  10383. trigger: number;
  10384. /** Options of the trigger */
  10385. triggerOptions: any;
  10386. /**
  10387. * Gets the trigger parameters
  10388. * @returns the trigger parameters
  10389. */
  10390. getTriggerParameter(): any;
  10391. /**
  10392. * Internal only - executes current action event
  10393. * @hidden
  10394. */
  10395. _executeCurrent(evt?: ActionEvent): void;
  10396. /**
  10397. * Serialize placeholder for child classes
  10398. * @param parent of child
  10399. * @returns the serialized object
  10400. */
  10401. serialize(parent: any): any;
  10402. /**
  10403. * Internal only
  10404. * @hidden
  10405. */
  10406. _prepare(): void;
  10407. /**
  10408. * Internal only - manager for action
  10409. * @hidden
  10410. */
  10411. _actionManager: AbstractActionManager;
  10412. }
  10413. /**
  10414. * The action to be carried out following a trigger
  10415. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10416. */
  10417. export class Action implements IAction {
  10418. /** the trigger, with or without parameters, for the action */
  10419. triggerOptions: any;
  10420. /**
  10421. * Trigger for the action
  10422. */
  10423. trigger: number;
  10424. /**
  10425. * Internal only - manager for action
  10426. * @hidden
  10427. */
  10428. _actionManager: ActionManager;
  10429. private _nextActiveAction;
  10430. private _child;
  10431. private _condition?;
  10432. private _triggerParameter;
  10433. /**
  10434. * An event triggered prior to action being executed.
  10435. */
  10436. onBeforeExecuteObservable: Observable<Action>;
  10437. /**
  10438. * Creates a new Action
  10439. * @param triggerOptions the trigger, with or without parameters, for the action
  10440. * @param condition an optional determinant of action
  10441. */
  10442. constructor(
  10443. /** the trigger, with or without parameters, for the action */
  10444. triggerOptions: any, condition?: Condition);
  10445. /**
  10446. * Internal only
  10447. * @hidden
  10448. */
  10449. _prepare(): void;
  10450. /**
  10451. * Gets the trigger parameters
  10452. * @returns the trigger parameters
  10453. */
  10454. getTriggerParameter(): any;
  10455. /**
  10456. * Internal only - executes current action event
  10457. * @hidden
  10458. */
  10459. _executeCurrent(evt?: ActionEvent): void;
  10460. /**
  10461. * Execute placeholder for child classes
  10462. * @param evt optional action event
  10463. */
  10464. execute(evt?: ActionEvent): void;
  10465. /**
  10466. * Skips to next active action
  10467. */
  10468. skipToNextActiveAction(): void;
  10469. /**
  10470. * Adds action to chain of actions, may be a DoNothingAction
  10471. * @param action defines the next action to execute
  10472. * @returns The action passed in
  10473. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10474. */
  10475. then(action: Action): Action;
  10476. /**
  10477. * Internal only
  10478. * @hidden
  10479. */
  10480. _getProperty(propertyPath: string): string;
  10481. /**
  10482. * Internal only
  10483. * @hidden
  10484. */
  10485. _getEffectiveTarget(target: any, propertyPath: string): any;
  10486. /**
  10487. * Serialize placeholder for child classes
  10488. * @param parent of child
  10489. * @returns the serialized object
  10490. */
  10491. serialize(parent: any): any;
  10492. /**
  10493. * Internal only called by serialize
  10494. * @hidden
  10495. */
  10496. protected _serialize(serializedAction: any, parent?: any): any;
  10497. /**
  10498. * Internal only
  10499. * @hidden
  10500. */
  10501. static _SerializeValueAsString: (value: any) => string;
  10502. /**
  10503. * Internal only
  10504. * @hidden
  10505. */
  10506. static _GetTargetProperty: (target: import("babylonjs/scene").Scene | import("babylonjs/node").Node) => {
  10507. name: string;
  10508. targetType: string;
  10509. value: string;
  10510. };
  10511. }
  10512. }
  10513. declare module "babylonjs/Actions/condition" {
  10514. import { ActionManager } from "babylonjs/Actions/actionManager";
  10515. /**
  10516. * A Condition applied to an Action
  10517. */
  10518. export class Condition {
  10519. /**
  10520. * Internal only - manager for action
  10521. * @hidden
  10522. */
  10523. _actionManager: ActionManager;
  10524. /**
  10525. * Internal only
  10526. * @hidden
  10527. */
  10528. _evaluationId: number;
  10529. /**
  10530. * Internal only
  10531. * @hidden
  10532. */
  10533. _currentResult: boolean;
  10534. /**
  10535. * Creates a new Condition
  10536. * @param actionManager the manager of the action the condition is applied to
  10537. */
  10538. constructor(actionManager: ActionManager);
  10539. /**
  10540. * Check if the current condition is valid
  10541. * @returns a boolean
  10542. */
  10543. isValid(): boolean;
  10544. /**
  10545. * Internal only
  10546. * @hidden
  10547. */
  10548. _getProperty(propertyPath: string): string;
  10549. /**
  10550. * Internal only
  10551. * @hidden
  10552. */
  10553. _getEffectiveTarget(target: any, propertyPath: string): any;
  10554. /**
  10555. * Serialize placeholder for child classes
  10556. * @returns the serialized object
  10557. */
  10558. serialize(): any;
  10559. /**
  10560. * Internal only
  10561. * @hidden
  10562. */
  10563. protected _serialize(serializedCondition: any): any;
  10564. }
  10565. /**
  10566. * Defines specific conditional operators as extensions of Condition
  10567. */
  10568. export class ValueCondition extends Condition {
  10569. /** path to specify the property of the target the conditional operator uses */
  10570. propertyPath: string;
  10571. /** the value compared by the conditional operator against the current value of the property */
  10572. value: any;
  10573. /** the conditional operator, default ValueCondition.IsEqual */
  10574. operator: number;
  10575. /**
  10576. * Internal only
  10577. * @hidden
  10578. */
  10579. private static _IsEqual;
  10580. /**
  10581. * Internal only
  10582. * @hidden
  10583. */
  10584. private static _IsDifferent;
  10585. /**
  10586. * Internal only
  10587. * @hidden
  10588. */
  10589. private static _IsGreater;
  10590. /**
  10591. * Internal only
  10592. * @hidden
  10593. */
  10594. private static _IsLesser;
  10595. /**
  10596. * returns the number for IsEqual
  10597. */
  10598. static readonly IsEqual: number;
  10599. /**
  10600. * Returns the number for IsDifferent
  10601. */
  10602. static readonly IsDifferent: number;
  10603. /**
  10604. * Returns the number for IsGreater
  10605. */
  10606. static readonly IsGreater: number;
  10607. /**
  10608. * Returns the number for IsLesser
  10609. */
  10610. static readonly IsLesser: number;
  10611. /**
  10612. * Internal only The action manager for the condition
  10613. * @hidden
  10614. */
  10615. _actionManager: ActionManager;
  10616. /**
  10617. * Internal only
  10618. * @hidden
  10619. */
  10620. private _target;
  10621. /**
  10622. * Internal only
  10623. * @hidden
  10624. */
  10625. private _effectiveTarget;
  10626. /**
  10627. * Internal only
  10628. * @hidden
  10629. */
  10630. private _property;
  10631. /**
  10632. * Creates a new ValueCondition
  10633. * @param actionManager manager for the action the condition applies to
  10634. * @param target for the action
  10635. * @param propertyPath path to specify the property of the target the conditional operator uses
  10636. * @param value the value compared by the conditional operator against the current value of the property
  10637. * @param operator the conditional operator, default ValueCondition.IsEqual
  10638. */
  10639. constructor(actionManager: ActionManager, target: any,
  10640. /** path to specify the property of the target the conditional operator uses */
  10641. propertyPath: string,
  10642. /** the value compared by the conditional operator against the current value of the property */
  10643. value: any,
  10644. /** the conditional operator, default ValueCondition.IsEqual */
  10645. operator?: number);
  10646. /**
  10647. * Compares the given value with the property value for the specified conditional operator
  10648. * @returns the result of the comparison
  10649. */
  10650. isValid(): boolean;
  10651. /**
  10652. * Serialize the ValueCondition into a JSON compatible object
  10653. * @returns serialization object
  10654. */
  10655. serialize(): any;
  10656. /**
  10657. * Gets the name of the conditional operator for the ValueCondition
  10658. * @param operator the conditional operator
  10659. * @returns the name
  10660. */
  10661. static GetOperatorName(operator: number): string;
  10662. }
  10663. /**
  10664. * Defines a predicate condition as an extension of Condition
  10665. */
  10666. export class PredicateCondition extends Condition {
  10667. /** defines the predicate function used to validate the condition */
  10668. predicate: () => boolean;
  10669. /**
  10670. * Internal only - manager for action
  10671. * @hidden
  10672. */
  10673. _actionManager: ActionManager;
  10674. /**
  10675. * Creates a new PredicateCondition
  10676. * @param actionManager manager for the action the condition applies to
  10677. * @param predicate defines the predicate function used to validate the condition
  10678. */
  10679. constructor(actionManager: ActionManager,
  10680. /** defines the predicate function used to validate the condition */
  10681. predicate: () => boolean);
  10682. /**
  10683. * @returns the validity of the predicate condition
  10684. */
  10685. isValid(): boolean;
  10686. }
  10687. /**
  10688. * Defines a state condition as an extension of Condition
  10689. */
  10690. export class StateCondition extends Condition {
  10691. /** Value to compare with target state */
  10692. value: string;
  10693. /**
  10694. * Internal only - manager for action
  10695. * @hidden
  10696. */
  10697. _actionManager: ActionManager;
  10698. /**
  10699. * Internal only
  10700. * @hidden
  10701. */
  10702. private _target;
  10703. /**
  10704. * Creates a new StateCondition
  10705. * @param actionManager manager for the action the condition applies to
  10706. * @param target of the condition
  10707. * @param value to compare with target state
  10708. */
  10709. constructor(actionManager: ActionManager, target: any,
  10710. /** Value to compare with target state */
  10711. value: string);
  10712. /**
  10713. * Gets a boolean indicating if the current condition is met
  10714. * @returns the validity of the state
  10715. */
  10716. isValid(): boolean;
  10717. /**
  10718. * Serialize the StateCondition into a JSON compatible object
  10719. * @returns serialization object
  10720. */
  10721. serialize(): any;
  10722. }
  10723. }
  10724. declare module "babylonjs/Actions/directActions" {
  10725. import { Action } from "babylonjs/Actions/action";
  10726. import { Condition } from "babylonjs/Actions/condition";
  10727. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10728. /**
  10729. * This defines an action responsible to toggle a boolean once triggered.
  10730. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10731. */
  10732. export class SwitchBooleanAction extends Action {
  10733. /**
  10734. * The path to the boolean property in the target object
  10735. */
  10736. propertyPath: string;
  10737. private _target;
  10738. private _effectiveTarget;
  10739. private _property;
  10740. /**
  10741. * Instantiate the action
  10742. * @param triggerOptions defines the trigger options
  10743. * @param target defines the object containing the boolean
  10744. * @param propertyPath defines the path to the boolean property in the target object
  10745. * @param condition defines the trigger related conditions
  10746. */
  10747. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10748. /** @hidden */
  10749. _prepare(): void;
  10750. /**
  10751. * Execute the action toggle the boolean value.
  10752. */
  10753. execute(): void;
  10754. /**
  10755. * Serializes the actions and its related information.
  10756. * @param parent defines the object to serialize in
  10757. * @returns the serialized object
  10758. */
  10759. serialize(parent: any): any;
  10760. }
  10761. /**
  10762. * This defines an action responsible to set a the state field of the target
  10763. * to a desired value once triggered.
  10764. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10765. */
  10766. export class SetStateAction extends Action {
  10767. /**
  10768. * The value to store in the state field.
  10769. */
  10770. value: string;
  10771. private _target;
  10772. /**
  10773. * Instantiate the action
  10774. * @param triggerOptions defines the trigger options
  10775. * @param target defines the object containing the state property
  10776. * @param value defines the value to store in the state field
  10777. * @param condition defines the trigger related conditions
  10778. */
  10779. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10780. /**
  10781. * Execute the action and store the value on the target state property.
  10782. */
  10783. execute(): void;
  10784. /**
  10785. * Serializes the actions and its related information.
  10786. * @param parent defines the object to serialize in
  10787. * @returns the serialized object
  10788. */
  10789. serialize(parent: any): any;
  10790. }
  10791. /**
  10792. * This defines an action responsible to set a property of the target
  10793. * to a desired value once triggered.
  10794. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10795. */
  10796. export class SetValueAction extends Action {
  10797. /**
  10798. * The path of the property to set in the target.
  10799. */
  10800. propertyPath: string;
  10801. /**
  10802. * The value to set in the property
  10803. */
  10804. value: any;
  10805. private _target;
  10806. private _effectiveTarget;
  10807. private _property;
  10808. /**
  10809. * Instantiate the action
  10810. * @param triggerOptions defines the trigger options
  10811. * @param target defines the object containing the property
  10812. * @param propertyPath defines the path of the property to set in the target
  10813. * @param value defines the value to set in the property
  10814. * @param condition defines the trigger related conditions
  10815. */
  10816. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10817. /** @hidden */
  10818. _prepare(): void;
  10819. /**
  10820. * Execute the action and set the targetted property to the desired value.
  10821. */
  10822. execute(): void;
  10823. /**
  10824. * Serializes the actions and its related information.
  10825. * @param parent defines the object to serialize in
  10826. * @returns the serialized object
  10827. */
  10828. serialize(parent: any): any;
  10829. }
  10830. /**
  10831. * This defines an action responsible to increment the target value
  10832. * to a desired value once triggered.
  10833. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10834. */
  10835. export class IncrementValueAction extends Action {
  10836. /**
  10837. * The path of the property to increment in the target.
  10838. */
  10839. propertyPath: string;
  10840. /**
  10841. * The value we should increment the property by.
  10842. */
  10843. value: any;
  10844. private _target;
  10845. private _effectiveTarget;
  10846. private _property;
  10847. /**
  10848. * Instantiate the action
  10849. * @param triggerOptions defines the trigger options
  10850. * @param target defines the object containing the property
  10851. * @param propertyPath defines the path of the property to increment in the target
  10852. * @param value defines the value value we should increment the property by
  10853. * @param condition defines the trigger related conditions
  10854. */
  10855. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10856. /** @hidden */
  10857. _prepare(): void;
  10858. /**
  10859. * Execute the action and increment the target of the value amount.
  10860. */
  10861. execute(): void;
  10862. /**
  10863. * Serializes the actions and its related information.
  10864. * @param parent defines the object to serialize in
  10865. * @returns the serialized object
  10866. */
  10867. serialize(parent: any): any;
  10868. }
  10869. /**
  10870. * This defines an action responsible to start an animation once triggered.
  10871. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10872. */
  10873. export class PlayAnimationAction extends Action {
  10874. /**
  10875. * Where the animation should start (animation frame)
  10876. */
  10877. from: number;
  10878. /**
  10879. * Where the animation should stop (animation frame)
  10880. */
  10881. to: number;
  10882. /**
  10883. * Define if the animation should loop or stop after the first play.
  10884. */
  10885. loop?: boolean;
  10886. private _target;
  10887. /**
  10888. * Instantiate the action
  10889. * @param triggerOptions defines the trigger options
  10890. * @param target defines the target animation or animation name
  10891. * @param from defines from where the animation should start (animation frame)
  10892. * @param end defines where the animation should stop (animation frame)
  10893. * @param loop defines if the animation should loop or stop after the first play
  10894. * @param condition defines the trigger related conditions
  10895. */
  10896. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10897. /** @hidden */
  10898. _prepare(): void;
  10899. /**
  10900. * Execute the action and play the animation.
  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 stop an animation once triggered.
  10912. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10913. */
  10914. export class StopAnimationAction extends Action {
  10915. private _target;
  10916. /**
  10917. * Instantiate the action
  10918. * @param triggerOptions defines the trigger options
  10919. * @param target defines the target animation or animation name
  10920. * @param condition defines the trigger related conditions
  10921. */
  10922. constructor(triggerOptions: any, target: any, condition?: Condition);
  10923. /** @hidden */
  10924. _prepare(): void;
  10925. /**
  10926. * Execute the action and stop the animation.
  10927. */
  10928. execute(): void;
  10929. /**
  10930. * Serializes the actions and its related information.
  10931. * @param parent defines the object to serialize in
  10932. * @returns the serialized object
  10933. */
  10934. serialize(parent: any): any;
  10935. }
  10936. /**
  10937. * This defines an action responsible that does nothing once triggered.
  10938. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10939. */
  10940. export class DoNothingAction extends Action {
  10941. /**
  10942. * Instantiate the action
  10943. * @param triggerOptions defines the trigger options
  10944. * @param condition defines the trigger related conditions
  10945. */
  10946. constructor(triggerOptions?: any, condition?: Condition);
  10947. /**
  10948. * Execute the action and do nothing.
  10949. */
  10950. execute(): void;
  10951. /**
  10952. * Serializes the actions and its related information.
  10953. * @param parent defines the object to serialize in
  10954. * @returns the serialized object
  10955. */
  10956. serialize(parent: any): any;
  10957. }
  10958. /**
  10959. * This defines an action responsible to trigger several actions once triggered.
  10960. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10961. */
  10962. export class CombineAction extends Action {
  10963. /**
  10964. * The list of aggregated animations to run.
  10965. */
  10966. children: Action[];
  10967. /**
  10968. * Instantiate the action
  10969. * @param triggerOptions defines the trigger options
  10970. * @param children defines the list of aggregated animations to run
  10971. * @param condition defines the trigger related conditions
  10972. */
  10973. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10974. /** @hidden */
  10975. _prepare(): void;
  10976. /**
  10977. * Execute the action and executes all the aggregated actions.
  10978. */
  10979. execute(evt: ActionEvent): void;
  10980. /**
  10981. * Serializes the actions and its related information.
  10982. * @param parent defines the object to serialize in
  10983. * @returns the serialized object
  10984. */
  10985. serialize(parent: any): any;
  10986. }
  10987. /**
  10988. * This defines an action responsible to run code (external event) once triggered.
  10989. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10990. */
  10991. export class ExecuteCodeAction extends Action {
  10992. /**
  10993. * The callback function to run.
  10994. */
  10995. func: (evt: ActionEvent) => void;
  10996. /**
  10997. * Instantiate the action
  10998. * @param triggerOptions defines the trigger options
  10999. * @param func defines the callback function to run
  11000. * @param condition defines the trigger related conditions
  11001. */
  11002. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  11003. /**
  11004. * Execute the action and run the attached code.
  11005. */
  11006. execute(evt: ActionEvent): void;
  11007. }
  11008. /**
  11009. * This defines an action responsible to set the parent property of the target once triggered.
  11010. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11011. */
  11012. export class SetParentAction extends Action {
  11013. private _parent;
  11014. private _target;
  11015. /**
  11016. * Instantiate the action
  11017. * @param triggerOptions defines the trigger options
  11018. * @param target defines the target containing the parent property
  11019. * @param parent defines from where the animation should start (animation frame)
  11020. * @param condition defines the trigger related conditions
  11021. */
  11022. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  11023. /** @hidden */
  11024. _prepare(): void;
  11025. /**
  11026. * Execute the action and set the parent property.
  11027. */
  11028. execute(): void;
  11029. /**
  11030. * Serializes the actions and its related information.
  11031. * @param parent defines the object to serialize in
  11032. * @returns the serialized object
  11033. */
  11034. serialize(parent: any): any;
  11035. }
  11036. }
  11037. declare module "babylonjs/Actions/actionManager" {
  11038. import { Nullable } from "babylonjs/types";
  11039. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11040. import { Scene } from "babylonjs/scene";
  11041. import { IAction } from "babylonjs/Actions/action";
  11042. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  11043. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  11044. /**
  11045. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  11046. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  11047. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11048. */
  11049. export class ActionManager extends AbstractActionManager {
  11050. /**
  11051. * Nothing
  11052. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11053. */
  11054. static readonly NothingTrigger: number;
  11055. /**
  11056. * On pick
  11057. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11058. */
  11059. static readonly OnPickTrigger: number;
  11060. /**
  11061. * On left pick
  11062. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11063. */
  11064. static readonly OnLeftPickTrigger: number;
  11065. /**
  11066. * On right pick
  11067. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11068. */
  11069. static readonly OnRightPickTrigger: number;
  11070. /**
  11071. * On center pick
  11072. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11073. */
  11074. static readonly OnCenterPickTrigger: number;
  11075. /**
  11076. * On pick down
  11077. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11078. */
  11079. static readonly OnPickDownTrigger: number;
  11080. /**
  11081. * On double pick
  11082. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11083. */
  11084. static readonly OnDoublePickTrigger: number;
  11085. /**
  11086. * On pick up
  11087. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11088. */
  11089. static readonly OnPickUpTrigger: number;
  11090. /**
  11091. * On pick out.
  11092. * This trigger will only be raised if you also declared a OnPickDown
  11093. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11094. */
  11095. static readonly OnPickOutTrigger: number;
  11096. /**
  11097. * On long press
  11098. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11099. */
  11100. static readonly OnLongPressTrigger: number;
  11101. /**
  11102. * On pointer over
  11103. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11104. */
  11105. static readonly OnPointerOverTrigger: number;
  11106. /**
  11107. * On pointer out
  11108. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11109. */
  11110. static readonly OnPointerOutTrigger: number;
  11111. /**
  11112. * On every frame
  11113. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11114. */
  11115. static readonly OnEveryFrameTrigger: number;
  11116. /**
  11117. * On intersection enter
  11118. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11119. */
  11120. static readonly OnIntersectionEnterTrigger: number;
  11121. /**
  11122. * On intersection exit
  11123. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11124. */
  11125. static readonly OnIntersectionExitTrigger: number;
  11126. /**
  11127. * On key down
  11128. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11129. */
  11130. static readonly OnKeyDownTrigger: number;
  11131. /**
  11132. * On key up
  11133. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11134. */
  11135. static readonly OnKeyUpTrigger: number;
  11136. private _scene;
  11137. /**
  11138. * Creates a new action manager
  11139. * @param scene defines the hosting scene
  11140. */
  11141. constructor(scene: Scene);
  11142. /**
  11143. * Releases all associated resources
  11144. */
  11145. dispose(): void;
  11146. /**
  11147. * Gets hosting scene
  11148. * @returns the hosting scene
  11149. */
  11150. getScene(): Scene;
  11151. /**
  11152. * Does this action manager handles actions of any of the given triggers
  11153. * @param triggers defines the triggers to be tested
  11154. * @return a boolean indicating whether one (or more) of the triggers is handled
  11155. */
  11156. hasSpecificTriggers(triggers: number[]): boolean;
  11157. /**
  11158. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  11159. * speed.
  11160. * @param triggerA defines the trigger to be tested
  11161. * @param triggerB defines the trigger to be tested
  11162. * @return a boolean indicating whether one (or more) of the triggers is handled
  11163. */
  11164. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  11165. /**
  11166. * Does this action manager handles actions of a given trigger
  11167. * @param trigger defines the trigger to be tested
  11168. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  11169. * @return whether the trigger is handled
  11170. */
  11171. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  11172. /**
  11173. * Does this action manager has pointer triggers
  11174. */
  11175. readonly hasPointerTriggers: boolean;
  11176. /**
  11177. * Does this action manager has pick triggers
  11178. */
  11179. readonly hasPickTriggers: boolean;
  11180. /**
  11181. * Registers an action to this action manager
  11182. * @param action defines the action to be registered
  11183. * @return the action amended (prepared) after registration
  11184. */
  11185. registerAction(action: IAction): Nullable<IAction>;
  11186. /**
  11187. * Unregisters an action to this action manager
  11188. * @param action defines the action to be unregistered
  11189. * @return a boolean indicating whether the action has been unregistered
  11190. */
  11191. unregisterAction(action: IAction): Boolean;
  11192. /**
  11193. * Process a specific trigger
  11194. * @param trigger defines the trigger to process
  11195. * @param evt defines the event details to be processed
  11196. */
  11197. processTrigger(trigger: number, evt?: IActionEvent): void;
  11198. /** @hidden */
  11199. _getEffectiveTarget(target: any, propertyPath: string): any;
  11200. /** @hidden */
  11201. _getProperty(propertyPath: string): string;
  11202. /**
  11203. * Serialize this manager to a JSON object
  11204. * @param name defines the property name to store this manager
  11205. * @returns a JSON representation of this manager
  11206. */
  11207. serialize(name: string): any;
  11208. /**
  11209. * Creates a new ActionManager from a JSON data
  11210. * @param parsedActions defines the JSON data to read from
  11211. * @param object defines the hosting mesh
  11212. * @param scene defines the hosting scene
  11213. */
  11214. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  11215. /**
  11216. * Get a trigger name by index
  11217. * @param trigger defines the trigger index
  11218. * @returns a trigger name
  11219. */
  11220. static GetTriggerName(trigger: number): string;
  11221. }
  11222. }
  11223. declare module "babylonjs/Culling/ray" {
  11224. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  11225. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  11226. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11227. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11228. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  11229. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  11230. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  11231. /**
  11232. * Class representing a ray with position and direction
  11233. */
  11234. export class Ray {
  11235. /** origin point */
  11236. origin: Vector3;
  11237. /** direction */
  11238. direction: Vector3;
  11239. /** length of the ray */
  11240. length: number;
  11241. private static readonly TmpVector3;
  11242. private _tmpRay;
  11243. /**
  11244. * Creates a new ray
  11245. * @param origin origin point
  11246. * @param direction direction
  11247. * @param length length of the ray
  11248. */
  11249. constructor(
  11250. /** origin point */
  11251. origin: Vector3,
  11252. /** direction */
  11253. direction: Vector3,
  11254. /** length of the ray */
  11255. length?: number);
  11256. /**
  11257. * Checks if the ray intersects a box
  11258. * @param minimum bound of the box
  11259. * @param maximum bound of the box
  11260. * @param intersectionTreshold extra extend to be added to the box in all direction
  11261. * @returns if the box was hit
  11262. */
  11263. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11264. /**
  11265. * Checks if the ray intersects a box
  11266. * @param box the bounding box to check
  11267. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11268. * @returns if the box was hit
  11269. */
  11270. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11271. /**
  11272. * If the ray hits a sphere
  11273. * @param sphere the bounding sphere to check
  11274. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11275. * @returns true if it hits the sphere
  11276. */
  11277. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11278. /**
  11279. * If the ray hits a triange
  11280. * @param vertex0 triangle vertex
  11281. * @param vertex1 triangle vertex
  11282. * @param vertex2 triangle vertex
  11283. * @returns intersection information if hit
  11284. */
  11285. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11286. /**
  11287. * Checks if ray intersects a plane
  11288. * @param plane the plane to check
  11289. * @returns the distance away it was hit
  11290. */
  11291. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11292. /**
  11293. * Checks if ray intersects a mesh
  11294. * @param mesh the mesh to check
  11295. * @param fastCheck if only the bounding box should checked
  11296. * @returns picking info of the intersecton
  11297. */
  11298. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11299. /**
  11300. * Checks if ray intersects a mesh
  11301. * @param meshes the meshes to check
  11302. * @param fastCheck if only the bounding box should checked
  11303. * @param results array to store result in
  11304. * @returns Array of picking infos
  11305. */
  11306. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11307. private _comparePickingInfo;
  11308. private static smallnum;
  11309. private static rayl;
  11310. /**
  11311. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11312. * @param sega the first point of the segment to test the intersection against
  11313. * @param segb the second point of the segment to test the intersection against
  11314. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11315. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11316. */
  11317. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11318. /**
  11319. * Update the ray from viewport position
  11320. * @param x position
  11321. * @param y y position
  11322. * @param viewportWidth viewport width
  11323. * @param viewportHeight viewport height
  11324. * @param world world matrix
  11325. * @param view view matrix
  11326. * @param projection projection matrix
  11327. * @returns this ray updated
  11328. */
  11329. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11330. /**
  11331. * Creates a ray with origin and direction of 0,0,0
  11332. * @returns the new ray
  11333. */
  11334. static Zero(): Ray;
  11335. /**
  11336. * Creates a new ray from screen space and viewport
  11337. * @param x position
  11338. * @param y y position
  11339. * @param viewportWidth viewport width
  11340. * @param viewportHeight viewport height
  11341. * @param world world matrix
  11342. * @param view view matrix
  11343. * @param projection projection matrix
  11344. * @returns new ray
  11345. */
  11346. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11347. /**
  11348. * 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
  11349. * transformed to the given world matrix.
  11350. * @param origin The origin point
  11351. * @param end The end point
  11352. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11353. * @returns the new ray
  11354. */
  11355. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11356. /**
  11357. * Transforms a ray by a matrix
  11358. * @param ray ray to transform
  11359. * @param matrix matrix to apply
  11360. * @returns the resulting new ray
  11361. */
  11362. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11363. /**
  11364. * Transforms a ray by a matrix
  11365. * @param ray ray to transform
  11366. * @param matrix matrix to apply
  11367. * @param result ray to store result in
  11368. */
  11369. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11370. /**
  11371. * Unproject a ray from screen space to object space
  11372. * @param sourceX defines the screen space x coordinate to use
  11373. * @param sourceY defines the screen space y coordinate to use
  11374. * @param viewportWidth defines the current width of the viewport
  11375. * @param viewportHeight defines the current height of the viewport
  11376. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11377. * @param view defines the view matrix to use
  11378. * @param projection defines the projection matrix to use
  11379. */
  11380. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11381. }
  11382. /**
  11383. * Type used to define predicate used to select faces when a mesh intersection is detected
  11384. */
  11385. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11386. module "babylonjs/scene" {
  11387. interface Scene {
  11388. /** @hidden */
  11389. _tempPickingRay: Nullable<Ray>;
  11390. /** @hidden */
  11391. _cachedRayForTransform: Ray;
  11392. /** @hidden */
  11393. _pickWithRayInverseMatrix: Matrix;
  11394. /** @hidden */
  11395. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11396. /** @hidden */
  11397. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11398. }
  11399. }
  11400. }
  11401. declare module "babylonjs/sceneComponent" {
  11402. import { Scene } from "babylonjs/scene";
  11403. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11404. import { SubMesh } from "babylonjs/Meshes/subMesh";
  11405. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  11406. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  11407. import { Nullable } from "babylonjs/types";
  11408. import { Camera } from "babylonjs/Cameras/camera";
  11409. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  11410. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11411. import { AbstractScene } from "babylonjs/abstractScene";
  11412. /**
  11413. * Groups all the scene component constants in one place to ease maintenance.
  11414. * @hidden
  11415. */
  11416. export class SceneComponentConstants {
  11417. static readonly NAME_EFFECTLAYER: string;
  11418. static readonly NAME_LAYER: string;
  11419. static readonly NAME_LENSFLARESYSTEM: string;
  11420. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11421. static readonly NAME_PARTICLESYSTEM: string;
  11422. static readonly NAME_GAMEPAD: string;
  11423. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11424. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11425. static readonly NAME_DEPTHRENDERER: string;
  11426. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11427. static readonly NAME_SPRITE: string;
  11428. static readonly NAME_OUTLINERENDERER: string;
  11429. static readonly NAME_PROCEDURALTEXTURE: string;
  11430. static readonly NAME_SHADOWGENERATOR: string;
  11431. static readonly NAME_OCTREE: string;
  11432. static readonly NAME_PHYSICSENGINE: string;
  11433. static readonly NAME_AUDIO: string;
  11434. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11435. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11436. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11437. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11438. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11439. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11440. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11441. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11442. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11443. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11444. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11445. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11446. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11447. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11448. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11449. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11450. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11451. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11452. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11453. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11454. static readonly STEP_AFTERRENDER_AUDIO: number;
  11455. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11456. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11457. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11458. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11459. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11460. static readonly STEP_POINTERMOVE_SPRITE: number;
  11461. static readonly STEP_POINTERDOWN_SPRITE: number;
  11462. static readonly STEP_POINTERUP_SPRITE: number;
  11463. }
  11464. /**
  11465. * This represents a scene component.
  11466. *
  11467. * This is used to decouple the dependency the scene is having on the different workloads like
  11468. * layers, post processes...
  11469. */
  11470. export interface ISceneComponent {
  11471. /**
  11472. * The name of the component. Each component must have a unique name.
  11473. */
  11474. name: string;
  11475. /**
  11476. * The scene the component belongs to.
  11477. */
  11478. scene: Scene;
  11479. /**
  11480. * Register the component to one instance of a scene.
  11481. */
  11482. register(): void;
  11483. /**
  11484. * Rebuilds the elements related to this component in case of
  11485. * context lost for instance.
  11486. */
  11487. rebuild(): void;
  11488. /**
  11489. * Disposes the component and the associated ressources.
  11490. */
  11491. dispose(): void;
  11492. }
  11493. /**
  11494. * This represents a SERIALIZABLE scene component.
  11495. *
  11496. * This extends Scene Component to add Serialization methods on top.
  11497. */
  11498. export interface ISceneSerializableComponent extends ISceneComponent {
  11499. /**
  11500. * Adds all the element from the container to the scene
  11501. * @param container the container holding the elements
  11502. */
  11503. addFromContainer(container: AbstractScene): void;
  11504. /**
  11505. * Removes all the elements in the container from the scene
  11506. * @param container contains the elements to remove
  11507. */
  11508. removeFromContainer(container: AbstractScene): void;
  11509. /**
  11510. * Serializes the component data to the specified json object
  11511. * @param serializationObject The object to serialize to
  11512. */
  11513. serialize(serializationObject: any): void;
  11514. }
  11515. /**
  11516. * Strong typing of a Mesh related stage step action
  11517. */
  11518. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11519. /**
  11520. * Strong typing of a Evaluate Sub Mesh related stage step action
  11521. */
  11522. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11523. /**
  11524. * Strong typing of a Active Mesh related stage step action
  11525. */
  11526. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11527. /**
  11528. * Strong typing of a Camera related stage step action
  11529. */
  11530. export type CameraStageAction = (camera: Camera) => void;
  11531. /**
  11532. * Strong typing of a Render Target related stage step action
  11533. */
  11534. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11535. /**
  11536. * Strong typing of a RenderingGroup related stage step action
  11537. */
  11538. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11539. /**
  11540. * Strong typing of a Mesh Render related stage step action
  11541. */
  11542. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11543. /**
  11544. * Strong typing of a simple stage step action
  11545. */
  11546. export type SimpleStageAction = () => void;
  11547. /**
  11548. * Strong typing of a render target action.
  11549. */
  11550. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11551. /**
  11552. * Strong typing of a pointer move action.
  11553. */
  11554. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11555. /**
  11556. * Strong typing of a pointer up/down action.
  11557. */
  11558. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11559. /**
  11560. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  11561. * @hidden
  11562. */
  11563. export class Stage<T extends Function> extends Array<{
  11564. index: number;
  11565. component: ISceneComponent;
  11566. action: T;
  11567. }> {
  11568. /**
  11569. * Hide ctor from the rest of the world.
  11570. * @param items The items to add.
  11571. */
  11572. private constructor();
  11573. /**
  11574. * Creates a new Stage.
  11575. * @returns A new instance of a Stage
  11576. */
  11577. static Create<T extends Function>(): Stage<T>;
  11578. /**
  11579. * Registers a step in an ordered way in the targeted stage.
  11580. * @param index Defines the position to register the step in
  11581. * @param component Defines the component attached to the step
  11582. * @param action Defines the action to launch during the step
  11583. */
  11584. registerStep(index: number, component: ISceneComponent, action: T): void;
  11585. /**
  11586. * Clears all the steps from the stage.
  11587. */
  11588. clear(): void;
  11589. }
  11590. }
  11591. declare module "babylonjs/Sprites/spriteSceneComponent" {
  11592. import { Nullable } from "babylonjs/types";
  11593. import { Observable } from "babylonjs/Misc/observable";
  11594. import { Scene } from "babylonjs/scene";
  11595. import { Sprite } from "babylonjs/Sprites/sprite";
  11596. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11597. import { Ray } from "babylonjs/Culling/ray";
  11598. import { Camera } from "babylonjs/Cameras/camera";
  11599. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11600. import { ISceneComponent } from "babylonjs/sceneComponent";
  11601. module "babylonjs/scene" {
  11602. interface Scene {
  11603. /** @hidden */
  11604. _pointerOverSprite: Nullable<Sprite>;
  11605. /** @hidden */
  11606. _pickedDownSprite: Nullable<Sprite>;
  11607. /** @hidden */
  11608. _tempSpritePickingRay: Nullable<Ray>;
  11609. /**
  11610. * All of the sprite managers added to this scene
  11611. * @see http://doc.babylonjs.com/babylon101/sprites
  11612. */
  11613. spriteManagers: Array<ISpriteManager>;
  11614. /**
  11615. * An event triggered when sprites rendering is about to start
  11616. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11617. */
  11618. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11619. /**
  11620. * An event triggered when sprites rendering is done
  11621. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11622. */
  11623. onAfterSpritesRenderingObservable: Observable<Scene>;
  11624. /** @hidden */
  11625. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11626. /** Launch a ray to try to pick a sprite in the scene
  11627. * @param x position on screen
  11628. * @param y position on screen
  11629. * @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
  11630. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11631. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11632. * @returns a PickingInfo
  11633. */
  11634. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11635. /** Use the given ray to pick a sprite in the scene
  11636. * @param ray The ray (in world space) to use to pick meshes
  11637. * @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
  11638. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11639. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11640. * @returns a PickingInfo
  11641. */
  11642. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11643. /**
  11644. * Force the sprite under the pointer
  11645. * @param sprite defines the sprite to use
  11646. */
  11647. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11648. /**
  11649. * Gets the sprite under the pointer
  11650. * @returns a Sprite or null if no sprite is under the pointer
  11651. */
  11652. getPointerOverSprite(): Nullable<Sprite>;
  11653. }
  11654. }
  11655. /**
  11656. * Defines the sprite scene component responsible to manage sprites
  11657. * in a given scene.
  11658. */
  11659. export class SpriteSceneComponent implements ISceneComponent {
  11660. /**
  11661. * The component name helpfull to identify the component in the list of scene components.
  11662. */
  11663. readonly name: string;
  11664. /**
  11665. * The scene the component belongs to.
  11666. */
  11667. scene: Scene;
  11668. /** @hidden */
  11669. private _spritePredicate;
  11670. /**
  11671. * Creates a new instance of the component for the given scene
  11672. * @param scene Defines the scene to register the component in
  11673. */
  11674. constructor(scene: Scene);
  11675. /**
  11676. * Registers the component in a given scene
  11677. */
  11678. register(): void;
  11679. /**
  11680. * Rebuilds the elements related to this component in case of
  11681. * context lost for instance.
  11682. */
  11683. rebuild(): void;
  11684. /**
  11685. * Disposes the component and the associated ressources.
  11686. */
  11687. dispose(): void;
  11688. private _pickSpriteButKeepRay;
  11689. private _pointerMove;
  11690. private _pointerDown;
  11691. private _pointerUp;
  11692. }
  11693. }
  11694. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  11695. /** @hidden */
  11696. export var fogFragmentDeclaration: {
  11697. name: string;
  11698. shader: string;
  11699. };
  11700. }
  11701. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  11702. /** @hidden */
  11703. export var fogFragment: {
  11704. name: string;
  11705. shader: string;
  11706. };
  11707. }
  11708. declare module "babylonjs/Shaders/sprites.fragment" {
  11709. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  11710. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  11711. /** @hidden */
  11712. export var spritesPixelShader: {
  11713. name: string;
  11714. shader: string;
  11715. };
  11716. }
  11717. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  11718. /** @hidden */
  11719. export var fogVertexDeclaration: {
  11720. name: string;
  11721. shader: string;
  11722. };
  11723. }
  11724. declare module "babylonjs/Shaders/sprites.vertex" {
  11725. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  11726. /** @hidden */
  11727. export var spritesVertexShader: {
  11728. name: string;
  11729. shader: string;
  11730. };
  11731. }
  11732. declare module "babylonjs/Sprites/spriteManager" {
  11733. import { IDisposable, Scene } from "babylonjs/scene";
  11734. import { Nullable } from "babylonjs/types";
  11735. import { Observable } from "babylonjs/Misc/observable";
  11736. import { Sprite } from "babylonjs/Sprites/sprite";
  11737. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11738. import { Camera } from "babylonjs/Cameras/camera";
  11739. import { Texture } from "babylonjs/Materials/Textures/texture";
  11740. import "babylonjs/Shaders/sprites.fragment";
  11741. import "babylonjs/Shaders/sprites.vertex";
  11742. import { Ray } from "babylonjs/Culling/ray";
  11743. /**
  11744. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11745. */
  11746. export interface ISpriteManager extends IDisposable {
  11747. /**
  11748. * Restricts the camera to viewing objects with the same layerMask.
  11749. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11750. */
  11751. layerMask: number;
  11752. /**
  11753. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11754. */
  11755. isPickable: boolean;
  11756. /**
  11757. * Specifies the rendering group id for this mesh (0 by default)
  11758. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11759. */
  11760. renderingGroupId: number;
  11761. /**
  11762. * Defines the list of sprites managed by the manager.
  11763. */
  11764. sprites: Array<Sprite>;
  11765. /**
  11766. * Tests the intersection of a sprite with a specific ray.
  11767. * @param ray The ray we are sending to test the collision
  11768. * @param camera The camera space we are sending rays in
  11769. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11770. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11771. * @returns picking info or null.
  11772. */
  11773. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11774. /**
  11775. * Renders the list of sprites on screen.
  11776. */
  11777. render(): void;
  11778. }
  11779. /**
  11780. * Class used to manage multiple sprites on the same spritesheet
  11781. * @see http://doc.babylonjs.com/babylon101/sprites
  11782. */
  11783. export class SpriteManager implements ISpriteManager {
  11784. /** defines the manager's name */
  11785. name: string;
  11786. /** Gets the list of sprites */
  11787. sprites: Sprite[];
  11788. /** Gets or sets the rendering group id (0 by default) */
  11789. renderingGroupId: number;
  11790. /** Gets or sets camera layer mask */
  11791. layerMask: number;
  11792. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11793. fogEnabled: boolean;
  11794. /** Gets or sets a boolean indicating if the sprites are pickable */
  11795. isPickable: boolean;
  11796. /** Defines the default width of a cell in the spritesheet */
  11797. cellWidth: number;
  11798. /** Defines the default height of a cell in the spritesheet */
  11799. cellHeight: number;
  11800. /**
  11801. * An event triggered when the manager is disposed.
  11802. */
  11803. onDisposeObservable: Observable<SpriteManager>;
  11804. private _onDisposeObserver;
  11805. /**
  11806. * Callback called when the manager is disposed
  11807. */
  11808. onDispose: () => void;
  11809. private _capacity;
  11810. private _spriteTexture;
  11811. private _epsilon;
  11812. private _scene;
  11813. private _vertexData;
  11814. private _buffer;
  11815. private _vertexBuffers;
  11816. private _indexBuffer;
  11817. private _effectBase;
  11818. private _effectFog;
  11819. /**
  11820. * Gets or sets the spritesheet texture
  11821. */
  11822. texture: Texture;
  11823. /**
  11824. * Creates a new sprite manager
  11825. * @param name defines the manager's name
  11826. * @param imgUrl defines the sprite sheet url
  11827. * @param capacity defines the maximum allowed number of sprites
  11828. * @param cellSize defines the size of a sprite cell
  11829. * @param scene defines the hosting scene
  11830. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11831. * @param samplingMode defines the smapling mode to use with spritesheet
  11832. */
  11833. constructor(
  11834. /** defines the manager's name */
  11835. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  11836. private _appendSpriteVertex;
  11837. /**
  11838. * Intersects the sprites with a ray
  11839. * @param ray defines the ray to intersect with
  11840. * @param camera defines the current active camera
  11841. * @param predicate defines a predicate used to select candidate sprites
  11842. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11843. * @returns null if no hit or a PickingInfo
  11844. */
  11845. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11846. /**
  11847. * Render all child sprites
  11848. */
  11849. render(): void;
  11850. /**
  11851. * Release associated resources
  11852. */
  11853. dispose(): void;
  11854. }
  11855. }
  11856. declare module "babylonjs/Sprites/sprite" {
  11857. import { Vector3, Color4 } from "babylonjs/Maths/math";
  11858. import { Nullable } from "babylonjs/types";
  11859. import { ActionManager } from "babylonjs/Actions/actionManager";
  11860. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11861. /**
  11862. * Class used to represent a sprite
  11863. * @see http://doc.babylonjs.com/babylon101/sprites
  11864. */
  11865. export class Sprite {
  11866. /** defines the name */
  11867. name: string;
  11868. /** Gets or sets the current world position */
  11869. position: Vector3;
  11870. /** Gets or sets the main color */
  11871. color: Color4;
  11872. /** Gets or sets the width */
  11873. width: number;
  11874. /** Gets or sets the height */
  11875. height: number;
  11876. /** Gets or sets rotation angle */
  11877. angle: number;
  11878. /** Gets or sets the cell index in the sprite sheet */
  11879. cellIndex: number;
  11880. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11881. invertU: number;
  11882. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11883. invertV: number;
  11884. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11885. disposeWhenFinishedAnimating: boolean;
  11886. /** Gets the list of attached animations */
  11887. animations: Animation[];
  11888. /** Gets or sets a boolean indicating if the sprite can be picked */
  11889. isPickable: boolean;
  11890. /**
  11891. * Gets or sets the associated action manager
  11892. */
  11893. actionManager: Nullable<ActionManager>;
  11894. private _animationStarted;
  11895. private _loopAnimation;
  11896. private _fromIndex;
  11897. private _toIndex;
  11898. private _delay;
  11899. private _direction;
  11900. private _manager;
  11901. private _time;
  11902. private _onAnimationEnd;
  11903. /**
  11904. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11905. */
  11906. isVisible: boolean;
  11907. /**
  11908. * Gets or sets the sprite size
  11909. */
  11910. size: number;
  11911. /**
  11912. * Creates a new Sprite
  11913. * @param name defines the name
  11914. * @param manager defines the manager
  11915. */
  11916. constructor(
  11917. /** defines the name */
  11918. name: string, manager: ISpriteManager);
  11919. /**
  11920. * Starts an animation
  11921. * @param from defines the initial key
  11922. * @param to defines the end key
  11923. * @param loop defines if the animation must loop
  11924. * @param delay defines the start delay (in ms)
  11925. * @param onAnimationEnd defines a callback to call when animation ends
  11926. */
  11927. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11928. /** Stops current animation (if any) */
  11929. stopAnimation(): void;
  11930. /** @hidden */
  11931. _animate(deltaTime: number): void;
  11932. /** Release associated resources */
  11933. dispose(): void;
  11934. }
  11935. }
  11936. declare module "babylonjs/Collisions/pickingInfo" {
  11937. import { Nullable } from "babylonjs/types";
  11938. import { Vector3, Vector2 } from "babylonjs/Maths/math";
  11939. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11940. import { Sprite } from "babylonjs/Sprites/sprite";
  11941. import { Ray } from "babylonjs/Culling/ray";
  11942. /**
  11943. * Information about the result of picking within a scene
  11944. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  11945. */
  11946. export class PickingInfo {
  11947. /** @hidden */
  11948. _pickingUnavailable: boolean;
  11949. /**
  11950. * If the pick collided with an object
  11951. */
  11952. hit: boolean;
  11953. /**
  11954. * Distance away where the pick collided
  11955. */
  11956. distance: number;
  11957. /**
  11958. * The location of pick collision
  11959. */
  11960. pickedPoint: Nullable<Vector3>;
  11961. /**
  11962. * The mesh corresponding the the pick collision
  11963. */
  11964. pickedMesh: Nullable<AbstractMesh>;
  11965. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  11966. bu: number;
  11967. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  11968. bv: number;
  11969. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  11970. faceId: number;
  11971. /** Id of the the submesh that was picked */
  11972. subMeshId: number;
  11973. /** If a sprite was picked, this will be the sprite the pick collided with */
  11974. pickedSprite: Nullable<Sprite>;
  11975. /**
  11976. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  11977. */
  11978. originMesh: Nullable<AbstractMesh>;
  11979. /**
  11980. * The ray that was used to perform the picking.
  11981. */
  11982. ray: Nullable<Ray>;
  11983. /**
  11984. * Gets the normal correspodning to the face the pick collided with
  11985. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  11986. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  11987. * @returns The normal correspodning to the face the pick collided with
  11988. */
  11989. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  11990. /**
  11991. * Gets the texture coordinates of where the pick occured
  11992. * @returns the vector containing the coordnates of the texture
  11993. */
  11994. getTextureCoordinates(): Nullable<Vector2>;
  11995. }
  11996. }
  11997. declare module "babylonjs/Events/pointerEvents" {
  11998. import { Nullable } from "babylonjs/types";
  11999. import { Vector2 } from "babylonjs/Maths/math";
  12000. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  12001. import { Ray } from "babylonjs/Culling/ray";
  12002. /**
  12003. * Gather the list of pointer event types as constants.
  12004. */
  12005. export class PointerEventTypes {
  12006. /**
  12007. * 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.
  12008. */
  12009. static readonly POINTERDOWN: number;
  12010. /**
  12011. * The pointerup event is fired when a pointer is no longer active.
  12012. */
  12013. static readonly POINTERUP: number;
  12014. /**
  12015. * The pointermove event is fired when a pointer changes coordinates.
  12016. */
  12017. static readonly POINTERMOVE: number;
  12018. /**
  12019. * The pointerwheel event is fired when a mouse wheel has been rotated.
  12020. */
  12021. static readonly POINTERWHEEL: number;
  12022. /**
  12023. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  12024. */
  12025. static readonly POINTERPICK: number;
  12026. /**
  12027. * The pointertap event is fired when a the object has been touched and released without drag.
  12028. */
  12029. static readonly POINTERTAP: number;
  12030. /**
  12031. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  12032. */
  12033. static readonly POINTERDOUBLETAP: number;
  12034. }
  12035. /**
  12036. * Base class of pointer info types.
  12037. */
  12038. export class PointerInfoBase {
  12039. /**
  12040. * Defines the type of event (PointerEventTypes)
  12041. */
  12042. type: number;
  12043. /**
  12044. * Defines the related dom event
  12045. */
  12046. event: PointerEvent | MouseWheelEvent;
  12047. /**
  12048. * Instantiates the base class of pointers info.
  12049. * @param type Defines the type of event (PointerEventTypes)
  12050. * @param event Defines the related dom event
  12051. */
  12052. constructor(
  12053. /**
  12054. * Defines the type of event (PointerEventTypes)
  12055. */
  12056. type: number,
  12057. /**
  12058. * Defines the related dom event
  12059. */
  12060. event: PointerEvent | MouseWheelEvent);
  12061. }
  12062. /**
  12063. * This class is used to store pointer related info for the onPrePointerObservable event.
  12064. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  12065. */
  12066. export class PointerInfoPre extends PointerInfoBase {
  12067. /**
  12068. * Ray from a pointer if availible (eg. 6dof controller)
  12069. */
  12070. ray: Nullable<Ray>;
  12071. /**
  12072. * Defines the local position of the pointer on the canvas.
  12073. */
  12074. localPosition: Vector2;
  12075. /**
  12076. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  12077. */
  12078. skipOnPointerObservable: boolean;
  12079. /**
  12080. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  12081. * @param type Defines the type of event (PointerEventTypes)
  12082. * @param event Defines the related dom event
  12083. * @param localX Defines the local x coordinates of the pointer when the event occured
  12084. * @param localY Defines the local y coordinates of the pointer when the event occured
  12085. */
  12086. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  12087. }
  12088. /**
  12089. * This type contains all the data related to a pointer event in Babylon.js.
  12090. * 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.
  12091. */
  12092. export class PointerInfo extends PointerInfoBase {
  12093. /**
  12094. * Defines the picking info associated to the info (if any)\
  12095. */
  12096. pickInfo: Nullable<PickingInfo>;
  12097. /**
  12098. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  12099. * @param type Defines the type of event (PointerEventTypes)
  12100. * @param event Defines the related dom event
  12101. * @param pickInfo Defines the picking info associated to the info (if any)\
  12102. */
  12103. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  12104. /**
  12105. * Defines the picking info associated to the info (if any)\
  12106. */
  12107. pickInfo: Nullable<PickingInfo>);
  12108. }
  12109. /**
  12110. * Data relating to a touch event on the screen.
  12111. */
  12112. export interface PointerTouch {
  12113. /**
  12114. * X coordinate of touch.
  12115. */
  12116. x: number;
  12117. /**
  12118. * Y coordinate of touch.
  12119. */
  12120. y: number;
  12121. /**
  12122. * Id of touch. Unique for each finger.
  12123. */
  12124. pointerId: number;
  12125. /**
  12126. * Event type passed from DOM.
  12127. */
  12128. type: any;
  12129. }
  12130. }
  12131. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  12132. import { Nullable } from "babylonjs/types";
  12133. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12134. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12135. /**
  12136. * Manage the mouse inputs to control the movement of a free camera.
  12137. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12138. */
  12139. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  12140. /**
  12141. * Define if touch is enabled in the mouse input
  12142. */
  12143. touchEnabled: boolean;
  12144. /**
  12145. * Defines the camera the input is attached to.
  12146. */
  12147. camera: FreeCamera;
  12148. /**
  12149. * Defines the buttons associated with the input to handle camera move.
  12150. */
  12151. buttons: number[];
  12152. /**
  12153. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  12154. */
  12155. angularSensibility: number;
  12156. private _pointerInput;
  12157. private _onMouseMove;
  12158. private _observer;
  12159. private previousPosition;
  12160. /**
  12161. * Manage the mouse inputs to control the movement of a free camera.
  12162. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12163. * @param touchEnabled Defines if touch is enabled or not
  12164. */
  12165. constructor(
  12166. /**
  12167. * Define if touch is enabled in the mouse input
  12168. */
  12169. touchEnabled?: boolean);
  12170. /**
  12171. * Attach the input controls to a specific dom element to get the input from.
  12172. * @param element Defines the element the controls should be listened from
  12173. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12174. */
  12175. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12176. /**
  12177. * Called on JS contextmenu event.
  12178. * Override this method to provide functionality.
  12179. */
  12180. protected onContextMenu(evt: PointerEvent): void;
  12181. /**
  12182. * Detach the current controls from the specified dom element.
  12183. * @param element Defines the element to stop listening the inputs from
  12184. */
  12185. detachControl(element: Nullable<HTMLElement>): void;
  12186. /**
  12187. * Gets the class name of the current intput.
  12188. * @returns the class name
  12189. */
  12190. getClassName(): string;
  12191. /**
  12192. * Get the friendly name associated with the input class.
  12193. * @returns the input friendly name
  12194. */
  12195. getSimpleName(): string;
  12196. }
  12197. }
  12198. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  12199. import { Nullable } from "babylonjs/types";
  12200. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12201. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12202. /**
  12203. * Manage the touch inputs to control the movement of a free camera.
  12204. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12205. */
  12206. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  12207. /**
  12208. * Defines the camera the input is attached to.
  12209. */
  12210. camera: FreeCamera;
  12211. /**
  12212. * Defines the touch sensibility for rotation.
  12213. * The higher the faster.
  12214. */
  12215. touchAngularSensibility: number;
  12216. /**
  12217. * Defines the touch sensibility for move.
  12218. * The higher the faster.
  12219. */
  12220. touchMoveSensibility: number;
  12221. private _offsetX;
  12222. private _offsetY;
  12223. private _pointerPressed;
  12224. private _pointerInput;
  12225. private _observer;
  12226. private _onLostFocus;
  12227. /**
  12228. * Attach the input controls to a specific dom element to get the input from.
  12229. * @param element Defines the element the controls should be listened from
  12230. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12231. */
  12232. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12233. /**
  12234. * Detach the current controls from the specified dom element.
  12235. * @param element Defines the element to stop listening the inputs from
  12236. */
  12237. detachControl(element: Nullable<HTMLElement>): void;
  12238. /**
  12239. * Update the current camera state depending on the inputs that have been used this frame.
  12240. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12241. */
  12242. checkInputs(): void;
  12243. /**
  12244. * Gets the class name of the current intput.
  12245. * @returns the class name
  12246. */
  12247. getClassName(): string;
  12248. /**
  12249. * Get the friendly name associated with the input class.
  12250. * @returns the input friendly name
  12251. */
  12252. getSimpleName(): string;
  12253. }
  12254. }
  12255. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  12256. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12257. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  12258. /**
  12259. * Default Inputs manager for the FreeCamera.
  12260. * It groups all the default supported inputs for ease of use.
  12261. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12262. */
  12263. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12264. /**
  12265. * Instantiates a new FreeCameraInputsManager.
  12266. * @param camera Defines the camera the inputs belong to
  12267. */
  12268. constructor(camera: FreeCamera);
  12269. /**
  12270. * Add keyboard input support to the input manager.
  12271. * @returns the current input manager
  12272. */
  12273. addKeyboard(): FreeCameraInputsManager;
  12274. /**
  12275. * Add mouse input support to the input manager.
  12276. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12277. * @returns the current input manager
  12278. */
  12279. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12280. /**
  12281. * Add touch input support to the input manager.
  12282. * @returns the current input manager
  12283. */
  12284. addTouch(): FreeCameraInputsManager;
  12285. }
  12286. }
  12287. declare module "babylonjs/Cameras/freeCamera" {
  12288. import { Vector3 } from "babylonjs/Maths/math";
  12289. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12290. import { Scene } from "babylonjs/scene";
  12291. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12292. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  12293. /**
  12294. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12295. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12296. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12297. */
  12298. export class FreeCamera extends TargetCamera {
  12299. /**
  12300. * Define the collision ellipsoid of the camera.
  12301. * This is helpful to simulate a camera body like the player body around the camera
  12302. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12303. */
  12304. ellipsoid: Vector3;
  12305. /**
  12306. * Define an offset for the position of the ellipsoid around the camera.
  12307. * This can be helpful to determine the center of the body near the gravity center of the body
  12308. * instead of its head.
  12309. */
  12310. ellipsoidOffset: Vector3;
  12311. /**
  12312. * Enable or disable collisions of the camera with the rest of the scene objects.
  12313. */
  12314. checkCollisions: boolean;
  12315. /**
  12316. * Enable or disable gravity on the camera.
  12317. */
  12318. applyGravity: boolean;
  12319. /**
  12320. * Define the input manager associated to the camera.
  12321. */
  12322. inputs: FreeCameraInputsManager;
  12323. /**
  12324. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12325. * Higher values reduce sensitivity.
  12326. */
  12327. /**
  12328. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12329. * Higher values reduce sensitivity.
  12330. */
  12331. angularSensibility: number;
  12332. /**
  12333. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12334. */
  12335. keysUp: number[];
  12336. /**
  12337. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12338. */
  12339. keysDown: number[];
  12340. /**
  12341. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12342. */
  12343. keysLeft: number[];
  12344. /**
  12345. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12346. */
  12347. keysRight: number[];
  12348. /**
  12349. * Event raised when the camera collide with a mesh in the scene.
  12350. */
  12351. onCollide: (collidedMesh: AbstractMesh) => void;
  12352. private _collider;
  12353. private _needMoveForGravity;
  12354. private _oldPosition;
  12355. private _diffPosition;
  12356. private _newPosition;
  12357. /** @hidden */
  12358. _localDirection: Vector3;
  12359. /** @hidden */
  12360. _transformedDirection: Vector3;
  12361. /**
  12362. * Instantiates a Free Camera.
  12363. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12364. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12365. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12366. * @param name Define the name of the camera in the scene
  12367. * @param position Define the start position of the camera in the scene
  12368. * @param scene Define the scene the camera belongs to
  12369. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12370. */
  12371. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12372. /**
  12373. * Attached controls to the current camera.
  12374. * @param element Defines the element the controls should be listened from
  12375. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12376. */
  12377. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12378. /**
  12379. * Detach the current controls from the camera.
  12380. * The camera will stop reacting to inputs.
  12381. * @param element Defines the element to stop listening the inputs from
  12382. */
  12383. detachControl(element: HTMLElement): void;
  12384. private _collisionMask;
  12385. /**
  12386. * Define a collision mask to limit the list of object the camera can collide with
  12387. */
  12388. collisionMask: number;
  12389. /** @hidden */
  12390. _collideWithWorld(displacement: Vector3): void;
  12391. private _onCollisionPositionChange;
  12392. /** @hidden */
  12393. _checkInputs(): void;
  12394. /** @hidden */
  12395. _decideIfNeedsToMove(): boolean;
  12396. /** @hidden */
  12397. _updatePosition(): void;
  12398. /**
  12399. * Destroy the camera and release the current resources hold by it.
  12400. */
  12401. dispose(): void;
  12402. /**
  12403. * Gets the current object class name.
  12404. * @return the class name
  12405. */
  12406. getClassName(): string;
  12407. }
  12408. }
  12409. declare module "babylonjs/Gamepads/gamepad" {
  12410. import { Observable } from "babylonjs/Misc/observable";
  12411. /**
  12412. * Represents a gamepad control stick position
  12413. */
  12414. export class StickValues {
  12415. /**
  12416. * The x component of the control stick
  12417. */
  12418. x: number;
  12419. /**
  12420. * The y component of the control stick
  12421. */
  12422. y: number;
  12423. /**
  12424. * Initializes the gamepad x and y control stick values
  12425. * @param x The x component of the gamepad control stick value
  12426. * @param y The y component of the gamepad control stick value
  12427. */
  12428. constructor(
  12429. /**
  12430. * The x component of the control stick
  12431. */
  12432. x: number,
  12433. /**
  12434. * The y component of the control stick
  12435. */
  12436. y: number);
  12437. }
  12438. /**
  12439. * An interface which manages callbacks for gamepad button changes
  12440. */
  12441. export interface GamepadButtonChanges {
  12442. /**
  12443. * Called when a gamepad has been changed
  12444. */
  12445. changed: boolean;
  12446. /**
  12447. * Called when a gamepad press event has been triggered
  12448. */
  12449. pressChanged: boolean;
  12450. /**
  12451. * Called when a touch event has been triggered
  12452. */
  12453. touchChanged: boolean;
  12454. /**
  12455. * Called when a value has changed
  12456. */
  12457. valueChanged: boolean;
  12458. }
  12459. /**
  12460. * Represents a gamepad
  12461. */
  12462. export class Gamepad {
  12463. /**
  12464. * The id of the gamepad
  12465. */
  12466. id: string;
  12467. /**
  12468. * The index of the gamepad
  12469. */
  12470. index: number;
  12471. /**
  12472. * The browser gamepad
  12473. */
  12474. browserGamepad: any;
  12475. /**
  12476. * Specifies what type of gamepad this represents
  12477. */
  12478. type: number;
  12479. private _leftStick;
  12480. private _rightStick;
  12481. /** @hidden */
  12482. _isConnected: boolean;
  12483. private _leftStickAxisX;
  12484. private _leftStickAxisY;
  12485. private _rightStickAxisX;
  12486. private _rightStickAxisY;
  12487. /**
  12488. * Triggered when the left control stick has been changed
  12489. */
  12490. private _onleftstickchanged;
  12491. /**
  12492. * Triggered when the right control stick has been changed
  12493. */
  12494. private _onrightstickchanged;
  12495. /**
  12496. * Represents a gamepad controller
  12497. */
  12498. static GAMEPAD: number;
  12499. /**
  12500. * Represents a generic controller
  12501. */
  12502. static GENERIC: number;
  12503. /**
  12504. * Represents an XBox controller
  12505. */
  12506. static XBOX: number;
  12507. /**
  12508. * Represents a pose-enabled controller
  12509. */
  12510. static POSE_ENABLED: number;
  12511. /**
  12512. * Specifies whether the left control stick should be Y-inverted
  12513. */
  12514. protected _invertLeftStickY: boolean;
  12515. /**
  12516. * Specifies if the gamepad has been connected
  12517. */
  12518. readonly isConnected: boolean;
  12519. /**
  12520. * Initializes the gamepad
  12521. * @param id The id of the gamepad
  12522. * @param index The index of the gamepad
  12523. * @param browserGamepad The browser gamepad
  12524. * @param leftStickX The x component of the left joystick
  12525. * @param leftStickY The y component of the left joystick
  12526. * @param rightStickX The x component of the right joystick
  12527. * @param rightStickY The y component of the right joystick
  12528. */
  12529. constructor(
  12530. /**
  12531. * The id of the gamepad
  12532. */
  12533. id: string,
  12534. /**
  12535. * The index of the gamepad
  12536. */
  12537. index: number,
  12538. /**
  12539. * The browser gamepad
  12540. */
  12541. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12542. /**
  12543. * Callback triggered when the left joystick has changed
  12544. * @param callback
  12545. */
  12546. onleftstickchanged(callback: (values: StickValues) => void): void;
  12547. /**
  12548. * Callback triggered when the right joystick has changed
  12549. * @param callback
  12550. */
  12551. onrightstickchanged(callback: (values: StickValues) => void): void;
  12552. /**
  12553. * Gets the left joystick
  12554. */
  12555. /**
  12556. * Sets the left joystick values
  12557. */
  12558. leftStick: StickValues;
  12559. /**
  12560. * Gets the right joystick
  12561. */
  12562. /**
  12563. * Sets the right joystick value
  12564. */
  12565. rightStick: StickValues;
  12566. /**
  12567. * Updates the gamepad joystick positions
  12568. */
  12569. update(): void;
  12570. /**
  12571. * Disposes the gamepad
  12572. */
  12573. dispose(): void;
  12574. }
  12575. /**
  12576. * Represents a generic gamepad
  12577. */
  12578. export class GenericPad extends Gamepad {
  12579. private _buttons;
  12580. private _onbuttondown;
  12581. private _onbuttonup;
  12582. /**
  12583. * Observable triggered when a button has been pressed
  12584. */
  12585. onButtonDownObservable: Observable<number>;
  12586. /**
  12587. * Observable triggered when a button has been released
  12588. */
  12589. onButtonUpObservable: Observable<number>;
  12590. /**
  12591. * Callback triggered when a button has been pressed
  12592. * @param callback Called when a button has been pressed
  12593. */
  12594. onbuttondown(callback: (buttonPressed: number) => void): void;
  12595. /**
  12596. * Callback triggered when a button has been released
  12597. * @param callback Called when a button has been released
  12598. */
  12599. onbuttonup(callback: (buttonReleased: number) => void): void;
  12600. /**
  12601. * Initializes the generic gamepad
  12602. * @param id The id of the generic gamepad
  12603. * @param index The index of the generic gamepad
  12604. * @param browserGamepad The browser gamepad
  12605. */
  12606. constructor(id: string, index: number, browserGamepad: any);
  12607. private _setButtonValue;
  12608. /**
  12609. * Updates the generic gamepad
  12610. */
  12611. update(): void;
  12612. /**
  12613. * Disposes the generic gamepad
  12614. */
  12615. dispose(): void;
  12616. }
  12617. }
  12618. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  12619. import { Observable } from "babylonjs/Misc/observable";
  12620. import { Nullable } from "babylonjs/types";
  12621. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  12622. import { TransformNode } from "babylonjs/Meshes/transformNode";
  12623. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12624. import { Ray } from "babylonjs/Culling/ray";
  12625. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  12626. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  12627. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12628. /**
  12629. * Defines the types of pose enabled controllers that are supported
  12630. */
  12631. export enum PoseEnabledControllerType {
  12632. /**
  12633. * HTC Vive
  12634. */
  12635. VIVE = 0,
  12636. /**
  12637. * Oculus Rift
  12638. */
  12639. OCULUS = 1,
  12640. /**
  12641. * Windows mixed reality
  12642. */
  12643. WINDOWS = 2,
  12644. /**
  12645. * Samsung gear VR
  12646. */
  12647. GEAR_VR = 3,
  12648. /**
  12649. * Google Daydream
  12650. */
  12651. DAYDREAM = 4,
  12652. /**
  12653. * Generic
  12654. */
  12655. GENERIC = 5
  12656. }
  12657. /**
  12658. * Defines the MutableGamepadButton interface for the state of a gamepad button
  12659. */
  12660. export interface MutableGamepadButton {
  12661. /**
  12662. * Value of the button/trigger
  12663. */
  12664. value: number;
  12665. /**
  12666. * If the button/trigger is currently touched
  12667. */
  12668. touched: boolean;
  12669. /**
  12670. * If the button/trigger is currently pressed
  12671. */
  12672. pressed: boolean;
  12673. }
  12674. /**
  12675. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  12676. * @hidden
  12677. */
  12678. export interface ExtendedGamepadButton extends GamepadButton {
  12679. /**
  12680. * If the button/trigger is currently pressed
  12681. */
  12682. readonly pressed: boolean;
  12683. /**
  12684. * If the button/trigger is currently touched
  12685. */
  12686. readonly touched: boolean;
  12687. /**
  12688. * Value of the button/trigger
  12689. */
  12690. readonly value: number;
  12691. }
  12692. /** @hidden */
  12693. export interface _GamePadFactory {
  12694. /**
  12695. * Returns wether or not the current gamepad can be created for this type of controller.
  12696. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  12697. * @returns true if it can be created, otherwise false
  12698. */
  12699. canCreate(gamepadInfo: any): boolean;
  12700. /**
  12701. * Creates a new instance of the Gamepad.
  12702. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  12703. * @returns the new gamepad instance
  12704. */
  12705. create(gamepadInfo: any): Gamepad;
  12706. }
  12707. /**
  12708. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  12709. */
  12710. export class PoseEnabledControllerHelper {
  12711. /** @hidden */
  12712. static _ControllerFactories: _GamePadFactory[];
  12713. /** @hidden */
  12714. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  12715. /**
  12716. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  12717. * @param vrGamepad the gamepad to initialized
  12718. * @returns a vr controller of the type the gamepad identified as
  12719. */
  12720. static InitiateController(vrGamepad: any): Gamepad;
  12721. }
  12722. /**
  12723. * Defines the PoseEnabledController object that contains state of a vr capable controller
  12724. */
  12725. export class PoseEnabledController extends Gamepad implements PoseControlled {
  12726. private _deviceRoomPosition;
  12727. private _deviceRoomRotationQuaternion;
  12728. /**
  12729. * The device position in babylon space
  12730. */
  12731. devicePosition: Vector3;
  12732. /**
  12733. * The device rotation in babylon space
  12734. */
  12735. deviceRotationQuaternion: Quaternion;
  12736. /**
  12737. * The scale factor of the device in babylon space
  12738. */
  12739. deviceScaleFactor: number;
  12740. /**
  12741. * (Likely devicePosition should be used instead) The device position in its room space
  12742. */
  12743. position: Vector3;
  12744. /**
  12745. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  12746. */
  12747. rotationQuaternion: Quaternion;
  12748. /**
  12749. * The type of controller (Eg. Windows mixed reality)
  12750. */
  12751. controllerType: PoseEnabledControllerType;
  12752. protected _calculatedPosition: Vector3;
  12753. private _calculatedRotation;
  12754. /**
  12755. * The raw pose from the device
  12756. */
  12757. rawPose: DevicePose;
  12758. private _trackPosition;
  12759. private _maxRotationDistFromHeadset;
  12760. private _draggedRoomRotation;
  12761. /**
  12762. * @hidden
  12763. */
  12764. _disableTrackPosition(fixedPosition: Vector3): void;
  12765. /**
  12766. * Internal, the mesh attached to the controller
  12767. * @hidden
  12768. */
  12769. _mesh: Nullable<AbstractMesh>;
  12770. private _poseControlledCamera;
  12771. private _leftHandSystemQuaternion;
  12772. /**
  12773. * Internal, matrix used to convert room space to babylon space
  12774. * @hidden
  12775. */
  12776. _deviceToWorld: Matrix;
  12777. /**
  12778. * Node to be used when casting a ray from the controller
  12779. * @hidden
  12780. */
  12781. _pointingPoseNode: Nullable<TransformNode>;
  12782. /**
  12783. * Name of the child mesh that can be used to cast a ray from the controller
  12784. */
  12785. static readonly POINTING_POSE: string;
  12786. /**
  12787. * Creates a new PoseEnabledController from a gamepad
  12788. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  12789. */
  12790. constructor(browserGamepad: any);
  12791. private _workingMatrix;
  12792. /**
  12793. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  12794. */
  12795. update(): void;
  12796. /**
  12797. * Updates only the pose device and mesh without doing any button event checking
  12798. */
  12799. protected _updatePoseAndMesh(): void;
  12800. /**
  12801. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  12802. * @param poseData raw pose fromthe device
  12803. */
  12804. updateFromDevice(poseData: DevicePose): void;
  12805. /**
  12806. * @hidden
  12807. */
  12808. _meshAttachedObservable: Observable<AbstractMesh>;
  12809. /**
  12810. * Attaches a mesh to the controller
  12811. * @param mesh the mesh to be attached
  12812. */
  12813. attachToMesh(mesh: AbstractMesh): void;
  12814. /**
  12815. * Attaches the controllers mesh to a camera
  12816. * @param camera the camera the mesh should be attached to
  12817. */
  12818. attachToPoseControlledCamera(camera: TargetCamera): void;
  12819. /**
  12820. * Disposes of the controller
  12821. */
  12822. dispose(): void;
  12823. /**
  12824. * The mesh that is attached to the controller
  12825. */
  12826. readonly mesh: Nullable<AbstractMesh>;
  12827. /**
  12828. * Gets the ray of the controller in the direction the controller is pointing
  12829. * @param length the length the resulting ray should be
  12830. * @returns a ray in the direction the controller is pointing
  12831. */
  12832. getForwardRay(length?: number): Ray;
  12833. }
  12834. }
  12835. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  12836. import { Observable } from "babylonjs/Misc/observable";
  12837. import { Scene } from "babylonjs/scene";
  12838. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12839. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  12840. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  12841. /**
  12842. * Defines the WebVRController object that represents controllers tracked in 3D space
  12843. */
  12844. export abstract class WebVRController extends PoseEnabledController {
  12845. /**
  12846. * Internal, the default controller model for the controller
  12847. */
  12848. protected _defaultModel: AbstractMesh;
  12849. /**
  12850. * Fired when the trigger state has changed
  12851. */
  12852. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  12853. /**
  12854. * Fired when the main button state has changed
  12855. */
  12856. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  12857. /**
  12858. * Fired when the secondary button state has changed
  12859. */
  12860. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  12861. /**
  12862. * Fired when the pad state has changed
  12863. */
  12864. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  12865. /**
  12866. * Fired when controllers stick values have changed
  12867. */
  12868. onPadValuesChangedObservable: Observable<StickValues>;
  12869. /**
  12870. * Array of button availible on the controller
  12871. */
  12872. protected _buttons: Array<MutableGamepadButton>;
  12873. private _onButtonStateChange;
  12874. /**
  12875. * Fired when a controller button's state has changed
  12876. * @param callback the callback containing the button that was modified
  12877. */
  12878. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  12879. /**
  12880. * X and Y axis corrisponding to the controllers joystick
  12881. */
  12882. pad: StickValues;
  12883. /**
  12884. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  12885. */
  12886. hand: string;
  12887. /**
  12888. * The default controller model for the controller
  12889. */
  12890. readonly defaultModel: AbstractMesh;
  12891. /**
  12892. * Creates a new WebVRController from a gamepad
  12893. * @param vrGamepad the gamepad that the WebVRController should be created from
  12894. */
  12895. constructor(vrGamepad: any);
  12896. /**
  12897. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  12898. */
  12899. update(): void;
  12900. /**
  12901. * Function to be called when a button is modified
  12902. */
  12903. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  12904. /**
  12905. * Loads a mesh and attaches it to the controller
  12906. * @param scene the scene the mesh should be added to
  12907. * @param meshLoaded callback for when the mesh has been loaded
  12908. */
  12909. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  12910. private _setButtonValue;
  12911. private _changes;
  12912. private _checkChanges;
  12913. /**
  12914. * Disposes of th webVRCOntroller
  12915. */
  12916. dispose(): void;
  12917. }
  12918. }
  12919. declare module "babylonjs/Lights/hemisphericLight" {
  12920. import { Nullable } from "babylonjs/types";
  12921. import { Scene } from "babylonjs/scene";
  12922. import { Matrix, Vector3, Color3 } from "babylonjs/Maths/math";
  12923. import { Effect } from "babylonjs/Materials/effect";
  12924. import { Light } from "babylonjs/Lights/light";
  12925. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  12926. /**
  12927. * The HemisphericLight simulates the ambient environment light,
  12928. * so the passed direction is the light reflection direction, not the incoming direction.
  12929. */
  12930. export class HemisphericLight extends Light {
  12931. /**
  12932. * The groundColor is the light in the opposite direction to the one specified during creation.
  12933. * 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.
  12934. */
  12935. groundColor: Color3;
  12936. /**
  12937. * The light reflection direction, not the incoming direction.
  12938. */
  12939. direction: Vector3;
  12940. /**
  12941. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  12942. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  12943. * The HemisphericLight can't cast shadows.
  12944. * Documentation : https://doc.babylonjs.com/babylon101/lights
  12945. * @param name The friendly name of the light
  12946. * @param direction The direction of the light reflection
  12947. * @param scene The scene the light belongs to
  12948. */
  12949. constructor(name: string, direction: Vector3, scene: Scene);
  12950. protected _buildUniformLayout(): void;
  12951. /**
  12952. * Returns the string "HemisphericLight".
  12953. * @return The class name
  12954. */
  12955. getClassName(): string;
  12956. /**
  12957. * Sets the HemisphericLight direction towards the passed target (Vector3).
  12958. * Returns the updated direction.
  12959. * @param target The target the direction should point to
  12960. * @return The computed direction
  12961. */
  12962. setDirectionToTarget(target: Vector3): Vector3;
  12963. /**
  12964. * Returns the shadow generator associated to the light.
  12965. * @returns Always null for hemispheric lights because it does not support shadows.
  12966. */
  12967. getShadowGenerator(): Nullable<IShadowGenerator>;
  12968. /**
  12969. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  12970. * @param effect The effect to update
  12971. * @param lightIndex The index of the light in the effect to update
  12972. * @returns The hemispheric light
  12973. */
  12974. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  12975. /**
  12976. * Computes the world matrix of the node
  12977. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  12978. * @param useWasUpdatedFlag defines a reserved property
  12979. * @returns the world matrix
  12980. */
  12981. computeWorldMatrix(): Matrix;
  12982. /**
  12983. * Returns the integer 3.
  12984. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  12985. */
  12986. getTypeID(): number;
  12987. /**
  12988. * Prepares the list of defines specific to the light type.
  12989. * @param defines the list of defines
  12990. * @param lightIndex defines the index of the light for the effect
  12991. */
  12992. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  12993. }
  12994. }
  12995. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  12996. declare module "babylonjs/Cameras/VR/webVRCamera" {
  12997. import { Nullable } from "babylonjs/types";
  12998. import { Observable } from "babylonjs/Misc/observable";
  12999. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  13000. import { Scene } from "babylonjs/scene";
  13001. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  13002. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  13003. import { Node } from "babylonjs/node";
  13004. import { Ray } from "babylonjs/Culling/ray";
  13005. import "babylonjs/Cameras/RigModes/webVRRigMode";
  13006. /**
  13007. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  13008. * IMPORTANT!! The data is right-hand data.
  13009. * @export
  13010. * @interface DevicePose
  13011. */
  13012. export interface DevicePose {
  13013. /**
  13014. * The position of the device, values in array are [x,y,z].
  13015. */
  13016. readonly position: Nullable<Float32Array>;
  13017. /**
  13018. * The linearVelocity of the device, values in array are [x,y,z].
  13019. */
  13020. readonly linearVelocity: Nullable<Float32Array>;
  13021. /**
  13022. * The linearAcceleration of the device, values in array are [x,y,z].
  13023. */
  13024. readonly linearAcceleration: Nullable<Float32Array>;
  13025. /**
  13026. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  13027. */
  13028. readonly orientation: Nullable<Float32Array>;
  13029. /**
  13030. * The angularVelocity of the device, values in array are [x,y,z].
  13031. */
  13032. readonly angularVelocity: Nullable<Float32Array>;
  13033. /**
  13034. * The angularAcceleration of the device, values in array are [x,y,z].
  13035. */
  13036. readonly angularAcceleration: Nullable<Float32Array>;
  13037. }
  13038. /**
  13039. * Interface representing a pose controlled object in Babylon.
  13040. * A pose controlled object has both regular pose values as well as pose values
  13041. * from an external device such as a VR head mounted display
  13042. */
  13043. export interface PoseControlled {
  13044. /**
  13045. * The position of the object in babylon space.
  13046. */
  13047. position: Vector3;
  13048. /**
  13049. * The rotation quaternion of the object in babylon space.
  13050. */
  13051. rotationQuaternion: Quaternion;
  13052. /**
  13053. * The position of the device in babylon space.
  13054. */
  13055. devicePosition?: Vector3;
  13056. /**
  13057. * The rotation quaternion of the device in babylon space.
  13058. */
  13059. deviceRotationQuaternion: Quaternion;
  13060. /**
  13061. * The raw pose coming from the device.
  13062. */
  13063. rawPose: Nullable<DevicePose>;
  13064. /**
  13065. * The scale of the device to be used when translating from device space to babylon space.
  13066. */
  13067. deviceScaleFactor: number;
  13068. /**
  13069. * Updates the poseControlled values based on the input device pose.
  13070. * @param poseData the pose data to update the object with
  13071. */
  13072. updateFromDevice(poseData: DevicePose): void;
  13073. }
  13074. /**
  13075. * Set of options to customize the webVRCamera
  13076. */
  13077. export interface WebVROptions {
  13078. /**
  13079. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  13080. */
  13081. trackPosition?: boolean;
  13082. /**
  13083. * Sets the scale of the vrDevice in babylon space. (default: 1)
  13084. */
  13085. positionScale?: number;
  13086. /**
  13087. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  13088. */
  13089. displayName?: string;
  13090. /**
  13091. * Should the native controller meshes be initialized. (default: true)
  13092. */
  13093. controllerMeshes?: boolean;
  13094. /**
  13095. * Creating a default HemiLight only on controllers. (default: true)
  13096. */
  13097. defaultLightingOnControllers?: boolean;
  13098. /**
  13099. * If you don't want to use the default VR button of the helper. (default: false)
  13100. */
  13101. useCustomVRButton?: boolean;
  13102. /**
  13103. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  13104. */
  13105. customVRButton?: HTMLButtonElement;
  13106. /**
  13107. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  13108. */
  13109. rayLength?: number;
  13110. /**
  13111. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  13112. */
  13113. defaultHeight?: number;
  13114. }
  13115. /**
  13116. * This represents a WebVR camera.
  13117. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  13118. * @example http://doc.babylonjs.com/how_to/webvr_camera
  13119. */
  13120. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  13121. private webVROptions;
  13122. /**
  13123. * @hidden
  13124. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  13125. */
  13126. _vrDevice: any;
  13127. /**
  13128. * The rawPose of the vrDevice.
  13129. */
  13130. rawPose: Nullable<DevicePose>;
  13131. private _onVREnabled;
  13132. private _specsVersion;
  13133. private _attached;
  13134. private _frameData;
  13135. protected _descendants: Array<Node>;
  13136. private _deviceRoomPosition;
  13137. /** @hidden */
  13138. _deviceRoomRotationQuaternion: Quaternion;
  13139. private _standingMatrix;
  13140. /**
  13141. * Represents device position in babylon space.
  13142. */
  13143. devicePosition: Vector3;
  13144. /**
  13145. * Represents device rotation in babylon space.
  13146. */
  13147. deviceRotationQuaternion: Quaternion;
  13148. /**
  13149. * The scale of the device to be used when translating from device space to babylon space.
  13150. */
  13151. deviceScaleFactor: number;
  13152. private _deviceToWorld;
  13153. private _worldToDevice;
  13154. /**
  13155. * References to the webVR controllers for the vrDevice.
  13156. */
  13157. controllers: Array<WebVRController>;
  13158. /**
  13159. * Emits an event when a controller is attached.
  13160. */
  13161. onControllersAttachedObservable: Observable<WebVRController[]>;
  13162. /**
  13163. * Emits an event when a controller's mesh has been loaded;
  13164. */
  13165. onControllerMeshLoadedObservable: Observable<WebVRController>;
  13166. /**
  13167. * Emits an event when the HMD's pose has been updated.
  13168. */
  13169. onPoseUpdatedFromDeviceObservable: Observable<any>;
  13170. private _poseSet;
  13171. /**
  13172. * If the rig cameras be used as parent instead of this camera.
  13173. */
  13174. rigParenting: boolean;
  13175. private _lightOnControllers;
  13176. private _defaultHeight?;
  13177. /**
  13178. * Instantiates a WebVRFreeCamera.
  13179. * @param name The name of the WebVRFreeCamera
  13180. * @param position The starting anchor position for the camera
  13181. * @param scene The scene the camera belongs to
  13182. * @param webVROptions a set of customizable options for the webVRCamera
  13183. */
  13184. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  13185. /**
  13186. * Gets the device distance from the ground in meters.
  13187. * @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.
  13188. */
  13189. deviceDistanceToRoomGround(): number;
  13190. /**
  13191. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  13192. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  13193. */
  13194. useStandingMatrix(callback?: (bool: boolean) => void): void;
  13195. /**
  13196. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  13197. * @returns A promise with a boolean set to if the standing matrix is supported.
  13198. */
  13199. useStandingMatrixAsync(): Promise<boolean>;
  13200. /**
  13201. * Disposes the camera
  13202. */
  13203. dispose(): void;
  13204. /**
  13205. * Gets a vrController by name.
  13206. * @param name The name of the controller to retreive
  13207. * @returns the controller matching the name specified or null if not found
  13208. */
  13209. getControllerByName(name: string): Nullable<WebVRController>;
  13210. private _leftController;
  13211. /**
  13212. * The controller corrisponding to the users left hand.
  13213. */
  13214. readonly leftController: Nullable<WebVRController>;
  13215. private _rightController;
  13216. /**
  13217. * The controller corrisponding to the users right hand.
  13218. */
  13219. readonly rightController: Nullable<WebVRController>;
  13220. /**
  13221. * Casts a ray forward from the vrCamera's gaze.
  13222. * @param length Length of the ray (default: 100)
  13223. * @returns the ray corrisponding to the gaze
  13224. */
  13225. getForwardRay(length?: number): Ray;
  13226. /**
  13227. * @hidden
  13228. * Updates the camera based on device's frame data
  13229. */
  13230. _checkInputs(): void;
  13231. /**
  13232. * Updates the poseControlled values based on the input device pose.
  13233. * @param poseData Pose coming from the device
  13234. */
  13235. updateFromDevice(poseData: DevicePose): void;
  13236. private _htmlElementAttached;
  13237. private _detachIfAttached;
  13238. /**
  13239. * WebVR's attach control will start broadcasting frames to the device.
  13240. * Note that in certain browsers (chrome for example) this function must be called
  13241. * within a user-interaction callback. Example:
  13242. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  13243. *
  13244. * @param element html element to attach the vrDevice to
  13245. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  13246. */
  13247. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  13248. /**
  13249. * Detaches the camera from the html element and disables VR
  13250. *
  13251. * @param element html element to detach from
  13252. */
  13253. detachControl(element: HTMLElement): void;
  13254. /**
  13255. * @returns the name of this class
  13256. */
  13257. getClassName(): string;
  13258. /**
  13259. * Calls resetPose on the vrDisplay
  13260. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  13261. */
  13262. resetToCurrentRotation(): void;
  13263. /**
  13264. * @hidden
  13265. * Updates the rig cameras (left and right eye)
  13266. */
  13267. _updateRigCameras(): void;
  13268. private _workingVector;
  13269. private _oneVector;
  13270. private _workingMatrix;
  13271. private updateCacheCalled;
  13272. private _correctPositionIfNotTrackPosition;
  13273. /**
  13274. * @hidden
  13275. * Updates the cached values of the camera
  13276. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  13277. */
  13278. _updateCache(ignoreParentClass?: boolean): void;
  13279. /**
  13280. * @hidden
  13281. * Get current device position in babylon world
  13282. */
  13283. _computeDevicePosition(): void;
  13284. /**
  13285. * Updates the current device position and rotation in the babylon world
  13286. */
  13287. update(): void;
  13288. /**
  13289. * @hidden
  13290. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  13291. * @returns an identity matrix
  13292. */
  13293. _getViewMatrix(): Matrix;
  13294. private _tmpMatrix;
  13295. /**
  13296. * This function is called by the two RIG cameras.
  13297. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  13298. * @hidden
  13299. */
  13300. _getWebVRViewMatrix(): Matrix;
  13301. /** @hidden */
  13302. _getWebVRProjectionMatrix(): Matrix;
  13303. private _onGamepadConnectedObserver;
  13304. private _onGamepadDisconnectedObserver;
  13305. private _updateCacheWhenTrackingDisabledObserver;
  13306. /**
  13307. * Initializes the controllers and their meshes
  13308. */
  13309. initControllers(): void;
  13310. }
  13311. }
  13312. declare module "babylonjs/PostProcesses/postProcess" {
  13313. import { Nullable } from "babylonjs/types";
  13314. import { SmartArray } from "babylonjs/Misc/smartArray";
  13315. import { Observable } from "babylonjs/Misc/observable";
  13316. import { Color4, Vector2 } from "babylonjs/Maths/math";
  13317. import { Camera } from "babylonjs/Cameras/camera";
  13318. import { Effect } from "babylonjs/Materials/effect";
  13319. import "babylonjs/Shaders/postprocess.vertex";
  13320. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  13321. import { Engine } from "babylonjs/Engines/engine";
  13322. /**
  13323. * Size options for a post process
  13324. */
  13325. export type PostProcessOptions = {
  13326. width: number;
  13327. height: number;
  13328. };
  13329. /**
  13330. * PostProcess can be used to apply a shader to a texture after it has been rendered
  13331. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  13332. */
  13333. export class PostProcess {
  13334. /** Name of the PostProcess. */
  13335. name: string;
  13336. /**
  13337. * Gets or sets the unique id of the post process
  13338. */
  13339. uniqueId: number;
  13340. /**
  13341. * Width of the texture to apply the post process on
  13342. */
  13343. width: number;
  13344. /**
  13345. * Height of the texture to apply the post process on
  13346. */
  13347. height: number;
  13348. /**
  13349. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  13350. * @hidden
  13351. */
  13352. _outputTexture: Nullable<InternalTexture>;
  13353. /**
  13354. * Sampling mode used by the shader
  13355. * See https://doc.babylonjs.com/classes/3.1/texture
  13356. */
  13357. renderTargetSamplingMode: number;
  13358. /**
  13359. * Clear color to use when screen clearing
  13360. */
  13361. clearColor: Color4;
  13362. /**
  13363. * If the buffer needs to be cleared before applying the post process. (default: true)
  13364. * Should be set to false if shader will overwrite all previous pixels.
  13365. */
  13366. autoClear: boolean;
  13367. /**
  13368. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  13369. */
  13370. alphaMode: number;
  13371. /**
  13372. * Sets the setAlphaBlendConstants of the babylon engine
  13373. */
  13374. alphaConstants: Color4;
  13375. /**
  13376. * Animations to be used for the post processing
  13377. */
  13378. animations: import("babylonjs/Animations/animation").Animation[];
  13379. /**
  13380. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  13381. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  13382. */
  13383. enablePixelPerfectMode: boolean;
  13384. /**
  13385. * Force the postprocess to be applied without taking in account viewport
  13386. */
  13387. forceFullscreenViewport: boolean;
  13388. /**
  13389. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  13390. *
  13391. * | Value | Type | Description |
  13392. * | ----- | ----------------------------------- | ----------- |
  13393. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  13394. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  13395. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  13396. *
  13397. */
  13398. scaleMode: number;
  13399. /**
  13400. * Force textures to be a power of two (default: false)
  13401. */
  13402. alwaysForcePOT: boolean;
  13403. private _samples;
  13404. /**
  13405. * Number of sample textures (default: 1)
  13406. */
  13407. samples: number;
  13408. /**
  13409. * Modify the scale of the post process to be the same as the viewport (default: false)
  13410. */
  13411. adaptScaleToCurrentViewport: boolean;
  13412. private _camera;
  13413. private _scene;
  13414. private _engine;
  13415. private _options;
  13416. private _reusable;
  13417. private _textureType;
  13418. /**
  13419. * Smart array of input and output textures for the post process.
  13420. * @hidden
  13421. */
  13422. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  13423. /**
  13424. * The index in _textures that corresponds to the output texture.
  13425. * @hidden
  13426. */
  13427. _currentRenderTextureInd: number;
  13428. private _effect;
  13429. private _samplers;
  13430. private _fragmentUrl;
  13431. private _vertexUrl;
  13432. private _parameters;
  13433. private _scaleRatio;
  13434. protected _indexParameters: any;
  13435. private _shareOutputWithPostProcess;
  13436. private _texelSize;
  13437. private _forcedOutputTexture;
  13438. /**
  13439. * Returns the fragment url or shader name used in the post process.
  13440. * @returns the fragment url or name in the shader store.
  13441. */
  13442. getEffectName(): string;
  13443. /**
  13444. * An event triggered when the postprocess is activated.
  13445. */
  13446. onActivateObservable: Observable<Camera>;
  13447. private _onActivateObserver;
  13448. /**
  13449. * A function that is added to the onActivateObservable
  13450. */
  13451. onActivate: Nullable<(camera: Camera) => void>;
  13452. /**
  13453. * An event triggered when the postprocess changes its size.
  13454. */
  13455. onSizeChangedObservable: Observable<PostProcess>;
  13456. private _onSizeChangedObserver;
  13457. /**
  13458. * A function that is added to the onSizeChangedObservable
  13459. */
  13460. onSizeChanged: (postProcess: PostProcess) => void;
  13461. /**
  13462. * An event triggered when the postprocess applies its effect.
  13463. */
  13464. onApplyObservable: Observable<Effect>;
  13465. private _onApplyObserver;
  13466. /**
  13467. * A function that is added to the onApplyObservable
  13468. */
  13469. onApply: (effect: Effect) => void;
  13470. /**
  13471. * An event triggered before rendering the postprocess
  13472. */
  13473. onBeforeRenderObservable: Observable<Effect>;
  13474. private _onBeforeRenderObserver;
  13475. /**
  13476. * A function that is added to the onBeforeRenderObservable
  13477. */
  13478. onBeforeRender: (effect: Effect) => void;
  13479. /**
  13480. * An event triggered after rendering the postprocess
  13481. */
  13482. onAfterRenderObservable: Observable<Effect>;
  13483. private _onAfterRenderObserver;
  13484. /**
  13485. * A function that is added to the onAfterRenderObservable
  13486. */
  13487. onAfterRender: (efect: Effect) => void;
  13488. /**
  13489. * 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
  13490. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  13491. */
  13492. inputTexture: InternalTexture;
  13493. /**
  13494. * Gets the camera which post process is applied to.
  13495. * @returns The camera the post process is applied to.
  13496. */
  13497. getCamera(): Camera;
  13498. /**
  13499. * Gets the texel size of the postprocess.
  13500. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  13501. */
  13502. readonly texelSize: Vector2;
  13503. /**
  13504. * Creates a new instance PostProcess
  13505. * @param name The name of the PostProcess.
  13506. * @param fragmentUrl The url of the fragment shader to be used.
  13507. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  13508. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  13509. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  13510. * @param camera The camera to apply the render pass to.
  13511. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  13512. * @param engine The engine which the post process will be applied. (default: current engine)
  13513. * @param reusable If the post process can be reused on the same frame. (default: false)
  13514. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  13515. * @param textureType Type of textures used when performing the post process. (default: 0)
  13516. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  13517. * @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
  13518. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  13519. */
  13520. constructor(
  13521. /** Name of the PostProcess. */
  13522. 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);
  13523. /**
  13524. * Gets a string idenfifying the name of the class
  13525. * @returns "PostProcess" string
  13526. */
  13527. getClassName(): string;
  13528. /**
  13529. * Gets the engine which this post process belongs to.
  13530. * @returns The engine the post process was enabled with.
  13531. */
  13532. getEngine(): Engine;
  13533. /**
  13534. * The effect that is created when initializing the post process.
  13535. * @returns The created effect corrisponding the the postprocess.
  13536. */
  13537. getEffect(): Effect;
  13538. /**
  13539. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  13540. * @param postProcess The post process to share the output with.
  13541. * @returns This post process.
  13542. */
  13543. shareOutputWith(postProcess: PostProcess): PostProcess;
  13544. /**
  13545. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  13546. * This should be called if the post process that shares output with this post process is disabled/disposed.
  13547. */
  13548. useOwnOutput(): void;
  13549. /**
  13550. * Updates the effect with the current post process compile time values and recompiles the shader.
  13551. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  13552. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  13553. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  13554. * @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
  13555. * @param onCompiled Called when the shader has been compiled.
  13556. * @param onError Called if there is an error when compiling a shader.
  13557. */
  13558. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  13559. /**
  13560. * The post process is reusable if it can be used multiple times within one frame.
  13561. * @returns If the post process is reusable
  13562. */
  13563. isReusable(): boolean;
  13564. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  13565. markTextureDirty(): void;
  13566. /**
  13567. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  13568. * 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.
  13569. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  13570. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  13571. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  13572. * @returns The target texture that was bound to be written to.
  13573. */
  13574. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  13575. /**
  13576. * If the post process is supported.
  13577. */
  13578. readonly isSupported: boolean;
  13579. /**
  13580. * The aspect ratio of the output texture.
  13581. */
  13582. readonly aspectRatio: number;
  13583. /**
  13584. * Get a value indicating if the post-process is ready to be used
  13585. * @returns true if the post-process is ready (shader is compiled)
  13586. */
  13587. isReady(): boolean;
  13588. /**
  13589. * Binds all textures and uniforms to the shader, this will be run on every pass.
  13590. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  13591. */
  13592. apply(): Nullable<Effect>;
  13593. private _disposeTextures;
  13594. /**
  13595. * Disposes the post process.
  13596. * @param camera The camera to dispose the post process on.
  13597. */
  13598. dispose(camera?: Camera): void;
  13599. }
  13600. }
  13601. declare module "babylonjs/PostProcesses/postProcessManager" {
  13602. import { Nullable } from "babylonjs/types";
  13603. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  13604. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  13605. import { Scene } from "babylonjs/scene";
  13606. /**
  13607. * PostProcessManager is used to manage one or more post processes or post process pipelines
  13608. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  13609. */
  13610. export class PostProcessManager {
  13611. private _scene;
  13612. private _indexBuffer;
  13613. private _vertexBuffers;
  13614. /**
  13615. * Creates a new instance PostProcess
  13616. * @param scene The scene that the post process is associated with.
  13617. */
  13618. constructor(scene: Scene);
  13619. private _prepareBuffers;
  13620. private _buildIndexBuffer;
  13621. /**
  13622. * Rebuilds the vertex buffers of the manager.
  13623. * @hidden
  13624. */
  13625. _rebuild(): void;
  13626. /**
  13627. * Prepares a frame to be run through a post process.
  13628. * @param sourceTexture The input texture to the post procesess. (default: null)
  13629. * @param postProcesses An array of post processes to be run. (default: null)
  13630. * @returns True if the post processes were able to be run.
  13631. * @hidden
  13632. */
  13633. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  13634. /**
  13635. * Manually render a set of post processes to a texture.
  13636. * @param postProcesses An array of post processes to be run.
  13637. * @param targetTexture The target texture to render to.
  13638. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  13639. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  13640. * @param lodLevel defines which lod of the texture to render to
  13641. */
  13642. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  13643. /**
  13644. * Finalize the result of the output of the postprocesses.
  13645. * @param doNotPresent If true the result will not be displayed to the screen.
  13646. * @param targetTexture The target texture to render to.
  13647. * @param faceIndex The index of the face to bind the target texture to.
  13648. * @param postProcesses The array of post processes to render.
  13649. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  13650. * @hidden
  13651. */
  13652. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  13653. /**
  13654. * Disposes of the post process manager.
  13655. */
  13656. dispose(): void;
  13657. }
  13658. }
  13659. declare module "babylonjs/Layers/layerSceneComponent" {
  13660. import { Scene } from "babylonjs/scene";
  13661. import { ISceneComponent } from "babylonjs/sceneComponent";
  13662. import { Layer } from "babylonjs/Layers/layer";
  13663. module "babylonjs/abstractScene" {
  13664. interface AbstractScene {
  13665. /**
  13666. * The list of layers (background and foreground) of the scene
  13667. */
  13668. layers: Array<Layer>;
  13669. }
  13670. }
  13671. /**
  13672. * Defines the layer scene component responsible to manage any layers
  13673. * in a given scene.
  13674. */
  13675. export class LayerSceneComponent implements ISceneComponent {
  13676. /**
  13677. * The component name helpfull to identify the component in the list of scene components.
  13678. */
  13679. readonly name: string;
  13680. /**
  13681. * The scene the component belongs to.
  13682. */
  13683. scene: Scene;
  13684. private _engine;
  13685. /**
  13686. * Creates a new instance of the component for the given scene
  13687. * @param scene Defines the scene to register the component in
  13688. */
  13689. constructor(scene: Scene);
  13690. /**
  13691. * Registers the component in a given scene
  13692. */
  13693. register(): void;
  13694. /**
  13695. * Rebuilds the elements related to this component in case of
  13696. * context lost for instance.
  13697. */
  13698. rebuild(): void;
  13699. /**
  13700. * Disposes the component and the associated ressources.
  13701. */
  13702. dispose(): void;
  13703. private _draw;
  13704. private _drawCameraPredicate;
  13705. private _drawCameraBackground;
  13706. private _drawCameraForeground;
  13707. private _drawRenderTargetPredicate;
  13708. private _drawRenderTargetBackground;
  13709. private _drawRenderTargetForeground;
  13710. }
  13711. }
  13712. declare module "babylonjs/Shaders/layer.fragment" {
  13713. /** @hidden */
  13714. export var layerPixelShader: {
  13715. name: string;
  13716. shader: string;
  13717. };
  13718. }
  13719. declare module "babylonjs/Shaders/layer.vertex" {
  13720. /** @hidden */
  13721. export var layerVertexShader: {
  13722. name: string;
  13723. shader: string;
  13724. };
  13725. }
  13726. declare module "babylonjs/Layers/layer" {
  13727. import { Observable } from "babylonjs/Misc/observable";
  13728. import { Nullable } from "babylonjs/types";
  13729. import { Scene } from "babylonjs/scene";
  13730. import { Vector2, Color4 } from "babylonjs/Maths/math";
  13731. import { Texture } from "babylonjs/Materials/Textures/texture";
  13732. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  13733. import "babylonjs/Shaders/layer.fragment";
  13734. import "babylonjs/Shaders/layer.vertex";
  13735. /**
  13736. * This represents a full screen 2d layer.
  13737. * This can be useful to display a picture in the background of your scene for instance.
  13738. * @see https://www.babylonjs-playground.com/#08A2BS#1
  13739. */
  13740. export class Layer {
  13741. /**
  13742. * Define the name of the layer.
  13743. */
  13744. name: string;
  13745. /**
  13746. * Define the texture the layer should display.
  13747. */
  13748. texture: Nullable<Texture>;
  13749. /**
  13750. * Is the layer in background or foreground.
  13751. */
  13752. isBackground: boolean;
  13753. /**
  13754. * Define the color of the layer (instead of texture).
  13755. */
  13756. color: Color4;
  13757. /**
  13758. * Define the scale of the layer in order to zoom in out of the texture.
  13759. */
  13760. scale: Vector2;
  13761. /**
  13762. * Define an offset for the layer in order to shift the texture.
  13763. */
  13764. offset: Vector2;
  13765. /**
  13766. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  13767. */
  13768. alphaBlendingMode: number;
  13769. /**
  13770. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  13771. * Alpha test will not mix with the background color in case of transparency.
  13772. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  13773. */
  13774. alphaTest: boolean;
  13775. /**
  13776. * Define a mask to restrict the layer to only some of the scene cameras.
  13777. */
  13778. layerMask: number;
  13779. /**
  13780. * Define the list of render target the layer is visible into.
  13781. */
  13782. renderTargetTextures: RenderTargetTexture[];
  13783. /**
  13784. * Define if the layer is only used in renderTarget or if it also
  13785. * renders in the main frame buffer of the canvas.
  13786. */
  13787. renderOnlyInRenderTargetTextures: boolean;
  13788. private _scene;
  13789. private _vertexBuffers;
  13790. private _indexBuffer;
  13791. private _effect;
  13792. private _alphaTestEffect;
  13793. /**
  13794. * An event triggered when the layer is disposed.
  13795. */
  13796. onDisposeObservable: Observable<Layer>;
  13797. private _onDisposeObserver;
  13798. /**
  13799. * Back compatibility with callback before the onDisposeObservable existed.
  13800. * The set callback will be triggered when the layer has been disposed.
  13801. */
  13802. onDispose: () => void;
  13803. /**
  13804. * An event triggered before rendering the scene
  13805. */
  13806. onBeforeRenderObservable: Observable<Layer>;
  13807. private _onBeforeRenderObserver;
  13808. /**
  13809. * Back compatibility with callback before the onBeforeRenderObservable existed.
  13810. * The set callback will be triggered just before rendering the layer.
  13811. */
  13812. onBeforeRender: () => void;
  13813. /**
  13814. * An event triggered after rendering the scene
  13815. */
  13816. onAfterRenderObservable: Observable<Layer>;
  13817. private _onAfterRenderObserver;
  13818. /**
  13819. * Back compatibility with callback before the onAfterRenderObservable existed.
  13820. * The set callback will be triggered just after rendering the layer.
  13821. */
  13822. onAfterRender: () => void;
  13823. /**
  13824. * Instantiates a new layer.
  13825. * This represents a full screen 2d layer.
  13826. * This can be useful to display a picture in the background of your scene for instance.
  13827. * @see https://www.babylonjs-playground.com/#08A2BS#1
  13828. * @param name Define the name of the layer in the scene
  13829. * @param imgUrl Define the url of the texture to display in the layer
  13830. * @param scene Define the scene the layer belongs to
  13831. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  13832. * @param color Defines a color for the layer
  13833. */
  13834. constructor(
  13835. /**
  13836. * Define the name of the layer.
  13837. */
  13838. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  13839. private _createIndexBuffer;
  13840. /** @hidden */
  13841. _rebuild(): void;
  13842. /**
  13843. * Renders the layer in the scene.
  13844. */
  13845. render(): void;
  13846. /**
  13847. * Disposes and releases the associated ressources.
  13848. */
  13849. dispose(): void;
  13850. }
  13851. }
  13852. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  13853. import { Scene } from "babylonjs/scene";
  13854. import { ISceneComponent } from "babylonjs/sceneComponent";
  13855. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  13856. module "babylonjs/abstractScene" {
  13857. interface AbstractScene {
  13858. /**
  13859. * The list of procedural textures added to the scene
  13860. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  13861. */
  13862. proceduralTextures: Array<ProceduralTexture>;
  13863. }
  13864. }
  13865. /**
  13866. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  13867. * in a given scene.
  13868. */
  13869. export class ProceduralTextureSceneComponent implements ISceneComponent {
  13870. /**
  13871. * The component name helpfull to identify the component in the list of scene components.
  13872. */
  13873. readonly name: string;
  13874. /**
  13875. * The scene the component belongs to.
  13876. */
  13877. scene: Scene;
  13878. /**
  13879. * Creates a new instance of the component for the given scene
  13880. * @param scene Defines the scene to register the component in
  13881. */
  13882. constructor(scene: Scene);
  13883. /**
  13884. * Registers the component in a given scene
  13885. */
  13886. register(): void;
  13887. /**
  13888. * Rebuilds the elements related to this component in case of
  13889. * context lost for instance.
  13890. */
  13891. rebuild(): void;
  13892. /**
  13893. * Disposes the component and the associated ressources.
  13894. */
  13895. dispose(): void;
  13896. private _beforeClear;
  13897. }
  13898. }
  13899. declare module "babylonjs/Shaders/procedural.vertex" {
  13900. /** @hidden */
  13901. export var proceduralVertexShader: {
  13902. name: string;
  13903. shader: string;
  13904. };
  13905. }
  13906. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  13907. import { Observable } from "babylonjs/Misc/observable";
  13908. import { Nullable } from "babylonjs/types";
  13909. import { Scene } from "babylonjs/scene";
  13910. import { Matrix, Vector3, Vector2, Color3, Color4 } from "babylonjs/Maths/math";
  13911. import { Effect } from "babylonjs/Materials/effect";
  13912. import { Texture } from "babylonjs/Materials/Textures/texture";
  13913. import "babylonjs/Shaders/procedural.vertex";
  13914. /**
  13915. * 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.
  13916. * This is the base class of any Procedural texture and contains most of the shareable code.
  13917. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  13918. */
  13919. export class ProceduralTexture extends Texture {
  13920. isCube: boolean;
  13921. /**
  13922. * Define if the texture is enabled or not (disabled texture will not render)
  13923. */
  13924. isEnabled: boolean;
  13925. /**
  13926. * Define if the texture must be cleared before rendering (default is true)
  13927. */
  13928. autoClear: boolean;
  13929. /**
  13930. * Callback called when the texture is generated
  13931. */
  13932. onGenerated: () => void;
  13933. /**
  13934. * Event raised when the texture is generated
  13935. */
  13936. onGeneratedObservable: Observable<ProceduralTexture>;
  13937. /** @hidden */
  13938. _generateMipMaps: boolean;
  13939. /** @hidden **/
  13940. _effect: Effect;
  13941. /** @hidden */
  13942. _textures: {
  13943. [key: string]: Texture;
  13944. };
  13945. private _size;
  13946. private _currentRefreshId;
  13947. private _refreshRate;
  13948. private _vertexBuffers;
  13949. private _indexBuffer;
  13950. private _uniforms;
  13951. private _samplers;
  13952. private _fragment;
  13953. private _floats;
  13954. private _ints;
  13955. private _floatsArrays;
  13956. private _colors3;
  13957. private _colors4;
  13958. private _vectors2;
  13959. private _vectors3;
  13960. private _matrices;
  13961. private _fallbackTexture;
  13962. private _fallbackTextureUsed;
  13963. private _engine;
  13964. private _cachedDefines;
  13965. private _contentUpdateId;
  13966. private _contentData;
  13967. /**
  13968. * Instantiates a new procedural texture.
  13969. * 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.
  13970. * This is the base class of any Procedural texture and contains most of the shareable code.
  13971. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  13972. * @param name Define the name of the texture
  13973. * @param size Define the size of the texture to create
  13974. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  13975. * @param scene Define the scene the texture belongs to
  13976. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  13977. * @param generateMipMaps Define if the texture should creates mip maps or not
  13978. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  13979. */
  13980. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  13981. /**
  13982. * The effect that is created when initializing the post process.
  13983. * @returns The created effect corrisponding the the postprocess.
  13984. */
  13985. getEffect(): Effect;
  13986. /**
  13987. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  13988. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  13989. */
  13990. getContent(): Nullable<ArrayBufferView>;
  13991. private _createIndexBuffer;
  13992. /** @hidden */
  13993. _rebuild(): void;
  13994. /**
  13995. * Resets the texture in order to recreate its associated resources.
  13996. * This can be called in case of context loss
  13997. */
  13998. reset(): void;
  13999. protected _getDefines(): string;
  14000. /**
  14001. * Is the texture ready to be used ? (rendered at least once)
  14002. * @returns true if ready, otherwise, false.
  14003. */
  14004. isReady(): boolean;
  14005. /**
  14006. * Resets the refresh counter of the texture and start bak from scratch.
  14007. * Could be useful to regenerate the texture if it is setup to render only once.
  14008. */
  14009. resetRefreshCounter(): void;
  14010. /**
  14011. * Set the fragment shader to use in order to render the texture.
  14012. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  14013. */
  14014. setFragment(fragment: any): void;
  14015. /**
  14016. * Define the refresh rate of the texture or the rendering frequency.
  14017. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  14018. */
  14019. refreshRate: number;
  14020. /** @hidden */
  14021. _shouldRender(): boolean;
  14022. /**
  14023. * Get the size the texture is rendering at.
  14024. * @returns the size (texture is always squared)
  14025. */
  14026. getRenderSize(): number;
  14027. /**
  14028. * Resize the texture to new value.
  14029. * @param size Define the new size the texture should have
  14030. * @param generateMipMaps Define whether the new texture should create mip maps
  14031. */
  14032. resize(size: number, generateMipMaps: boolean): void;
  14033. private _checkUniform;
  14034. /**
  14035. * Set a texture in the shader program used to render.
  14036. * @param name Define the name of the uniform samplers as defined in the shader
  14037. * @param texture Define the texture to bind to this sampler
  14038. * @return the texture itself allowing "fluent" like uniform updates
  14039. */
  14040. setTexture(name: string, texture: Texture): ProceduralTexture;
  14041. /**
  14042. * Set a float in the shader.
  14043. * @param name Define the name of the uniform as defined in the shader
  14044. * @param value Define the value to give to the uniform
  14045. * @return the texture itself allowing "fluent" like uniform updates
  14046. */
  14047. setFloat(name: string, value: number): ProceduralTexture;
  14048. /**
  14049. * Set a int in the shader.
  14050. * @param name Define the name of the uniform as defined in the shader
  14051. * @param value Define the value to give to the uniform
  14052. * @return the texture itself allowing "fluent" like uniform updates
  14053. */
  14054. setInt(name: string, value: number): ProceduralTexture;
  14055. /**
  14056. * Set an array of floats in the shader.
  14057. * @param name Define the name of the uniform as defined in the shader
  14058. * @param value Define the value to give to the uniform
  14059. * @return the texture itself allowing "fluent" like uniform updates
  14060. */
  14061. setFloats(name: string, value: number[]): ProceduralTexture;
  14062. /**
  14063. * Set a vec3 in the shader from a Color3.
  14064. * @param name Define the name of the uniform as defined in the shader
  14065. * @param value Define the value to give to the uniform
  14066. * @return the texture itself allowing "fluent" like uniform updates
  14067. */
  14068. setColor3(name: string, value: Color3): ProceduralTexture;
  14069. /**
  14070. * Set a vec4 in the shader from a Color4.
  14071. * @param name Define the name of the uniform as defined in the shader
  14072. * @param value Define the value to give to the uniform
  14073. * @return the texture itself allowing "fluent" like uniform updates
  14074. */
  14075. setColor4(name: string, value: Color4): ProceduralTexture;
  14076. /**
  14077. * Set a vec2 in the shader from a Vector2.
  14078. * @param name Define the name of the uniform as defined in the shader
  14079. * @param value Define the value to give to the uniform
  14080. * @return the texture itself allowing "fluent" like uniform updates
  14081. */
  14082. setVector2(name: string, value: Vector2): ProceduralTexture;
  14083. /**
  14084. * Set a vec3 in the shader from a Vector3.
  14085. * @param name Define the name of the uniform as defined in the shader
  14086. * @param value Define the value to give to the uniform
  14087. * @return the texture itself allowing "fluent" like uniform updates
  14088. */
  14089. setVector3(name: string, value: Vector3): ProceduralTexture;
  14090. /**
  14091. * Set a mat4 in the shader from a MAtrix.
  14092. * @param name Define the name of the uniform as defined in the shader
  14093. * @param value Define the value to give to the uniform
  14094. * @return the texture itself allowing "fluent" like uniform updates
  14095. */
  14096. setMatrix(name: string, value: Matrix): ProceduralTexture;
  14097. /**
  14098. * Render the texture to its associated render target.
  14099. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  14100. */
  14101. render(useCameraPostProcess?: boolean): void;
  14102. /**
  14103. * Clone the texture.
  14104. * @returns the cloned texture
  14105. */
  14106. clone(): ProceduralTexture;
  14107. /**
  14108. * Dispose the texture and release its asoociated resources.
  14109. */
  14110. dispose(): void;
  14111. }
  14112. }
  14113. declare module "babylonjs/Particles/baseParticleSystem" {
  14114. import { Nullable } from "babylonjs/types";
  14115. import { Color4, Vector2, Vector3 } from "babylonjs/Maths/math";
  14116. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14117. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  14118. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  14119. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  14120. import { Scene } from "babylonjs/scene";
  14121. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/tools";
  14122. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  14123. import { Texture } from "babylonjs/Materials/Textures/texture";
  14124. import { Animation } from "babylonjs/Animations/animation";
  14125. /**
  14126. * This represents the base class for particle system in Babylon.
  14127. * 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.
  14128. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14129. * @example https://doc.babylonjs.com/babylon101/particles
  14130. */
  14131. export class BaseParticleSystem {
  14132. /**
  14133. * Source color is added to the destination color without alpha affecting the result
  14134. */
  14135. static BLENDMODE_ONEONE: number;
  14136. /**
  14137. * Blend current color and particle color using particle’s alpha
  14138. */
  14139. static BLENDMODE_STANDARD: number;
  14140. /**
  14141. * Add current color and particle color multiplied by particle’s alpha
  14142. */
  14143. static BLENDMODE_ADD: number;
  14144. /**
  14145. * Multiply current color with particle color
  14146. */
  14147. static BLENDMODE_MULTIPLY: number;
  14148. /**
  14149. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  14150. */
  14151. static BLENDMODE_MULTIPLYADD: number;
  14152. /**
  14153. * List of animations used by the particle system.
  14154. */
  14155. animations: Animation[];
  14156. /**
  14157. * The id of the Particle system.
  14158. */
  14159. id: string;
  14160. /**
  14161. * The friendly name of the Particle system.
  14162. */
  14163. name: string;
  14164. /**
  14165. * The rendering group used by the Particle system to chose when to render.
  14166. */
  14167. renderingGroupId: number;
  14168. /**
  14169. * The emitter represents the Mesh or position we are attaching the particle system to.
  14170. */
  14171. emitter: Nullable<AbstractMesh | Vector3>;
  14172. /**
  14173. * The maximum number of particles to emit per frame
  14174. */
  14175. emitRate: number;
  14176. /**
  14177. * If you want to launch only a few particles at once, that can be done, as well.
  14178. */
  14179. manualEmitCount: number;
  14180. /**
  14181. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14182. */
  14183. updateSpeed: number;
  14184. /**
  14185. * The amount of time the particle system is running (depends of the overall update speed).
  14186. */
  14187. targetStopDuration: number;
  14188. /**
  14189. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14190. */
  14191. disposeOnStop: boolean;
  14192. /**
  14193. * Minimum power of emitting particles.
  14194. */
  14195. minEmitPower: number;
  14196. /**
  14197. * Maximum power of emitting particles.
  14198. */
  14199. maxEmitPower: number;
  14200. /**
  14201. * Minimum life time of emitting particles.
  14202. */
  14203. minLifeTime: number;
  14204. /**
  14205. * Maximum life time of emitting particles.
  14206. */
  14207. maxLifeTime: number;
  14208. /**
  14209. * Minimum Size of emitting particles.
  14210. */
  14211. minSize: number;
  14212. /**
  14213. * Maximum Size of emitting particles.
  14214. */
  14215. maxSize: number;
  14216. /**
  14217. * Minimum scale of emitting particles on X axis.
  14218. */
  14219. minScaleX: number;
  14220. /**
  14221. * Maximum scale of emitting particles on X axis.
  14222. */
  14223. maxScaleX: number;
  14224. /**
  14225. * Minimum scale of emitting particles on Y axis.
  14226. */
  14227. minScaleY: number;
  14228. /**
  14229. * Maximum scale of emitting particles on Y axis.
  14230. */
  14231. maxScaleY: number;
  14232. /**
  14233. * Gets or sets the minimal initial rotation in radians.
  14234. */
  14235. minInitialRotation: number;
  14236. /**
  14237. * Gets or sets the maximal initial rotation in radians.
  14238. */
  14239. maxInitialRotation: number;
  14240. /**
  14241. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14242. */
  14243. minAngularSpeed: number;
  14244. /**
  14245. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14246. */
  14247. maxAngularSpeed: number;
  14248. /**
  14249. * The texture used to render each particle. (this can be a spritesheet)
  14250. */
  14251. particleTexture: Nullable<Texture>;
  14252. /**
  14253. * The layer mask we are rendering the particles through.
  14254. */
  14255. layerMask: number;
  14256. /**
  14257. * This can help using your own shader to render the particle system.
  14258. * The according effect will be created
  14259. */
  14260. customShader: any;
  14261. /**
  14262. * By default particle system starts as soon as they are created. This prevents the
  14263. * automatic start to happen and let you decide when to start emitting particles.
  14264. */
  14265. preventAutoStart: boolean;
  14266. private _noiseTexture;
  14267. /**
  14268. * Gets or sets a texture used to add random noise to particle positions
  14269. */
  14270. noiseTexture: Nullable<ProceduralTexture>;
  14271. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14272. noiseStrength: Vector3;
  14273. /**
  14274. * Callback triggered when the particle animation is ending.
  14275. */
  14276. onAnimationEnd: Nullable<() => void>;
  14277. /**
  14278. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  14279. */
  14280. blendMode: number;
  14281. /**
  14282. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  14283. * to override the particles.
  14284. */
  14285. forceDepthWrite: boolean;
  14286. /** 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 */
  14287. preWarmCycles: number;
  14288. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  14289. preWarmStepOffset: number;
  14290. /**
  14291. * 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)
  14292. */
  14293. spriteCellChangeSpeed: number;
  14294. /**
  14295. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14296. */
  14297. startSpriteCellID: number;
  14298. /**
  14299. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14300. */
  14301. endSpriteCellID: number;
  14302. /**
  14303. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14304. */
  14305. spriteCellWidth: number;
  14306. /**
  14307. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14308. */
  14309. spriteCellHeight: number;
  14310. /**
  14311. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14312. */
  14313. spriteRandomStartCell: boolean;
  14314. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14315. translationPivot: Vector2;
  14316. /** @hidden */
  14317. protected _isAnimationSheetEnabled: boolean;
  14318. /**
  14319. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14320. */
  14321. beginAnimationOnStart: boolean;
  14322. /**
  14323. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14324. */
  14325. beginAnimationFrom: number;
  14326. /**
  14327. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14328. */
  14329. beginAnimationTo: number;
  14330. /**
  14331. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14332. */
  14333. beginAnimationLoop: boolean;
  14334. /**
  14335. * Gets or sets a world offset applied to all particles
  14336. */
  14337. worldOffset: Vector3;
  14338. /**
  14339. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  14340. */
  14341. isAnimationSheetEnabled: boolean;
  14342. /**
  14343. * Get hosting scene
  14344. * @returns the scene
  14345. */
  14346. getScene(): Scene;
  14347. /**
  14348. * You can use gravity if you want to give an orientation to your particles.
  14349. */
  14350. gravity: Vector3;
  14351. protected _colorGradients: Nullable<Array<ColorGradient>>;
  14352. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  14353. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  14354. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  14355. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  14356. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  14357. protected _dragGradients: Nullable<Array<FactorGradient>>;
  14358. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  14359. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  14360. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  14361. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  14362. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  14363. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  14364. /**
  14365. * Defines the delay in milliseconds before starting the system (0 by default)
  14366. */
  14367. startDelay: number;
  14368. /**
  14369. * Gets the current list of drag gradients.
  14370. * You must use addDragGradient and removeDragGradient to udpate this list
  14371. * @returns the list of drag gradients
  14372. */
  14373. getDragGradients(): Nullable<Array<FactorGradient>>;
  14374. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14375. limitVelocityDamping: number;
  14376. /**
  14377. * Gets the current list of limit velocity gradients.
  14378. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14379. * @returns the list of limit velocity gradients
  14380. */
  14381. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14382. /**
  14383. * Gets the current list of color gradients.
  14384. * You must use addColorGradient and removeColorGradient to udpate this list
  14385. * @returns the list of color gradients
  14386. */
  14387. getColorGradients(): Nullable<Array<ColorGradient>>;
  14388. /**
  14389. * Gets the current list of size gradients.
  14390. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14391. * @returns the list of size gradients
  14392. */
  14393. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14394. /**
  14395. * Gets the current list of color remap gradients.
  14396. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14397. * @returns the list of color remap gradients
  14398. */
  14399. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14400. /**
  14401. * Gets the current list of alpha remap gradients.
  14402. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14403. * @returns the list of alpha remap gradients
  14404. */
  14405. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14406. /**
  14407. * Gets the current list of life time gradients.
  14408. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14409. * @returns the list of life time gradients
  14410. */
  14411. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14412. /**
  14413. * Gets the current list of angular speed gradients.
  14414. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14415. * @returns the list of angular speed gradients
  14416. */
  14417. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14418. /**
  14419. * Gets the current list of velocity gradients.
  14420. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14421. * @returns the list of velocity gradients
  14422. */
  14423. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14424. /**
  14425. * Gets the current list of start size gradients.
  14426. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14427. * @returns the list of start size gradients
  14428. */
  14429. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14430. /**
  14431. * Gets the current list of emit rate gradients.
  14432. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14433. * @returns the list of emit rate gradients
  14434. */
  14435. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14436. /**
  14437. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14438. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14439. */
  14440. direction1: Vector3;
  14441. /**
  14442. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14443. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14444. */
  14445. direction2: Vector3;
  14446. /**
  14447. * 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.
  14448. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14449. */
  14450. minEmitBox: Vector3;
  14451. /**
  14452. * 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.
  14453. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14454. */
  14455. maxEmitBox: Vector3;
  14456. /**
  14457. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14458. */
  14459. color1: Color4;
  14460. /**
  14461. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14462. */
  14463. color2: Color4;
  14464. /**
  14465. * Color the particle will have at the end of its lifetime
  14466. */
  14467. colorDead: Color4;
  14468. /**
  14469. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  14470. */
  14471. textureMask: Color4;
  14472. /**
  14473. * The particle emitter type defines the emitter used by the particle system.
  14474. * It can be for example box, sphere, or cone...
  14475. */
  14476. particleEmitterType: IParticleEmitterType;
  14477. /** @hidden */
  14478. _isSubEmitter: boolean;
  14479. /**
  14480. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14481. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14482. */
  14483. billboardMode: number;
  14484. protected _isBillboardBased: boolean;
  14485. /**
  14486. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  14487. */
  14488. isBillboardBased: boolean;
  14489. /**
  14490. * The scene the particle system belongs to.
  14491. */
  14492. protected _scene: Scene;
  14493. /**
  14494. * Local cache of defines for image processing.
  14495. */
  14496. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  14497. /**
  14498. * Default configuration related to image processing available in the standard Material.
  14499. */
  14500. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  14501. /**
  14502. * Gets the image processing configuration used either in this material.
  14503. */
  14504. /**
  14505. * Sets the Default image processing configuration used either in the this material.
  14506. *
  14507. * If sets to null, the scene one is in use.
  14508. */
  14509. imageProcessingConfiguration: ImageProcessingConfiguration;
  14510. /**
  14511. * Attaches a new image processing configuration to the Standard Material.
  14512. * @param configuration
  14513. */
  14514. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  14515. /** @hidden */
  14516. protected _reset(): void;
  14517. /** @hidden */
  14518. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  14519. /**
  14520. * Instantiates a particle system.
  14521. * 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.
  14522. * @param name The name of the particle system
  14523. */
  14524. constructor(name: string);
  14525. /**
  14526. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14527. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14528. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14529. * @returns the emitter
  14530. */
  14531. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14532. /**
  14533. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14534. * @param radius The radius of the hemisphere to emit from
  14535. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14536. * @returns the emitter
  14537. */
  14538. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  14539. /**
  14540. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14541. * @param radius The radius of the sphere to emit from
  14542. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14543. * @returns the emitter
  14544. */
  14545. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  14546. /**
  14547. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  14548. * @param radius The radius of the sphere to emit from
  14549. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  14550. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  14551. * @returns the emitter
  14552. */
  14553. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  14554. /**
  14555. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  14556. * @param radius The radius of the emission cylinder
  14557. * @param height The height of the emission cylinder
  14558. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  14559. * @param directionRandomizer How much to randomize the particle direction [0-1]
  14560. * @returns the emitter
  14561. */
  14562. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  14563. /**
  14564. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  14565. * @param radius The radius of the cylinder to emit from
  14566. * @param height The height of the emission cylinder
  14567. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14568. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  14569. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  14570. * @returns the emitter
  14571. */
  14572. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  14573. /**
  14574. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  14575. * @param radius The radius of the cone to emit from
  14576. * @param angle The base angle of the cone
  14577. * @returns the emitter
  14578. */
  14579. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  14580. /**
  14581. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  14582. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14583. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14584. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14585. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14586. * @returns the emitter
  14587. */
  14588. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  14589. }
  14590. }
  14591. declare module "babylonjs/Particles/subEmitter" {
  14592. import { Scene } from "babylonjs/scene";
  14593. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  14594. /**
  14595. * Type of sub emitter
  14596. */
  14597. export enum SubEmitterType {
  14598. /**
  14599. * Attached to the particle over it's lifetime
  14600. */
  14601. ATTACHED = 0,
  14602. /**
  14603. * Created when the particle dies
  14604. */
  14605. END = 1
  14606. }
  14607. /**
  14608. * Sub emitter class used to emit particles from an existing particle
  14609. */
  14610. export class SubEmitter {
  14611. /**
  14612. * the particle system to be used by the sub emitter
  14613. */
  14614. particleSystem: ParticleSystem;
  14615. /**
  14616. * Type of the submitter (Default: END)
  14617. */
  14618. type: SubEmitterType;
  14619. /**
  14620. * 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)
  14621. * Note: This only is supported when using an emitter of type Mesh
  14622. */
  14623. inheritDirection: boolean;
  14624. /**
  14625. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  14626. */
  14627. inheritedVelocityAmount: number;
  14628. /**
  14629. * Creates a sub emitter
  14630. * @param particleSystem the particle system to be used by the sub emitter
  14631. */
  14632. constructor(
  14633. /**
  14634. * the particle system to be used by the sub emitter
  14635. */
  14636. particleSystem: ParticleSystem);
  14637. /**
  14638. * Clones the sub emitter
  14639. * @returns the cloned sub emitter
  14640. */
  14641. clone(): SubEmitter;
  14642. /**
  14643. * Serialize current object to a JSON object
  14644. * @returns the serialized object
  14645. */
  14646. serialize(): any;
  14647. /** @hidden */
  14648. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  14649. /**
  14650. * Creates a new SubEmitter from a serialized JSON version
  14651. * @param serializationObject defines the JSON object to read from
  14652. * @param scene defines the hosting scene
  14653. * @param rootUrl defines the rootUrl for data loading
  14654. * @returns a new SubEmitter
  14655. */
  14656. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  14657. /** Release associated resources */
  14658. dispose(): void;
  14659. }
  14660. }
  14661. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  14662. /** @hidden */
  14663. export var clipPlaneFragmentDeclaration: {
  14664. name: string;
  14665. shader: string;
  14666. };
  14667. }
  14668. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  14669. /** @hidden */
  14670. export var imageProcessingDeclaration: {
  14671. name: string;
  14672. shader: string;
  14673. };
  14674. }
  14675. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  14676. /** @hidden */
  14677. export var imageProcessingFunctions: {
  14678. name: string;
  14679. shader: string;
  14680. };
  14681. }
  14682. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  14683. /** @hidden */
  14684. export var clipPlaneFragment: {
  14685. name: string;
  14686. shader: string;
  14687. };
  14688. }
  14689. declare module "babylonjs/Shaders/particles.fragment" {
  14690. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  14691. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  14692. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  14693. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  14694. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  14695. /** @hidden */
  14696. export var particlesPixelShader: {
  14697. name: string;
  14698. shader: string;
  14699. };
  14700. }
  14701. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  14702. /** @hidden */
  14703. export var clipPlaneVertexDeclaration: {
  14704. name: string;
  14705. shader: string;
  14706. };
  14707. }
  14708. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  14709. /** @hidden */
  14710. export var clipPlaneVertex: {
  14711. name: string;
  14712. shader: string;
  14713. };
  14714. }
  14715. declare module "babylonjs/Shaders/particles.vertex" {
  14716. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  14717. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  14718. /** @hidden */
  14719. export var particlesVertexShader: {
  14720. name: string;
  14721. shader: string;
  14722. };
  14723. }
  14724. declare module "babylonjs/Particles/particleSystem" {
  14725. import { Nullable } from "babylonjs/types";
  14726. import { IAnimatable, FactorGradient, Color3Gradient } from "babylonjs/Misc/tools";
  14727. import { Observable } from "babylonjs/Misc/observable";
  14728. import { Color4, Color3, Vector3, Matrix } from "babylonjs/Maths/math";
  14729. import { Effect } from "babylonjs/Materials/effect";
  14730. import { Scene, IDisposable } from "babylonjs/scene";
  14731. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  14732. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  14733. import { Particle } from "babylonjs/Particles/particle";
  14734. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  14735. import "babylonjs/Shaders/particles.fragment";
  14736. import "babylonjs/Shaders/particles.vertex";
  14737. /**
  14738. * This represents a particle system in Babylon.
  14739. * 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.
  14740. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14741. * @example https://doc.babylonjs.com/babylon101/particles
  14742. */
  14743. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  14744. /**
  14745. * Billboard mode will only apply to Y axis
  14746. */
  14747. static readonly BILLBOARDMODE_Y: number;
  14748. /**
  14749. * Billboard mode will apply to all axes
  14750. */
  14751. static readonly BILLBOARDMODE_ALL: number;
  14752. /**
  14753. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  14754. */
  14755. static readonly BILLBOARDMODE_STRETCHED: number;
  14756. /**
  14757. * This function can be defined to provide custom update for active particles.
  14758. * This function will be called instead of regular update (age, position, color, etc.).
  14759. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  14760. */
  14761. updateFunction: (particles: Particle[]) => void;
  14762. private _emitterWorldMatrix;
  14763. /**
  14764. * This function can be defined to specify initial direction for every new particle.
  14765. * It by default use the emitterType defined function
  14766. */
  14767. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  14768. /**
  14769. * This function can be defined to specify initial position for every new particle.
  14770. * It by default use the emitterType defined function
  14771. */
  14772. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  14773. /**
  14774. * @hidden
  14775. */
  14776. _inheritedVelocityOffset: Vector3;
  14777. /**
  14778. * An event triggered when the system is disposed
  14779. */
  14780. onDisposeObservable: Observable<ParticleSystem>;
  14781. private _onDisposeObserver;
  14782. /**
  14783. * Sets a callback that will be triggered when the system is disposed
  14784. */
  14785. onDispose: () => void;
  14786. private _particles;
  14787. private _epsilon;
  14788. private _capacity;
  14789. private _stockParticles;
  14790. private _newPartsExcess;
  14791. private _vertexData;
  14792. private _vertexBuffer;
  14793. private _vertexBuffers;
  14794. private _spriteBuffer;
  14795. private _indexBuffer;
  14796. private _effect;
  14797. private _customEffect;
  14798. private _cachedDefines;
  14799. private _scaledColorStep;
  14800. private _colorDiff;
  14801. private _scaledDirection;
  14802. private _scaledGravity;
  14803. private _currentRenderId;
  14804. private _alive;
  14805. private _useInstancing;
  14806. private _started;
  14807. private _stopped;
  14808. private _actualFrame;
  14809. private _scaledUpdateSpeed;
  14810. private _vertexBufferSize;
  14811. /** @hidden */
  14812. _currentEmitRateGradient: Nullable<FactorGradient>;
  14813. /** @hidden */
  14814. _currentEmitRate1: number;
  14815. /** @hidden */
  14816. _currentEmitRate2: number;
  14817. /** @hidden */
  14818. _currentStartSizeGradient: Nullable<FactorGradient>;
  14819. /** @hidden */
  14820. _currentStartSize1: number;
  14821. /** @hidden */
  14822. _currentStartSize2: number;
  14823. private readonly _rawTextureWidth;
  14824. private _rampGradientsTexture;
  14825. private _useRampGradients;
  14826. /** Gets or sets a boolean indicating that ramp gradients must be used
  14827. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  14828. */
  14829. useRampGradients: boolean;
  14830. /**
  14831. * 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.
  14832. * 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: [])
  14833. */
  14834. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  14835. private _subEmitters;
  14836. /**
  14837. * @hidden
  14838. * If the particle systems emitter should be disposed when the particle system is disposed
  14839. */
  14840. _disposeEmitterOnDispose: boolean;
  14841. /**
  14842. * The current active Sub-systems, this property is used by the root particle system only.
  14843. */
  14844. activeSubSystems: Array<ParticleSystem>;
  14845. private _rootParticleSystem;
  14846. /**
  14847. * Gets the current list of active particles
  14848. */
  14849. readonly particles: Particle[];
  14850. /**
  14851. * Returns the string "ParticleSystem"
  14852. * @returns a string containing the class name
  14853. */
  14854. getClassName(): string;
  14855. /**
  14856. * Instantiates a particle system.
  14857. * 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.
  14858. * @param name The name of the particle system
  14859. * @param capacity The max number of particles alive at the same time
  14860. * @param scene The scene the particle system belongs to
  14861. * @param customEffect a custom effect used to change the way particles are rendered by default
  14862. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  14863. * @param epsilon Offset used to render the particles
  14864. */
  14865. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  14866. private _addFactorGradient;
  14867. private _removeFactorGradient;
  14868. /**
  14869. * Adds a new life time gradient
  14870. * @param gradient defines the gradient to use (between 0 and 1)
  14871. * @param factor defines the life time factor to affect to the specified gradient
  14872. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14873. * @returns the current particle system
  14874. */
  14875. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14876. /**
  14877. * Remove a specific life time gradient
  14878. * @param gradient defines the gradient to remove
  14879. * @returns the current particle system
  14880. */
  14881. removeLifeTimeGradient(gradient: number): IParticleSystem;
  14882. /**
  14883. * Adds a new size gradient
  14884. * @param gradient defines the gradient to use (between 0 and 1)
  14885. * @param factor defines the size factor to affect to the specified gradient
  14886. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14887. * @returns the current particle system
  14888. */
  14889. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14890. /**
  14891. * Remove a specific size gradient
  14892. * @param gradient defines the gradient to remove
  14893. * @returns the current particle system
  14894. */
  14895. removeSizeGradient(gradient: number): IParticleSystem;
  14896. /**
  14897. * Adds a new color remap gradient
  14898. * @param gradient defines the gradient to use (between 0 and 1)
  14899. * @param min defines the color remap minimal range
  14900. * @param max defines the color remap maximal range
  14901. * @returns the current particle system
  14902. */
  14903. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14904. /**
  14905. * Remove a specific color remap gradient
  14906. * @param gradient defines the gradient to remove
  14907. * @returns the current particle system
  14908. */
  14909. removeColorRemapGradient(gradient: number): IParticleSystem;
  14910. /**
  14911. * Adds a new alpha remap gradient
  14912. * @param gradient defines the gradient to use (between 0 and 1)
  14913. * @param min defines the alpha remap minimal range
  14914. * @param max defines the alpha remap maximal range
  14915. * @returns the current particle system
  14916. */
  14917. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14918. /**
  14919. * Remove a specific alpha remap gradient
  14920. * @param gradient defines the gradient to remove
  14921. * @returns the current particle system
  14922. */
  14923. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  14924. /**
  14925. * Adds a new angular speed gradient
  14926. * @param gradient defines the gradient to use (between 0 and 1)
  14927. * @param factor defines the angular speed to affect to the specified gradient
  14928. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14929. * @returns the current particle system
  14930. */
  14931. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14932. /**
  14933. * Remove a specific angular speed gradient
  14934. * @param gradient defines the gradient to remove
  14935. * @returns the current particle system
  14936. */
  14937. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  14938. /**
  14939. * Adds a new velocity gradient
  14940. * @param gradient defines the gradient to use (between 0 and 1)
  14941. * @param factor defines the velocity to affect to the specified gradient
  14942. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14943. * @returns the current particle system
  14944. */
  14945. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14946. /**
  14947. * Remove a specific velocity gradient
  14948. * @param gradient defines the gradient to remove
  14949. * @returns the current particle system
  14950. */
  14951. removeVelocityGradient(gradient: number): IParticleSystem;
  14952. /**
  14953. * Adds a new limit velocity gradient
  14954. * @param gradient defines the gradient to use (between 0 and 1)
  14955. * @param factor defines the limit velocity value to affect to the specified gradient
  14956. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14957. * @returns the current particle system
  14958. */
  14959. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14960. /**
  14961. * Remove a specific limit velocity gradient
  14962. * @param gradient defines the gradient to remove
  14963. * @returns the current particle system
  14964. */
  14965. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  14966. /**
  14967. * Adds a new drag gradient
  14968. * @param gradient defines the gradient to use (between 0 and 1)
  14969. * @param factor defines the drag value to affect to the specified gradient
  14970. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14971. * @returns the current particle system
  14972. */
  14973. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14974. /**
  14975. * Remove a specific drag gradient
  14976. * @param gradient defines the gradient to remove
  14977. * @returns the current particle system
  14978. */
  14979. removeDragGradient(gradient: number): IParticleSystem;
  14980. /**
  14981. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  14982. * @param gradient defines the gradient to use (between 0 and 1)
  14983. * @param factor defines the emit rate value to affect to the specified gradient
  14984. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14985. * @returns the current particle system
  14986. */
  14987. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14988. /**
  14989. * Remove a specific emit rate gradient
  14990. * @param gradient defines the gradient to remove
  14991. * @returns the current particle system
  14992. */
  14993. removeEmitRateGradient(gradient: number): IParticleSystem;
  14994. /**
  14995. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  14996. * @param gradient defines the gradient to use (between 0 and 1)
  14997. * @param factor defines the start size value to affect to the specified gradient
  14998. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14999. * @returns the current particle system
  15000. */
  15001. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15002. /**
  15003. * Remove a specific start size gradient
  15004. * @param gradient defines the gradient to remove
  15005. * @returns the current particle system
  15006. */
  15007. removeStartSizeGradient(gradient: number): IParticleSystem;
  15008. private _createRampGradientTexture;
  15009. /**
  15010. * Gets the current list of ramp gradients.
  15011. * You must use addRampGradient and removeRampGradient to udpate this list
  15012. * @returns the list of ramp gradients
  15013. */
  15014. getRampGradients(): Nullable<Array<Color3Gradient>>;
  15015. /**
  15016. * Adds a new ramp gradient used to remap particle colors
  15017. * @param gradient defines the gradient to use (between 0 and 1)
  15018. * @param color defines the color to affect to the specified gradient
  15019. * @returns the current particle system
  15020. */
  15021. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  15022. /**
  15023. * Remove a specific ramp gradient
  15024. * @param gradient defines the gradient to remove
  15025. * @returns the current particle system
  15026. */
  15027. removeRampGradient(gradient: number): ParticleSystem;
  15028. /**
  15029. * Adds a new color gradient
  15030. * @param gradient defines the gradient to use (between 0 and 1)
  15031. * @param color1 defines the color to affect to the specified gradient
  15032. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  15033. * @returns this particle system
  15034. */
  15035. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  15036. /**
  15037. * Remove a specific color gradient
  15038. * @param gradient defines the gradient to remove
  15039. * @returns this particle system
  15040. */
  15041. removeColorGradient(gradient: number): IParticleSystem;
  15042. private _fetchR;
  15043. protected _reset(): void;
  15044. private _resetEffect;
  15045. private _createVertexBuffers;
  15046. private _createIndexBuffer;
  15047. /**
  15048. * Gets the maximum number of particles active at the same time.
  15049. * @returns The max number of active particles.
  15050. */
  15051. getCapacity(): number;
  15052. /**
  15053. * Gets whether there are still active particles in the system.
  15054. * @returns True if it is alive, otherwise false.
  15055. */
  15056. isAlive(): boolean;
  15057. /**
  15058. * Gets if the system has been started. (Note: this will still be true after stop is called)
  15059. * @returns True if it has been started, otherwise false.
  15060. */
  15061. isStarted(): boolean;
  15062. private _prepareSubEmitterInternalArray;
  15063. /**
  15064. * Starts the particle system and begins to emit
  15065. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  15066. */
  15067. start(delay?: number): void;
  15068. /**
  15069. * Stops the particle system.
  15070. * @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.
  15071. */
  15072. stop(stopSubEmitters?: boolean): void;
  15073. /**
  15074. * Remove all active particles
  15075. */
  15076. reset(): void;
  15077. /**
  15078. * @hidden (for internal use only)
  15079. */
  15080. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  15081. /**
  15082. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  15083. * Its lifetime will start back at 0.
  15084. */
  15085. recycleParticle: (particle: Particle) => void;
  15086. private _stopSubEmitters;
  15087. private _createParticle;
  15088. private _removeFromRoot;
  15089. private _emitFromParticle;
  15090. private _update;
  15091. /** @hidden */
  15092. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  15093. /** @hidden */
  15094. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  15095. /** @hidden */
  15096. private _getEffect;
  15097. /**
  15098. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  15099. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  15100. */
  15101. animate(preWarmOnly?: boolean): void;
  15102. private _appendParticleVertices;
  15103. /**
  15104. * Rebuilds the particle system.
  15105. */
  15106. rebuild(): void;
  15107. /**
  15108. * Is this system ready to be used/rendered
  15109. * @return true if the system is ready
  15110. */
  15111. isReady(): boolean;
  15112. private _render;
  15113. /**
  15114. * Renders the particle system in its current state.
  15115. * @returns the current number of particles
  15116. */
  15117. render(): number;
  15118. /**
  15119. * Disposes the particle system and free the associated resources
  15120. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  15121. */
  15122. dispose(disposeTexture?: boolean): void;
  15123. /**
  15124. * Clones the particle system.
  15125. * @param name The name of the cloned object
  15126. * @param newEmitter The new emitter to use
  15127. * @returns the cloned particle system
  15128. */
  15129. clone(name: string, newEmitter: any): ParticleSystem;
  15130. /**
  15131. * Serializes the particle system to a JSON object.
  15132. * @returns the JSON object
  15133. */
  15134. serialize(): any;
  15135. /** @hidden */
  15136. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  15137. /** @hidden */
  15138. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  15139. /**
  15140. * Parses a JSON object to create a particle system.
  15141. * @param parsedParticleSystem The JSON object to parse
  15142. * @param scene The scene to create the particle system in
  15143. * @param rootUrl The root url to use to load external dependencies like texture
  15144. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  15145. * @returns the Parsed particle system
  15146. */
  15147. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  15148. }
  15149. }
  15150. declare module "babylonjs/Particles/particle" {
  15151. import { Nullable } from "babylonjs/types";
  15152. import { Color4, Vector2, Vector3, Vector4 } from "babylonjs/Maths/math";
  15153. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  15154. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  15155. import { ColorGradient, FactorGradient } from "babylonjs/Misc/tools";
  15156. /**
  15157. * A particle represents one of the element emitted by a particle system.
  15158. * This is mainly define by its coordinates, direction, velocity and age.
  15159. */
  15160. export class Particle {
  15161. /**
  15162. * The particle system the particle belongs to.
  15163. */
  15164. particleSystem: ParticleSystem;
  15165. private static _Count;
  15166. /**
  15167. * Unique ID of the particle
  15168. */
  15169. id: number;
  15170. /**
  15171. * The world position of the particle in the scene.
  15172. */
  15173. position: Vector3;
  15174. /**
  15175. * The world direction of the particle in the scene.
  15176. */
  15177. direction: Vector3;
  15178. /**
  15179. * The color of the particle.
  15180. */
  15181. color: Color4;
  15182. /**
  15183. * The color change of the particle per step.
  15184. */
  15185. colorStep: Color4;
  15186. /**
  15187. * Defines how long will the life of the particle be.
  15188. */
  15189. lifeTime: number;
  15190. /**
  15191. * The current age of the particle.
  15192. */
  15193. age: number;
  15194. /**
  15195. * The current size of the particle.
  15196. */
  15197. size: number;
  15198. /**
  15199. * The current scale of the particle.
  15200. */
  15201. scale: Vector2;
  15202. /**
  15203. * The current angle of the particle.
  15204. */
  15205. angle: number;
  15206. /**
  15207. * Defines how fast is the angle changing.
  15208. */
  15209. angularSpeed: number;
  15210. /**
  15211. * Defines the cell index used by the particle to be rendered from a sprite.
  15212. */
  15213. cellIndex: number;
  15214. /**
  15215. * The information required to support color remapping
  15216. */
  15217. remapData: Vector4;
  15218. /** @hidden */
  15219. _randomCellOffset?: number;
  15220. /** @hidden */
  15221. _initialDirection: Nullable<Vector3>;
  15222. /** @hidden */
  15223. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  15224. /** @hidden */
  15225. _initialStartSpriteCellID: number;
  15226. /** @hidden */
  15227. _initialEndSpriteCellID: number;
  15228. /** @hidden */
  15229. _currentColorGradient: Nullable<ColorGradient>;
  15230. /** @hidden */
  15231. _currentColor1: Color4;
  15232. /** @hidden */
  15233. _currentColor2: Color4;
  15234. /** @hidden */
  15235. _currentSizeGradient: Nullable<FactorGradient>;
  15236. /** @hidden */
  15237. _currentSize1: number;
  15238. /** @hidden */
  15239. _currentSize2: number;
  15240. /** @hidden */
  15241. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  15242. /** @hidden */
  15243. _currentAngularSpeed1: number;
  15244. /** @hidden */
  15245. _currentAngularSpeed2: number;
  15246. /** @hidden */
  15247. _currentVelocityGradient: Nullable<FactorGradient>;
  15248. /** @hidden */
  15249. _currentVelocity1: number;
  15250. /** @hidden */
  15251. _currentVelocity2: number;
  15252. /** @hidden */
  15253. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  15254. /** @hidden */
  15255. _currentLimitVelocity1: number;
  15256. /** @hidden */
  15257. _currentLimitVelocity2: number;
  15258. /** @hidden */
  15259. _currentDragGradient: Nullable<FactorGradient>;
  15260. /** @hidden */
  15261. _currentDrag1: number;
  15262. /** @hidden */
  15263. _currentDrag2: number;
  15264. /** @hidden */
  15265. _randomNoiseCoordinates1: Vector3;
  15266. /** @hidden */
  15267. _randomNoiseCoordinates2: Vector3;
  15268. /**
  15269. * Creates a new instance Particle
  15270. * @param particleSystem the particle system the particle belongs to
  15271. */
  15272. constructor(
  15273. /**
  15274. * The particle system the particle belongs to.
  15275. */
  15276. particleSystem: ParticleSystem);
  15277. private updateCellInfoFromSystem;
  15278. /**
  15279. * Defines how the sprite cell index is updated for the particle
  15280. */
  15281. updateCellIndex(): void;
  15282. /** @hidden */
  15283. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  15284. /** @hidden */
  15285. _inheritParticleInfoToSubEmitters(): void;
  15286. /** @hidden */
  15287. _reset(): void;
  15288. /**
  15289. * Copy the properties of particle to another one.
  15290. * @param other the particle to copy the information to.
  15291. */
  15292. copyTo(other: Particle): void;
  15293. }
  15294. }
  15295. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  15296. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15297. import { Effect } from "babylonjs/Materials/effect";
  15298. import { Particle } from "babylonjs/Particles/particle";
  15299. /**
  15300. * Particle emitter represents a volume emitting particles.
  15301. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  15302. */
  15303. export interface IParticleEmitterType {
  15304. /**
  15305. * Called by the particle System when the direction is computed for the created particle.
  15306. * @param worldMatrix is the world matrix of the particle system
  15307. * @param directionToUpdate is the direction vector to update with the result
  15308. * @param particle is the particle we are computed the direction for
  15309. */
  15310. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15311. /**
  15312. * Called by the particle System when the position is computed for the created particle.
  15313. * @param worldMatrix is the world matrix of the particle system
  15314. * @param positionToUpdate is the position vector to update with the result
  15315. * @param particle is the particle we are computed the position for
  15316. */
  15317. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15318. /**
  15319. * Clones the current emitter and returns a copy of it
  15320. * @returns the new emitter
  15321. */
  15322. clone(): IParticleEmitterType;
  15323. /**
  15324. * Called by the GPUParticleSystem to setup the update shader
  15325. * @param effect defines the update shader
  15326. */
  15327. applyToShader(effect: Effect): void;
  15328. /**
  15329. * Returns a string to use to update the GPU particles update shader
  15330. * @returns the effect defines string
  15331. */
  15332. getEffectDefines(): string;
  15333. /**
  15334. * Returns a string representing the class name
  15335. * @returns a string containing the class name
  15336. */
  15337. getClassName(): string;
  15338. /**
  15339. * Serializes the particle system to a JSON object.
  15340. * @returns the JSON object
  15341. */
  15342. serialize(): any;
  15343. /**
  15344. * Parse properties from a JSON object
  15345. * @param serializationObject defines the JSON object
  15346. */
  15347. parse(serializationObject: any): void;
  15348. }
  15349. }
  15350. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  15351. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15352. import { Effect } from "babylonjs/Materials/effect";
  15353. import { Particle } from "babylonjs/Particles/particle";
  15354. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15355. /**
  15356. * Particle emitter emitting particles from the inside of a box.
  15357. * It emits the particles randomly between 2 given directions.
  15358. */
  15359. export class BoxParticleEmitter implements IParticleEmitterType {
  15360. /**
  15361. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15362. */
  15363. direction1: Vector3;
  15364. /**
  15365. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15366. */
  15367. direction2: Vector3;
  15368. /**
  15369. * 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.
  15370. */
  15371. minEmitBox: Vector3;
  15372. /**
  15373. * 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.
  15374. */
  15375. maxEmitBox: Vector3;
  15376. /**
  15377. * Creates a new instance BoxParticleEmitter
  15378. */
  15379. constructor();
  15380. /**
  15381. * Called by the particle System when the direction is computed for the created particle.
  15382. * @param worldMatrix is the world matrix of the particle system
  15383. * @param directionToUpdate is the direction vector to update with the result
  15384. * @param particle is the particle we are computed the direction for
  15385. */
  15386. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15387. /**
  15388. * Called by the particle System when the position is computed for the created particle.
  15389. * @param worldMatrix is the world matrix of the particle system
  15390. * @param positionToUpdate is the position vector to update with the result
  15391. * @param particle is the particle we are computed the position for
  15392. */
  15393. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15394. /**
  15395. * Clones the current emitter and returns a copy of it
  15396. * @returns the new emitter
  15397. */
  15398. clone(): BoxParticleEmitter;
  15399. /**
  15400. * Called by the GPUParticleSystem to setup the update shader
  15401. * @param effect defines the update shader
  15402. */
  15403. applyToShader(effect: Effect): void;
  15404. /**
  15405. * Returns a string to use to update the GPU particles update shader
  15406. * @returns a string containng the defines string
  15407. */
  15408. getEffectDefines(): string;
  15409. /**
  15410. * Returns the string "BoxParticleEmitter"
  15411. * @returns a string containing the class name
  15412. */
  15413. getClassName(): string;
  15414. /**
  15415. * Serializes the particle system to a JSON object.
  15416. * @returns the JSON object
  15417. */
  15418. serialize(): any;
  15419. /**
  15420. * Parse properties from a JSON object
  15421. * @param serializationObject defines the JSON object
  15422. */
  15423. parse(serializationObject: any): void;
  15424. }
  15425. }
  15426. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  15427. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15428. import { Effect } from "babylonjs/Materials/effect";
  15429. import { Particle } from "babylonjs/Particles/particle";
  15430. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15431. /**
  15432. * Particle emitter emitting particles from the inside of a cone.
  15433. * It emits the particles alongside the cone volume from the base to the particle.
  15434. * The emission direction might be randomized.
  15435. */
  15436. export class ConeParticleEmitter implements IParticleEmitterType {
  15437. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15438. directionRandomizer: number;
  15439. private _radius;
  15440. private _angle;
  15441. private _height;
  15442. /**
  15443. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  15444. */
  15445. radiusRange: number;
  15446. /**
  15447. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  15448. */
  15449. heightRange: number;
  15450. /**
  15451. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  15452. */
  15453. emitFromSpawnPointOnly: boolean;
  15454. /**
  15455. * Gets or sets the radius of the emission cone
  15456. */
  15457. radius: number;
  15458. /**
  15459. * Gets or sets the angle of the emission cone
  15460. */
  15461. angle: number;
  15462. private _buildHeight;
  15463. /**
  15464. * Creates a new instance ConeParticleEmitter
  15465. * @param radius the radius of the emission cone (1 by default)
  15466. * @param angle the cone base angle (PI by default)
  15467. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  15468. */
  15469. constructor(radius?: number, angle?: number,
  15470. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15471. directionRandomizer?: number);
  15472. /**
  15473. * Called by the particle System when the direction is computed for the created particle.
  15474. * @param worldMatrix is the world matrix of the particle system
  15475. * @param directionToUpdate is the direction vector to update with the result
  15476. * @param particle is the particle we are computed the direction for
  15477. */
  15478. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15479. /**
  15480. * Called by the particle System when the position is computed for the created particle.
  15481. * @param worldMatrix is the world matrix of the particle system
  15482. * @param positionToUpdate is the position vector to update with the result
  15483. * @param particle is the particle we are computed the position for
  15484. */
  15485. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15486. /**
  15487. * Clones the current emitter and returns a copy of it
  15488. * @returns the new emitter
  15489. */
  15490. clone(): ConeParticleEmitter;
  15491. /**
  15492. * Called by the GPUParticleSystem to setup the update shader
  15493. * @param effect defines the update shader
  15494. */
  15495. applyToShader(effect: Effect): void;
  15496. /**
  15497. * Returns a string to use to update the GPU particles update shader
  15498. * @returns a string containng the defines string
  15499. */
  15500. getEffectDefines(): string;
  15501. /**
  15502. * Returns the string "ConeParticleEmitter"
  15503. * @returns a string containing the class name
  15504. */
  15505. getClassName(): string;
  15506. /**
  15507. * Serializes the particle system to a JSON object.
  15508. * @returns the JSON object
  15509. */
  15510. serialize(): any;
  15511. /**
  15512. * Parse properties from a JSON object
  15513. * @param serializationObject defines the JSON object
  15514. */
  15515. parse(serializationObject: any): void;
  15516. }
  15517. }
  15518. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  15519. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15520. import { Effect } from "babylonjs/Materials/effect";
  15521. import { Particle } from "babylonjs/Particles/particle";
  15522. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15523. /**
  15524. * Particle emitter emitting particles from the inside of a cylinder.
  15525. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  15526. */
  15527. export class CylinderParticleEmitter implements IParticleEmitterType {
  15528. /**
  15529. * The radius of the emission cylinder.
  15530. */
  15531. radius: number;
  15532. /**
  15533. * The height of the emission cylinder.
  15534. */
  15535. height: number;
  15536. /**
  15537. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15538. */
  15539. radiusRange: number;
  15540. /**
  15541. * How much to randomize the particle direction [0-1].
  15542. */
  15543. directionRandomizer: number;
  15544. /**
  15545. * Creates a new instance CylinderParticleEmitter
  15546. * @param radius the radius of the emission cylinder (1 by default)
  15547. * @param height the height of the emission cylinder (1 by default)
  15548. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15549. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15550. */
  15551. constructor(
  15552. /**
  15553. * The radius of the emission cylinder.
  15554. */
  15555. radius?: number,
  15556. /**
  15557. * The height of the emission cylinder.
  15558. */
  15559. height?: number,
  15560. /**
  15561. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15562. */
  15563. radiusRange?: number,
  15564. /**
  15565. * How much to randomize the particle direction [0-1].
  15566. */
  15567. directionRandomizer?: number);
  15568. /**
  15569. * Called by the particle System when the direction is computed for the created particle.
  15570. * @param worldMatrix is the world matrix of the particle system
  15571. * @param directionToUpdate is the direction vector to update with the result
  15572. * @param particle is the particle we are computed the direction for
  15573. */
  15574. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15575. /**
  15576. * Called by the particle System when the position is computed for the created particle.
  15577. * @param worldMatrix is the world matrix of the particle system
  15578. * @param positionToUpdate is the position vector to update with the result
  15579. * @param particle is the particle we are computed the position for
  15580. */
  15581. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15582. /**
  15583. * Clones the current emitter and returns a copy of it
  15584. * @returns the new emitter
  15585. */
  15586. clone(): CylinderParticleEmitter;
  15587. /**
  15588. * Called by the GPUParticleSystem to setup the update shader
  15589. * @param effect defines the update shader
  15590. */
  15591. applyToShader(effect: Effect): void;
  15592. /**
  15593. * Returns a string to use to update the GPU particles update shader
  15594. * @returns a string containng the defines string
  15595. */
  15596. getEffectDefines(): string;
  15597. /**
  15598. * Returns the string "CylinderParticleEmitter"
  15599. * @returns a string containing the class name
  15600. */
  15601. getClassName(): string;
  15602. /**
  15603. * Serializes the particle system to a JSON object.
  15604. * @returns the JSON object
  15605. */
  15606. serialize(): any;
  15607. /**
  15608. * Parse properties from a JSON object
  15609. * @param serializationObject defines the JSON object
  15610. */
  15611. parse(serializationObject: any): void;
  15612. }
  15613. /**
  15614. * Particle emitter emitting particles from the inside of a cylinder.
  15615. * It emits the particles randomly between two vectors.
  15616. */
  15617. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  15618. /**
  15619. * The min limit of the emission direction.
  15620. */
  15621. direction1: Vector3;
  15622. /**
  15623. * The max limit of the emission direction.
  15624. */
  15625. direction2: Vector3;
  15626. /**
  15627. * Creates a new instance CylinderDirectedParticleEmitter
  15628. * @param radius the radius of the emission cylinder (1 by default)
  15629. * @param height the height of the emission cylinder (1 by default)
  15630. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15631. * @param direction1 the min limit of the emission direction (up vector by default)
  15632. * @param direction2 the max limit of the emission direction (up vector by default)
  15633. */
  15634. constructor(radius?: number, height?: number, radiusRange?: number,
  15635. /**
  15636. * The min limit of the emission direction.
  15637. */
  15638. direction1?: Vector3,
  15639. /**
  15640. * The max limit of the emission direction.
  15641. */
  15642. direction2?: Vector3);
  15643. /**
  15644. * Called by the particle System when the direction is computed for the created particle.
  15645. * @param worldMatrix is the world matrix of the particle system
  15646. * @param directionToUpdate is the direction vector to update with the result
  15647. * @param particle is the particle we are computed the direction for
  15648. */
  15649. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15650. /**
  15651. * Clones the current emitter and returns a copy of it
  15652. * @returns the new emitter
  15653. */
  15654. clone(): CylinderDirectedParticleEmitter;
  15655. /**
  15656. * Called by the GPUParticleSystem to setup the update shader
  15657. * @param effect defines the update shader
  15658. */
  15659. applyToShader(effect: Effect): void;
  15660. /**
  15661. * Returns a string to use to update the GPU particles update shader
  15662. * @returns a string containng the defines string
  15663. */
  15664. getEffectDefines(): string;
  15665. /**
  15666. * Returns the string "CylinderDirectedParticleEmitter"
  15667. * @returns a string containing the class name
  15668. */
  15669. getClassName(): string;
  15670. /**
  15671. * Serializes the particle system to a JSON object.
  15672. * @returns the JSON object
  15673. */
  15674. serialize(): any;
  15675. /**
  15676. * Parse properties from a JSON object
  15677. * @param serializationObject defines the JSON object
  15678. */
  15679. parse(serializationObject: any): void;
  15680. }
  15681. }
  15682. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  15683. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15684. import { Effect } from "babylonjs/Materials/effect";
  15685. import { Particle } from "babylonjs/Particles/particle";
  15686. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15687. /**
  15688. * Particle emitter emitting particles from the inside of a hemisphere.
  15689. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  15690. */
  15691. export class HemisphericParticleEmitter implements IParticleEmitterType {
  15692. /**
  15693. * The radius of the emission hemisphere.
  15694. */
  15695. radius: number;
  15696. /**
  15697. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15698. */
  15699. radiusRange: number;
  15700. /**
  15701. * How much to randomize the particle direction [0-1].
  15702. */
  15703. directionRandomizer: number;
  15704. /**
  15705. * Creates a new instance HemisphericParticleEmitter
  15706. * @param radius the radius of the emission hemisphere (1 by default)
  15707. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15708. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15709. */
  15710. constructor(
  15711. /**
  15712. * The radius of the emission hemisphere.
  15713. */
  15714. radius?: number,
  15715. /**
  15716. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15717. */
  15718. radiusRange?: number,
  15719. /**
  15720. * How much to randomize the particle direction [0-1].
  15721. */
  15722. directionRandomizer?: number);
  15723. /**
  15724. * Called by the particle System when the direction is computed for the created particle.
  15725. * @param worldMatrix is the world matrix of the particle system
  15726. * @param directionToUpdate is the direction vector to update with the result
  15727. * @param particle is the particle we are computed the direction for
  15728. */
  15729. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15730. /**
  15731. * Called by the particle System when the position is computed for the created particle.
  15732. * @param worldMatrix is the world matrix of the particle system
  15733. * @param positionToUpdate is the position vector to update with the result
  15734. * @param particle is the particle we are computed the position for
  15735. */
  15736. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15737. /**
  15738. * Clones the current emitter and returns a copy of it
  15739. * @returns the new emitter
  15740. */
  15741. clone(): HemisphericParticleEmitter;
  15742. /**
  15743. * Called by the GPUParticleSystem to setup the update shader
  15744. * @param effect defines the update shader
  15745. */
  15746. applyToShader(effect: Effect): void;
  15747. /**
  15748. * Returns a string to use to update the GPU particles update shader
  15749. * @returns a string containng the defines string
  15750. */
  15751. getEffectDefines(): string;
  15752. /**
  15753. * Returns the string "HemisphericParticleEmitter"
  15754. * @returns a string containing the class name
  15755. */
  15756. getClassName(): string;
  15757. /**
  15758. * Serializes the particle system to a JSON object.
  15759. * @returns the JSON object
  15760. */
  15761. serialize(): any;
  15762. /**
  15763. * Parse properties from a JSON object
  15764. * @param serializationObject defines the JSON object
  15765. */
  15766. parse(serializationObject: any): void;
  15767. }
  15768. }
  15769. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  15770. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15771. import { Effect } from "babylonjs/Materials/effect";
  15772. import { Particle } from "babylonjs/Particles/particle";
  15773. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15774. /**
  15775. * Particle emitter emitting particles from a point.
  15776. * It emits the particles randomly between 2 given directions.
  15777. */
  15778. export class PointParticleEmitter implements IParticleEmitterType {
  15779. /**
  15780. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15781. */
  15782. direction1: Vector3;
  15783. /**
  15784. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15785. */
  15786. direction2: Vector3;
  15787. /**
  15788. * Creates a new instance PointParticleEmitter
  15789. */
  15790. constructor();
  15791. /**
  15792. * Called by the particle System when the direction is computed for the created particle.
  15793. * @param worldMatrix is the world matrix of the particle system
  15794. * @param directionToUpdate is the direction vector to update with the result
  15795. * @param particle is the particle we are computed the direction for
  15796. */
  15797. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15798. /**
  15799. * Called by the particle System when the position is computed for the created particle.
  15800. * @param worldMatrix is the world matrix of the particle system
  15801. * @param positionToUpdate is the position vector to update with the result
  15802. * @param particle is the particle we are computed the position for
  15803. */
  15804. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15805. /**
  15806. * Clones the current emitter and returns a copy of it
  15807. * @returns the new emitter
  15808. */
  15809. clone(): PointParticleEmitter;
  15810. /**
  15811. * Called by the GPUParticleSystem to setup the update shader
  15812. * @param effect defines the update shader
  15813. */
  15814. applyToShader(effect: Effect): void;
  15815. /**
  15816. * Returns a string to use to update the GPU particles update shader
  15817. * @returns a string containng the defines string
  15818. */
  15819. getEffectDefines(): string;
  15820. /**
  15821. * Returns the string "PointParticleEmitter"
  15822. * @returns a string containing the class name
  15823. */
  15824. getClassName(): string;
  15825. /**
  15826. * Serializes the particle system to a JSON object.
  15827. * @returns the JSON object
  15828. */
  15829. serialize(): any;
  15830. /**
  15831. * Parse properties from a JSON object
  15832. * @param serializationObject defines the JSON object
  15833. */
  15834. parse(serializationObject: any): void;
  15835. }
  15836. }
  15837. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  15838. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15839. import { Effect } from "babylonjs/Materials/effect";
  15840. import { Particle } from "babylonjs/Particles/particle";
  15841. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15842. /**
  15843. * Particle emitter emitting particles from the inside of a sphere.
  15844. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  15845. */
  15846. export class SphereParticleEmitter implements IParticleEmitterType {
  15847. /**
  15848. * The radius of the emission sphere.
  15849. */
  15850. radius: number;
  15851. /**
  15852. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15853. */
  15854. radiusRange: number;
  15855. /**
  15856. * How much to randomize the particle direction [0-1].
  15857. */
  15858. directionRandomizer: number;
  15859. /**
  15860. * Creates a new instance SphereParticleEmitter
  15861. * @param radius the radius of the emission sphere (1 by default)
  15862. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15863. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15864. */
  15865. constructor(
  15866. /**
  15867. * The radius of the emission sphere.
  15868. */
  15869. radius?: number,
  15870. /**
  15871. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15872. */
  15873. radiusRange?: number,
  15874. /**
  15875. * How much to randomize the particle direction [0-1].
  15876. */
  15877. directionRandomizer?: number);
  15878. /**
  15879. * Called by the particle System when the direction is computed for the created particle.
  15880. * @param worldMatrix is the world matrix of the particle system
  15881. * @param directionToUpdate is the direction vector to update with the result
  15882. * @param particle is the particle we are computed the direction for
  15883. */
  15884. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15885. /**
  15886. * Called by the particle System when the position is computed for the created particle.
  15887. * @param worldMatrix is the world matrix of the particle system
  15888. * @param positionToUpdate is the position vector to update with the result
  15889. * @param particle is the particle we are computed the position for
  15890. */
  15891. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15892. /**
  15893. * Clones the current emitter and returns a copy of it
  15894. * @returns the new emitter
  15895. */
  15896. clone(): SphereParticleEmitter;
  15897. /**
  15898. * Called by the GPUParticleSystem to setup the update shader
  15899. * @param effect defines the update shader
  15900. */
  15901. applyToShader(effect: Effect): void;
  15902. /**
  15903. * Returns a string to use to update the GPU particles update shader
  15904. * @returns a string containng the defines string
  15905. */
  15906. getEffectDefines(): string;
  15907. /**
  15908. * Returns the string "SphereParticleEmitter"
  15909. * @returns a string containing the class name
  15910. */
  15911. getClassName(): string;
  15912. /**
  15913. * Serializes the particle system to a JSON object.
  15914. * @returns the JSON object
  15915. */
  15916. serialize(): any;
  15917. /**
  15918. * Parse properties from a JSON object
  15919. * @param serializationObject defines the JSON object
  15920. */
  15921. parse(serializationObject: any): void;
  15922. }
  15923. /**
  15924. * Particle emitter emitting particles from the inside of a sphere.
  15925. * It emits the particles randomly between two vectors.
  15926. */
  15927. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  15928. /**
  15929. * The min limit of the emission direction.
  15930. */
  15931. direction1: Vector3;
  15932. /**
  15933. * The max limit of the emission direction.
  15934. */
  15935. direction2: Vector3;
  15936. /**
  15937. * Creates a new instance SphereDirectedParticleEmitter
  15938. * @param radius the radius of the emission sphere (1 by default)
  15939. * @param direction1 the min limit of the emission direction (up vector by default)
  15940. * @param direction2 the max limit of the emission direction (up vector by default)
  15941. */
  15942. constructor(radius?: number,
  15943. /**
  15944. * The min limit of the emission direction.
  15945. */
  15946. direction1?: Vector3,
  15947. /**
  15948. * The max limit of the emission direction.
  15949. */
  15950. direction2?: Vector3);
  15951. /**
  15952. * Called by the particle System when the direction is computed for the created particle.
  15953. * @param worldMatrix is the world matrix of the particle system
  15954. * @param directionToUpdate is the direction vector to update with the result
  15955. * @param particle is the particle we are computed the direction for
  15956. */
  15957. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15958. /**
  15959. * Clones the current emitter and returns a copy of it
  15960. * @returns the new emitter
  15961. */
  15962. clone(): SphereDirectedParticleEmitter;
  15963. /**
  15964. * Called by the GPUParticleSystem to setup the update shader
  15965. * @param effect defines the update shader
  15966. */
  15967. applyToShader(effect: Effect): void;
  15968. /**
  15969. * Returns a string to use to update the GPU particles update shader
  15970. * @returns a string containng the defines string
  15971. */
  15972. getEffectDefines(): string;
  15973. /**
  15974. * Returns the string "SphereDirectedParticleEmitter"
  15975. * @returns a string containing the class name
  15976. */
  15977. getClassName(): string;
  15978. /**
  15979. * Serializes the particle system to a JSON object.
  15980. * @returns the JSON object
  15981. */
  15982. serialize(): any;
  15983. /**
  15984. * Parse properties from a JSON object
  15985. * @param serializationObject defines the JSON object
  15986. */
  15987. parse(serializationObject: any): void;
  15988. }
  15989. }
  15990. declare module "babylonjs/Particles/EmitterTypes/index" {
  15991. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  15992. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  15993. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  15994. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  15995. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15996. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  15997. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  15998. }
  15999. declare module "babylonjs/Particles/IParticleSystem" {
  16000. import { Nullable } from "babylonjs/types";
  16001. import { Color4, Color3, Vector2, Vector3 } from "babylonjs/Maths/math";
  16002. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16003. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  16004. import { Texture } from "babylonjs/Materials/Textures/texture";
  16005. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  16006. import { Scene } from "babylonjs/scene";
  16007. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/tools";
  16008. import { Animation } from "babylonjs/Animations/animation";
  16009. /**
  16010. * Interface representing a particle system in Babylon.js.
  16011. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  16012. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  16013. */
  16014. export interface IParticleSystem {
  16015. /**
  16016. * List of animations used by the particle system.
  16017. */
  16018. animations: Animation[];
  16019. /**
  16020. * The id of the Particle system.
  16021. */
  16022. id: string;
  16023. /**
  16024. * The name of the Particle system.
  16025. */
  16026. name: string;
  16027. /**
  16028. * The emitter represents the Mesh or position we are attaching the particle system to.
  16029. */
  16030. emitter: Nullable<AbstractMesh | Vector3>;
  16031. /**
  16032. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  16033. */
  16034. isBillboardBased: boolean;
  16035. /**
  16036. * The rendering group used by the Particle system to chose when to render.
  16037. */
  16038. renderingGroupId: number;
  16039. /**
  16040. * The layer mask we are rendering the particles through.
  16041. */
  16042. layerMask: number;
  16043. /**
  16044. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16045. */
  16046. updateSpeed: number;
  16047. /**
  16048. * The amount of time the particle system is running (depends of the overall update speed).
  16049. */
  16050. targetStopDuration: number;
  16051. /**
  16052. * The texture used to render each particle. (this can be a spritesheet)
  16053. */
  16054. particleTexture: Nullable<Texture>;
  16055. /**
  16056. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  16057. */
  16058. blendMode: number;
  16059. /**
  16060. * Minimum life time of emitting particles.
  16061. */
  16062. minLifeTime: number;
  16063. /**
  16064. * Maximum life time of emitting particles.
  16065. */
  16066. maxLifeTime: number;
  16067. /**
  16068. * Minimum Size of emitting particles.
  16069. */
  16070. minSize: number;
  16071. /**
  16072. * Maximum Size of emitting particles.
  16073. */
  16074. maxSize: number;
  16075. /**
  16076. * Minimum scale of emitting particles on X axis.
  16077. */
  16078. minScaleX: number;
  16079. /**
  16080. * Maximum scale of emitting particles on X axis.
  16081. */
  16082. maxScaleX: number;
  16083. /**
  16084. * Minimum scale of emitting particles on Y axis.
  16085. */
  16086. minScaleY: number;
  16087. /**
  16088. * Maximum scale of emitting particles on Y axis.
  16089. */
  16090. maxScaleY: number;
  16091. /**
  16092. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  16093. */
  16094. color1: Color4;
  16095. /**
  16096. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  16097. */
  16098. color2: Color4;
  16099. /**
  16100. * Color the particle will have at the end of its lifetime.
  16101. */
  16102. colorDead: Color4;
  16103. /**
  16104. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  16105. */
  16106. emitRate: number;
  16107. /**
  16108. * You can use gravity if you want to give an orientation to your particles.
  16109. */
  16110. gravity: Vector3;
  16111. /**
  16112. * Minimum power of emitting particles.
  16113. */
  16114. minEmitPower: number;
  16115. /**
  16116. * Maximum power of emitting particles.
  16117. */
  16118. maxEmitPower: number;
  16119. /**
  16120. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16121. */
  16122. minAngularSpeed: number;
  16123. /**
  16124. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16125. */
  16126. maxAngularSpeed: number;
  16127. /**
  16128. * Gets or sets the minimal initial rotation in radians.
  16129. */
  16130. minInitialRotation: number;
  16131. /**
  16132. * Gets or sets the maximal initial rotation in radians.
  16133. */
  16134. maxInitialRotation: number;
  16135. /**
  16136. * The particle emitter type defines the emitter used by the particle system.
  16137. * It can be for example box, sphere, or cone...
  16138. */
  16139. particleEmitterType: Nullable<IParticleEmitterType>;
  16140. /**
  16141. * Defines the delay in milliseconds before starting the system (0 by default)
  16142. */
  16143. startDelay: number;
  16144. /**
  16145. * 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
  16146. */
  16147. preWarmCycles: number;
  16148. /**
  16149. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  16150. */
  16151. preWarmStepOffset: number;
  16152. /**
  16153. * 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)
  16154. */
  16155. spriteCellChangeSpeed: number;
  16156. /**
  16157. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16158. */
  16159. startSpriteCellID: number;
  16160. /**
  16161. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16162. */
  16163. endSpriteCellID: number;
  16164. /**
  16165. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16166. */
  16167. spriteCellWidth: number;
  16168. /**
  16169. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16170. */
  16171. spriteCellHeight: number;
  16172. /**
  16173. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16174. */
  16175. spriteRandomStartCell: boolean;
  16176. /**
  16177. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  16178. */
  16179. isAnimationSheetEnabled: boolean;
  16180. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16181. translationPivot: Vector2;
  16182. /**
  16183. * Gets or sets a texture used to add random noise to particle positions
  16184. */
  16185. noiseTexture: Nullable<BaseTexture>;
  16186. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16187. noiseStrength: Vector3;
  16188. /**
  16189. * Gets or sets the billboard mode to use when isBillboardBased = true.
  16190. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  16191. */
  16192. billboardMode: number;
  16193. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  16194. limitVelocityDamping: number;
  16195. /**
  16196. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16197. */
  16198. beginAnimationOnStart: boolean;
  16199. /**
  16200. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16201. */
  16202. beginAnimationFrom: number;
  16203. /**
  16204. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16205. */
  16206. beginAnimationTo: number;
  16207. /**
  16208. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16209. */
  16210. beginAnimationLoop: boolean;
  16211. /**
  16212. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16213. */
  16214. disposeOnStop: boolean;
  16215. /**
  16216. * Gets the maximum number of particles active at the same time.
  16217. * @returns The max number of active particles.
  16218. */
  16219. getCapacity(): number;
  16220. /**
  16221. * Gets if the system has been started. (Note: this will still be true after stop is called)
  16222. * @returns True if it has been started, otherwise false.
  16223. */
  16224. isStarted(): boolean;
  16225. /**
  16226. * Animates the particle system for this frame.
  16227. */
  16228. animate(): void;
  16229. /**
  16230. * Renders the particle system in its current state.
  16231. * @returns the current number of particles
  16232. */
  16233. render(): number;
  16234. /**
  16235. * Dispose the particle system and frees its associated resources.
  16236. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  16237. */
  16238. dispose(disposeTexture?: boolean): void;
  16239. /**
  16240. * Clones the particle system.
  16241. * @param name The name of the cloned object
  16242. * @param newEmitter The new emitter to use
  16243. * @returns the cloned particle system
  16244. */
  16245. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  16246. /**
  16247. * Serializes the particle system to a JSON object.
  16248. * @returns the JSON object
  16249. */
  16250. serialize(): any;
  16251. /**
  16252. * Rebuild the particle system
  16253. */
  16254. rebuild(): void;
  16255. /**
  16256. * Starts the particle system and begins to emit
  16257. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  16258. */
  16259. start(delay?: number): void;
  16260. /**
  16261. * Stops the particle system.
  16262. */
  16263. stop(): void;
  16264. /**
  16265. * Remove all active particles
  16266. */
  16267. reset(): void;
  16268. /**
  16269. * Is this system ready to be used/rendered
  16270. * @return true if the system is ready
  16271. */
  16272. isReady(): boolean;
  16273. /**
  16274. * Adds a new color gradient
  16275. * @param gradient defines the gradient to use (between 0 and 1)
  16276. * @param color1 defines the color to affect to the specified gradient
  16277. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  16278. * @returns the current particle system
  16279. */
  16280. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  16281. /**
  16282. * Remove a specific color gradient
  16283. * @param gradient defines the gradient to remove
  16284. * @returns the current particle system
  16285. */
  16286. removeColorGradient(gradient: number): IParticleSystem;
  16287. /**
  16288. * Adds a new size gradient
  16289. * @param gradient defines the gradient to use (between 0 and 1)
  16290. * @param factor defines the size factor to affect to the specified gradient
  16291. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16292. * @returns the current particle system
  16293. */
  16294. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16295. /**
  16296. * Remove a specific size gradient
  16297. * @param gradient defines the gradient to remove
  16298. * @returns the current particle system
  16299. */
  16300. removeSizeGradient(gradient: number): IParticleSystem;
  16301. /**
  16302. * Gets the current list of color gradients.
  16303. * You must use addColorGradient and removeColorGradient to udpate this list
  16304. * @returns the list of color gradients
  16305. */
  16306. getColorGradients(): Nullable<Array<ColorGradient>>;
  16307. /**
  16308. * Gets the current list of size gradients.
  16309. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16310. * @returns the list of size gradients
  16311. */
  16312. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16313. /**
  16314. * Gets the current list of angular speed gradients.
  16315. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  16316. * @returns the list of angular speed gradients
  16317. */
  16318. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  16319. /**
  16320. * Adds a new angular speed gradient
  16321. * @param gradient defines the gradient to use (between 0 and 1)
  16322. * @param factor defines the angular speed to affect to the specified gradient
  16323. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16324. * @returns the current particle system
  16325. */
  16326. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16327. /**
  16328. * Remove a specific angular speed gradient
  16329. * @param gradient defines the gradient to remove
  16330. * @returns the current particle system
  16331. */
  16332. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  16333. /**
  16334. * Gets the current list of velocity gradients.
  16335. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  16336. * @returns the list of velocity gradients
  16337. */
  16338. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  16339. /**
  16340. * Adds a new velocity gradient
  16341. * @param gradient defines the gradient to use (between 0 and 1)
  16342. * @param factor defines the velocity to affect to the specified gradient
  16343. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16344. * @returns the current particle system
  16345. */
  16346. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16347. /**
  16348. * Remove a specific velocity gradient
  16349. * @param gradient defines the gradient to remove
  16350. * @returns the current particle system
  16351. */
  16352. removeVelocityGradient(gradient: number): IParticleSystem;
  16353. /**
  16354. * Gets the current list of limit velocity gradients.
  16355. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16356. * @returns the list of limit velocity gradients
  16357. */
  16358. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16359. /**
  16360. * Adds a new limit velocity gradient
  16361. * @param gradient defines the gradient to use (between 0 and 1)
  16362. * @param factor defines the limit velocity to affect to the specified gradient
  16363. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16364. * @returns the current particle system
  16365. */
  16366. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16367. /**
  16368. * Remove a specific limit velocity gradient
  16369. * @param gradient defines the gradient to remove
  16370. * @returns the current particle system
  16371. */
  16372. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  16373. /**
  16374. * Adds a new drag gradient
  16375. * @param gradient defines the gradient to use (between 0 and 1)
  16376. * @param factor defines the drag to affect to the specified gradient
  16377. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16378. * @returns the current particle system
  16379. */
  16380. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16381. /**
  16382. * Remove a specific drag gradient
  16383. * @param gradient defines the gradient to remove
  16384. * @returns the current particle system
  16385. */
  16386. removeDragGradient(gradient: number): IParticleSystem;
  16387. /**
  16388. * Gets the current list of drag gradients.
  16389. * You must use addDragGradient and removeDragGradient to udpate this list
  16390. * @returns the list of drag gradients
  16391. */
  16392. getDragGradients(): Nullable<Array<FactorGradient>>;
  16393. /**
  16394. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  16395. * @param gradient defines the gradient to use (between 0 and 1)
  16396. * @param factor defines the emit rate to affect to the specified gradient
  16397. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16398. * @returns the current particle system
  16399. */
  16400. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16401. /**
  16402. * Remove a specific emit rate gradient
  16403. * @param gradient defines the gradient to remove
  16404. * @returns the current particle system
  16405. */
  16406. removeEmitRateGradient(gradient: number): IParticleSystem;
  16407. /**
  16408. * Gets the current list of emit rate gradients.
  16409. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  16410. * @returns the list of emit rate gradients
  16411. */
  16412. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  16413. /**
  16414. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  16415. * @param gradient defines the gradient to use (between 0 and 1)
  16416. * @param factor defines the start size to affect to the specified gradient
  16417. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16418. * @returns the current particle system
  16419. */
  16420. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16421. /**
  16422. * Remove a specific start size gradient
  16423. * @param gradient defines the gradient to remove
  16424. * @returns the current particle system
  16425. */
  16426. removeStartSizeGradient(gradient: number): IParticleSystem;
  16427. /**
  16428. * Gets the current list of start size gradients.
  16429. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  16430. * @returns the list of start size gradients
  16431. */
  16432. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  16433. /**
  16434. * Adds a new life time gradient
  16435. * @param gradient defines the gradient to use (between 0 and 1)
  16436. * @param factor defines the life time factor to affect to the specified gradient
  16437. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16438. * @returns the current particle system
  16439. */
  16440. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16441. /**
  16442. * Remove a specific life time gradient
  16443. * @param gradient defines the gradient to remove
  16444. * @returns the current particle system
  16445. */
  16446. removeLifeTimeGradient(gradient: number): IParticleSystem;
  16447. /**
  16448. * Gets the current list of life time gradients.
  16449. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  16450. * @returns the list of life time gradients
  16451. */
  16452. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  16453. /**
  16454. * Gets the current list of color gradients.
  16455. * You must use addColorGradient and removeColorGradient to udpate this list
  16456. * @returns the list of color gradients
  16457. */
  16458. getColorGradients(): Nullable<Array<ColorGradient>>;
  16459. /**
  16460. * Adds a new ramp gradient used to remap particle colors
  16461. * @param gradient defines the gradient to use (between 0 and 1)
  16462. * @param color defines the color to affect to the specified gradient
  16463. * @returns the current particle system
  16464. */
  16465. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  16466. /**
  16467. * Gets the current list of ramp gradients.
  16468. * You must use addRampGradient and removeRampGradient to udpate this list
  16469. * @returns the list of ramp gradients
  16470. */
  16471. getRampGradients(): Nullable<Array<Color3Gradient>>;
  16472. /** Gets or sets a boolean indicating that ramp gradients must be used
  16473. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  16474. */
  16475. useRampGradients: boolean;
  16476. /**
  16477. * Adds a new color remap gradient
  16478. * @param gradient defines the gradient to use (between 0 and 1)
  16479. * @param min defines the color remap minimal range
  16480. * @param max defines the color remap maximal range
  16481. * @returns the current particle system
  16482. */
  16483. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16484. /**
  16485. * Gets the current list of color remap gradients.
  16486. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  16487. * @returns the list of color remap gradients
  16488. */
  16489. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  16490. /**
  16491. * Adds a new alpha remap gradient
  16492. * @param gradient defines the gradient to use (between 0 and 1)
  16493. * @param min defines the alpha remap minimal range
  16494. * @param max defines the alpha remap maximal range
  16495. * @returns the current particle system
  16496. */
  16497. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16498. /**
  16499. * Gets the current list of alpha remap gradients.
  16500. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  16501. * @returns the list of alpha remap gradients
  16502. */
  16503. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  16504. /**
  16505. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  16506. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16507. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16508. * @returns the emitter
  16509. */
  16510. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  16511. /**
  16512. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  16513. * @param radius The radius of the hemisphere to emit from
  16514. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16515. * @returns the emitter
  16516. */
  16517. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  16518. /**
  16519. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  16520. * @param radius The radius of the sphere to emit from
  16521. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16522. * @returns the emitter
  16523. */
  16524. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  16525. /**
  16526. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  16527. * @param radius The radius of the sphere to emit from
  16528. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  16529. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  16530. * @returns the emitter
  16531. */
  16532. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  16533. /**
  16534. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  16535. * @param radius The radius of the emission cylinder
  16536. * @param height The height of the emission cylinder
  16537. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  16538. * @param directionRandomizer How much to randomize the particle direction [0-1]
  16539. * @returns the emitter
  16540. */
  16541. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  16542. /**
  16543. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  16544. * @param radius The radius of the cylinder to emit from
  16545. * @param height The height of the emission cylinder
  16546. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16547. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  16548. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  16549. * @returns the emitter
  16550. */
  16551. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  16552. /**
  16553. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  16554. * @param radius The radius of the cone to emit from
  16555. * @param angle The base angle of the cone
  16556. * @returns the emitter
  16557. */
  16558. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  16559. /**
  16560. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  16561. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16562. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16563. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16564. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16565. * @returns the emitter
  16566. */
  16567. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  16568. /**
  16569. * Get hosting scene
  16570. * @returns the scene
  16571. */
  16572. getScene(): Scene;
  16573. }
  16574. }
  16575. declare module "babylonjs/Meshes/instancedMesh" {
  16576. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  16577. import { Vector3 } from "babylonjs/Maths/math";
  16578. import { Camera } from "babylonjs/Cameras/camera";
  16579. import { Node } from "babylonjs/node";
  16580. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16581. import { Mesh } from "babylonjs/Meshes/mesh";
  16582. import { Material } from "babylonjs/Materials/material";
  16583. import { Skeleton } from "babylonjs/Bones/skeleton";
  16584. /**
  16585. * Creates an instance based on a source mesh.
  16586. */
  16587. export class InstancedMesh extends AbstractMesh {
  16588. private _sourceMesh;
  16589. private _currentLOD;
  16590. /** @hidden */
  16591. _indexInSourceMeshInstanceArray: number;
  16592. constructor(name: string, source: Mesh);
  16593. /**
  16594. * Returns the string "InstancedMesh".
  16595. */
  16596. getClassName(): string;
  16597. /**
  16598. * If the source mesh receives shadows
  16599. */
  16600. readonly receiveShadows: boolean;
  16601. /**
  16602. * The material of the source mesh
  16603. */
  16604. readonly material: Nullable<Material>;
  16605. /**
  16606. * Visibility of the source mesh
  16607. */
  16608. readonly visibility: number;
  16609. /**
  16610. * Skeleton of the source mesh
  16611. */
  16612. readonly skeleton: Nullable<Skeleton>;
  16613. /**
  16614. * Rendering ground id of the source mesh
  16615. */
  16616. renderingGroupId: number;
  16617. /**
  16618. * Returns the total number of vertices (integer).
  16619. */
  16620. getTotalVertices(): number;
  16621. /**
  16622. * Returns a positive integer : the total number of indices in this mesh geometry.
  16623. * @returns the numner of indices or zero if the mesh has no geometry.
  16624. */
  16625. getTotalIndices(): number;
  16626. /**
  16627. * The source mesh of the instance
  16628. */
  16629. readonly sourceMesh: Mesh;
  16630. /**
  16631. * Is this node ready to be used/rendered
  16632. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16633. * @return {boolean} is it ready
  16634. */
  16635. isReady(completeCheck?: boolean): boolean;
  16636. /**
  16637. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16638. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16639. * @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.
  16640. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16641. */
  16642. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16643. /**
  16644. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16645. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16646. * The `data` are either a numeric array either a Float32Array.
  16647. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16648. * 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).
  16649. * Note that a new underlying VertexBuffer object is created each call.
  16650. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16651. *
  16652. * Possible `kind` values :
  16653. * - VertexBuffer.PositionKind
  16654. * - VertexBuffer.UVKind
  16655. * - VertexBuffer.UV2Kind
  16656. * - VertexBuffer.UV3Kind
  16657. * - VertexBuffer.UV4Kind
  16658. * - VertexBuffer.UV5Kind
  16659. * - VertexBuffer.UV6Kind
  16660. * - VertexBuffer.ColorKind
  16661. * - VertexBuffer.MatricesIndicesKind
  16662. * - VertexBuffer.MatricesIndicesExtraKind
  16663. * - VertexBuffer.MatricesWeightsKind
  16664. * - VertexBuffer.MatricesWeightsExtraKind
  16665. *
  16666. * Returns the Mesh.
  16667. */
  16668. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  16669. /**
  16670. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16671. * If the mesh has no geometry, it is simply returned as it is.
  16672. * The `data` are either a numeric array either a Float32Array.
  16673. * No new underlying VertexBuffer object is created.
  16674. * 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.
  16675. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16676. *
  16677. * Possible `kind` values :
  16678. * - VertexBuffer.PositionKind
  16679. * - VertexBuffer.UVKind
  16680. * - VertexBuffer.UV2Kind
  16681. * - VertexBuffer.UV3Kind
  16682. * - VertexBuffer.UV4Kind
  16683. * - VertexBuffer.UV5Kind
  16684. * - VertexBuffer.UV6Kind
  16685. * - VertexBuffer.ColorKind
  16686. * - VertexBuffer.MatricesIndicesKind
  16687. * - VertexBuffer.MatricesIndicesExtraKind
  16688. * - VertexBuffer.MatricesWeightsKind
  16689. * - VertexBuffer.MatricesWeightsExtraKind
  16690. *
  16691. * Returns the Mesh.
  16692. */
  16693. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16694. /**
  16695. * Sets the mesh indices.
  16696. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16697. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16698. * This method creates a new index buffer each call.
  16699. * Returns the Mesh.
  16700. */
  16701. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16702. /**
  16703. * Boolean : True if the mesh owns the requested kind of data.
  16704. */
  16705. isVerticesDataPresent(kind: string): boolean;
  16706. /**
  16707. * Returns an array of indices (IndicesArray).
  16708. */
  16709. getIndices(): Nullable<IndicesArray>;
  16710. readonly _positions: Nullable<Vector3[]>;
  16711. /**
  16712. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  16713. * This means the mesh underlying bounding box and sphere are recomputed.
  16714. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  16715. * @returns the current mesh
  16716. */
  16717. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  16718. /** @hidden */
  16719. _preActivate(): InstancedMesh;
  16720. /** @hidden */
  16721. _activate(renderId: number): InstancedMesh;
  16722. /**
  16723. * Returns the current associated LOD AbstractMesh.
  16724. */
  16725. getLOD(camera: Camera): AbstractMesh;
  16726. /** @hidden */
  16727. _syncSubMeshes(): InstancedMesh;
  16728. /** @hidden */
  16729. _generatePointsArray(): boolean;
  16730. /**
  16731. * Creates a new InstancedMesh from the current mesh.
  16732. * - name (string) : the cloned mesh name
  16733. * - newParent (optional Node) : the optional Node to parent the clone to.
  16734. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  16735. *
  16736. * Returns the clone.
  16737. */
  16738. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  16739. /**
  16740. * Disposes the InstancedMesh.
  16741. * Returns nothing.
  16742. */
  16743. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16744. }
  16745. }
  16746. declare module "babylonjs/Materials/shaderMaterial" {
  16747. import { Scene } from "babylonjs/scene";
  16748. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  16749. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16750. import { Mesh } from "babylonjs/Meshes/mesh";
  16751. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  16752. import { Texture } from "babylonjs/Materials/Textures/texture";
  16753. import { Material } from "babylonjs/Materials/material";
  16754. /**
  16755. * Defines the options associated with the creation of a shader material.
  16756. */
  16757. export interface IShaderMaterialOptions {
  16758. /**
  16759. * Does the material work in alpha blend mode
  16760. */
  16761. needAlphaBlending: boolean;
  16762. /**
  16763. * Does the material work in alpha test mode
  16764. */
  16765. needAlphaTesting: boolean;
  16766. /**
  16767. * The list of attribute names used in the shader
  16768. */
  16769. attributes: string[];
  16770. /**
  16771. * The list of unifrom names used in the shader
  16772. */
  16773. uniforms: string[];
  16774. /**
  16775. * The list of UBO names used in the shader
  16776. */
  16777. uniformBuffers: string[];
  16778. /**
  16779. * The list of sampler names used in the shader
  16780. */
  16781. samplers: string[];
  16782. /**
  16783. * The list of defines used in the shader
  16784. */
  16785. defines: string[];
  16786. }
  16787. /**
  16788. * 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.
  16789. *
  16790. * This returned material effects how the mesh will look based on the code in the shaders.
  16791. *
  16792. * @see http://doc.babylonjs.com/how_to/shader_material
  16793. */
  16794. export class ShaderMaterial extends Material {
  16795. private _shaderPath;
  16796. private _options;
  16797. private _textures;
  16798. private _textureArrays;
  16799. private _floats;
  16800. private _ints;
  16801. private _floatsArrays;
  16802. private _colors3;
  16803. private _colors3Arrays;
  16804. private _colors4;
  16805. private _vectors2;
  16806. private _vectors3;
  16807. private _vectors4;
  16808. private _matrices;
  16809. private _matrices3x3;
  16810. private _matrices2x2;
  16811. private _vectors2Arrays;
  16812. private _vectors3Arrays;
  16813. private _cachedWorldViewMatrix;
  16814. private _renderId;
  16815. /**
  16816. * Instantiate a new shader material.
  16817. * 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.
  16818. * This returned material effects how the mesh will look based on the code in the shaders.
  16819. * @see http://doc.babylonjs.com/how_to/shader_material
  16820. * @param name Define the name of the material in the scene
  16821. * @param scene Define the scene the material belongs to
  16822. * @param shaderPath Defines the route to the shader code in one of three ways:
  16823. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  16824. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  16825. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  16826. * @param options Define the options used to create the shader
  16827. */
  16828. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  16829. /**
  16830. * Gets the options used to compile the shader.
  16831. * They can be modified to trigger a new compilation
  16832. */
  16833. readonly options: IShaderMaterialOptions;
  16834. /**
  16835. * Gets the current class name of the material e.g. "ShaderMaterial"
  16836. * Mainly use in serialization.
  16837. * @returns the class name
  16838. */
  16839. getClassName(): string;
  16840. /**
  16841. * Specifies if the material will require alpha blending
  16842. * @returns a boolean specifying if alpha blending is needed
  16843. */
  16844. needAlphaBlending(): boolean;
  16845. /**
  16846. * Specifies if this material should be rendered in alpha test mode
  16847. * @returns a boolean specifying if an alpha test is needed.
  16848. */
  16849. needAlphaTesting(): boolean;
  16850. private _checkUniform;
  16851. /**
  16852. * Set a texture in the shader.
  16853. * @param name Define the name of the uniform samplers as defined in the shader
  16854. * @param texture Define the texture to bind to this sampler
  16855. * @return the material itself allowing "fluent" like uniform updates
  16856. */
  16857. setTexture(name: string, texture: Texture): ShaderMaterial;
  16858. /**
  16859. * Set a texture array in the shader.
  16860. * @param name Define the name of the uniform sampler array as defined in the shader
  16861. * @param textures Define the list of textures to bind to this sampler
  16862. * @return the material itself allowing "fluent" like uniform updates
  16863. */
  16864. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  16865. /**
  16866. * Set a float in the shader.
  16867. * @param name Define the name of the uniform as defined in the shader
  16868. * @param value Define the value to give to the uniform
  16869. * @return the material itself allowing "fluent" like uniform updates
  16870. */
  16871. setFloat(name: string, value: number): ShaderMaterial;
  16872. /**
  16873. * Set a int in the shader.
  16874. * @param name Define the name of the uniform as defined in the shader
  16875. * @param value Define the value to give to the uniform
  16876. * @return the material itself allowing "fluent" like uniform updates
  16877. */
  16878. setInt(name: string, value: number): ShaderMaterial;
  16879. /**
  16880. * Set an array of floats in the shader.
  16881. * @param name Define the name of the uniform as defined in the shader
  16882. * @param value Define the value to give to the uniform
  16883. * @return the material itself allowing "fluent" like uniform updates
  16884. */
  16885. setFloats(name: string, value: number[]): ShaderMaterial;
  16886. /**
  16887. * Set a vec3 in the shader from a Color3.
  16888. * @param name Define the name of the uniform as defined in the shader
  16889. * @param value Define the value to give to the uniform
  16890. * @return the material itself allowing "fluent" like uniform updates
  16891. */
  16892. setColor3(name: string, value: Color3): ShaderMaterial;
  16893. /**
  16894. * Set a vec3 array in the shader from a Color3 array.
  16895. * @param name Define the name of the uniform as defined in the shader
  16896. * @param value Define the value to give to the uniform
  16897. * @return the material itself allowing "fluent" like uniform updates
  16898. */
  16899. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  16900. /**
  16901. * Set a vec4 in the shader from a Color4.
  16902. * @param name Define the name of the uniform as defined in the shader
  16903. * @param value Define the value to give to the uniform
  16904. * @return the material itself allowing "fluent" like uniform updates
  16905. */
  16906. setColor4(name: string, value: Color4): ShaderMaterial;
  16907. /**
  16908. * Set a vec2 in the shader from a Vector2.
  16909. * @param name Define the name of the uniform as defined in the shader
  16910. * @param value Define the value to give to the uniform
  16911. * @return the material itself allowing "fluent" like uniform updates
  16912. */
  16913. setVector2(name: string, value: Vector2): ShaderMaterial;
  16914. /**
  16915. * Set a vec3 in the shader from a Vector3.
  16916. * @param name Define the name of the uniform as defined in the shader
  16917. * @param value Define the value to give to the uniform
  16918. * @return the material itself allowing "fluent" like uniform updates
  16919. */
  16920. setVector3(name: string, value: Vector3): ShaderMaterial;
  16921. /**
  16922. * Set a vec4 in the shader from a Vector4.
  16923. * @param name Define the name of the uniform as defined in the shader
  16924. * @param value Define the value to give to the uniform
  16925. * @return the material itself allowing "fluent" like uniform updates
  16926. */
  16927. setVector4(name: string, value: Vector4): ShaderMaterial;
  16928. /**
  16929. * Set a mat4 in the shader from a Matrix.
  16930. * @param name Define the name of the uniform as defined in the shader
  16931. * @param value Define the value to give to the uniform
  16932. * @return the material itself allowing "fluent" like uniform updates
  16933. */
  16934. setMatrix(name: string, value: Matrix): ShaderMaterial;
  16935. /**
  16936. * Set a mat3 in the shader from a Float32Array.
  16937. * @param name Define the name of the uniform as defined in the shader
  16938. * @param value Define the value to give to the uniform
  16939. * @return the material itself allowing "fluent" like uniform updates
  16940. */
  16941. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  16942. /**
  16943. * Set a mat2 in the shader from a Float32Array.
  16944. * @param name Define the name of the uniform as defined in the shader
  16945. * @param value Define the value to give to the uniform
  16946. * @return the material itself allowing "fluent" like uniform updates
  16947. */
  16948. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  16949. /**
  16950. * Set a vec2 array in the shader from a number array.
  16951. * @param name Define the name of the uniform as defined in the shader
  16952. * @param value Define the value to give to the uniform
  16953. * @return the material itself allowing "fluent" like uniform updates
  16954. */
  16955. setArray2(name: string, value: number[]): ShaderMaterial;
  16956. /**
  16957. * Set a vec3 array in the shader from a number array.
  16958. * @param name Define the name of the uniform as defined in the shader
  16959. * @param value Define the value to give to the uniform
  16960. * @return the material itself allowing "fluent" like uniform updates
  16961. */
  16962. setArray3(name: string, value: number[]): ShaderMaterial;
  16963. private _checkCache;
  16964. /**
  16965. * Checks if the material is ready to render the requested mesh
  16966. * @param mesh Define the mesh to render
  16967. * @param useInstances Define whether or not the material is used with instances
  16968. * @returns true if ready, otherwise false
  16969. */
  16970. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  16971. /**
  16972. * Binds the world matrix to the material
  16973. * @param world defines the world transformation matrix
  16974. */
  16975. bindOnlyWorldMatrix(world: Matrix): void;
  16976. /**
  16977. * Binds the material to the mesh
  16978. * @param world defines the world transformation matrix
  16979. * @param mesh defines the mesh to bind the material to
  16980. */
  16981. bind(world: Matrix, mesh?: Mesh): void;
  16982. /**
  16983. * Gets the active textures from the material
  16984. * @returns an array of textures
  16985. */
  16986. getActiveTextures(): BaseTexture[];
  16987. /**
  16988. * Specifies if the material uses a texture
  16989. * @param texture defines the texture to check against the material
  16990. * @returns a boolean specifying if the material uses the texture
  16991. */
  16992. hasTexture(texture: BaseTexture): boolean;
  16993. /**
  16994. * Makes a duplicate of the material, and gives it a new name
  16995. * @param name defines the new name for the duplicated material
  16996. * @returns the cloned material
  16997. */
  16998. clone(name: string): ShaderMaterial;
  16999. /**
  17000. * Disposes the material
  17001. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  17002. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  17003. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  17004. */
  17005. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  17006. /**
  17007. * Serializes this material in a JSON representation
  17008. * @returns the serialized material object
  17009. */
  17010. serialize(): any;
  17011. /**
  17012. * Creates a shader material from parsed shader material data
  17013. * @param source defines the JSON represnetation of the material
  17014. * @param scene defines the hosting scene
  17015. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17016. * @returns a new material
  17017. */
  17018. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  17019. }
  17020. }
  17021. declare module "babylonjs/Shaders/color.fragment" {
  17022. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  17023. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  17024. /** @hidden */
  17025. export var colorPixelShader: {
  17026. name: string;
  17027. shader: string;
  17028. };
  17029. }
  17030. declare module "babylonjs/Shaders/color.vertex" {
  17031. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  17032. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  17033. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  17034. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  17035. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  17036. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  17037. /** @hidden */
  17038. export var colorVertexShader: {
  17039. name: string;
  17040. shader: string;
  17041. };
  17042. }
  17043. declare module "babylonjs/Meshes/linesMesh" {
  17044. import { Nullable } from "babylonjs/types";
  17045. import { Scene } from "babylonjs/scene";
  17046. import { Color3 } from "babylonjs/Maths/math";
  17047. import { Node } from "babylonjs/node";
  17048. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17049. import { Mesh } from "babylonjs/Meshes/mesh";
  17050. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  17051. import { Effect } from "babylonjs/Materials/effect";
  17052. import { Material } from "babylonjs/Materials/material";
  17053. import "babylonjs/Shaders/color.fragment";
  17054. import "babylonjs/Shaders/color.vertex";
  17055. /**
  17056. * Line mesh
  17057. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  17058. */
  17059. export class LinesMesh extends Mesh {
  17060. /**
  17061. * If vertex color should be applied to the mesh
  17062. */
  17063. useVertexColor?: boolean | undefined;
  17064. /**
  17065. * If vertex alpha should be applied to the mesh
  17066. */
  17067. useVertexAlpha?: boolean | undefined;
  17068. /**
  17069. * Color of the line (Default: White)
  17070. */
  17071. color: Color3;
  17072. /**
  17073. * Alpha of the line (Default: 1)
  17074. */
  17075. alpha: number;
  17076. /**
  17077. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17078. * This margin is expressed in world space coordinates, so its value may vary.
  17079. * Default value is 0.1
  17080. */
  17081. intersectionThreshold: number;
  17082. private _colorShader;
  17083. /**
  17084. * Creates a new LinesMesh
  17085. * @param name defines the name
  17086. * @param scene defines the hosting scene
  17087. * @param parent defines the parent mesh if any
  17088. * @param source defines the optional source LinesMesh used to clone data from
  17089. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  17090. * When false, achieved by calling a clone(), also passing False.
  17091. * This will make creation of children, recursive.
  17092. * @param useVertexColor defines if this LinesMesh supports vertex color
  17093. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  17094. */
  17095. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  17096. /**
  17097. * If vertex color should be applied to the mesh
  17098. */
  17099. useVertexColor?: boolean | undefined,
  17100. /**
  17101. * If vertex alpha should be applied to the mesh
  17102. */
  17103. useVertexAlpha?: boolean | undefined);
  17104. private _addClipPlaneDefine;
  17105. private _removeClipPlaneDefine;
  17106. isReady(): boolean;
  17107. /**
  17108. * Returns the string "LineMesh"
  17109. */
  17110. getClassName(): string;
  17111. /**
  17112. * @hidden
  17113. */
  17114. /**
  17115. * @hidden
  17116. */
  17117. material: Material;
  17118. /**
  17119. * @hidden
  17120. */
  17121. readonly checkCollisions: boolean;
  17122. /** @hidden */
  17123. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  17124. /** @hidden */
  17125. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  17126. /**
  17127. * Disposes of the line mesh
  17128. * @param doNotRecurse If children should be disposed
  17129. */
  17130. dispose(doNotRecurse?: boolean): void;
  17131. /**
  17132. * Returns a new LineMesh object cloned from the current one.
  17133. */
  17134. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  17135. /**
  17136. * Creates a new InstancedLinesMesh object from the mesh model.
  17137. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  17138. * @param name defines the name of the new instance
  17139. * @returns a new InstancedLinesMesh
  17140. */
  17141. createInstance(name: string): InstancedLinesMesh;
  17142. }
  17143. /**
  17144. * Creates an instance based on a source LinesMesh
  17145. */
  17146. export class InstancedLinesMesh extends InstancedMesh {
  17147. /**
  17148. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17149. * This margin is expressed in world space coordinates, so its value may vary.
  17150. * Initilized with the intersectionThreshold value of the source LinesMesh
  17151. */
  17152. intersectionThreshold: number;
  17153. constructor(name: string, source: LinesMesh);
  17154. /**
  17155. * Returns the string "InstancedLinesMesh".
  17156. */
  17157. getClassName(): string;
  17158. }
  17159. }
  17160. declare module "babylonjs/Shaders/line.fragment" {
  17161. /** @hidden */
  17162. export var linePixelShader: {
  17163. name: string;
  17164. shader: string;
  17165. };
  17166. }
  17167. declare module "babylonjs/Shaders/line.vertex" {
  17168. /** @hidden */
  17169. export var lineVertexShader: {
  17170. name: string;
  17171. shader: string;
  17172. };
  17173. }
  17174. declare module "babylonjs/Rendering/edgesRenderer" {
  17175. import { Nullable } from "babylonjs/types";
  17176. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  17177. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17178. import { Vector3 } from "babylonjs/Maths/math";
  17179. import { IDisposable } from "babylonjs/scene";
  17180. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  17181. import "babylonjs/Shaders/line.fragment";
  17182. import "babylonjs/Shaders/line.vertex";
  17183. module "babylonjs/Meshes/abstractMesh" {
  17184. interface AbstractMesh {
  17185. /**
  17186. * Disables the mesh edge rendering mode
  17187. * @returns the currentAbstractMesh
  17188. */
  17189. disableEdgesRendering(): AbstractMesh;
  17190. /**
  17191. * Enables the edge rendering mode on the mesh.
  17192. * This mode makes the mesh edges visible
  17193. * @param epsilon defines the maximal distance between two angles to detect a face
  17194. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17195. * @returns the currentAbstractMesh
  17196. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17197. */
  17198. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17199. /**
  17200. * Gets the edgesRenderer associated with the mesh
  17201. */
  17202. edgesRenderer: Nullable<EdgesRenderer>;
  17203. }
  17204. }
  17205. module "babylonjs/Meshes/linesMesh" {
  17206. interface LinesMesh {
  17207. /**
  17208. * Enables the edge rendering mode on the mesh.
  17209. * This mode makes the mesh edges visible
  17210. * @param epsilon defines the maximal distance between two angles to detect a face
  17211. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17212. * @returns the currentAbstractMesh
  17213. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17214. */
  17215. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17216. }
  17217. }
  17218. module "babylonjs/Meshes/linesMesh" {
  17219. interface InstancedLinesMesh {
  17220. /**
  17221. * Enables the edge rendering mode on the mesh.
  17222. * This mode makes the mesh edges visible
  17223. * @param epsilon defines the maximal distance between two angles to detect a face
  17224. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17225. * @returns the current InstancedLinesMesh
  17226. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17227. */
  17228. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  17229. }
  17230. }
  17231. /**
  17232. * Defines the minimum contract an Edges renderer should follow.
  17233. */
  17234. export interface IEdgesRenderer extends IDisposable {
  17235. /**
  17236. * Gets or sets a boolean indicating if the edgesRenderer is active
  17237. */
  17238. isEnabled: boolean;
  17239. /**
  17240. * Renders the edges of the attached mesh,
  17241. */
  17242. render(): void;
  17243. /**
  17244. * Checks wether or not the edges renderer is ready to render.
  17245. * @return true if ready, otherwise false.
  17246. */
  17247. isReady(): boolean;
  17248. }
  17249. /**
  17250. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  17251. */
  17252. export class EdgesRenderer implements IEdgesRenderer {
  17253. /**
  17254. * Define the size of the edges with an orthographic camera
  17255. */
  17256. edgesWidthScalerForOrthographic: number;
  17257. /**
  17258. * Define the size of the edges with a perspective camera
  17259. */
  17260. edgesWidthScalerForPerspective: number;
  17261. protected _source: AbstractMesh;
  17262. protected _linesPositions: number[];
  17263. protected _linesNormals: number[];
  17264. protected _linesIndices: number[];
  17265. protected _epsilon: number;
  17266. protected _indicesCount: number;
  17267. protected _lineShader: ShaderMaterial;
  17268. protected _ib: WebGLBuffer;
  17269. protected _buffers: {
  17270. [key: string]: Nullable<VertexBuffer>;
  17271. };
  17272. protected _checkVerticesInsteadOfIndices: boolean;
  17273. private _meshRebuildObserver;
  17274. private _meshDisposeObserver;
  17275. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  17276. isEnabled: boolean;
  17277. /**
  17278. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  17279. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  17280. * @param source Mesh used to create edges
  17281. * @param epsilon sum of angles in adjacency to check for edge
  17282. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  17283. * @param generateEdgesLines - should generate Lines or only prepare resources.
  17284. */
  17285. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  17286. protected _prepareRessources(): void;
  17287. /** @hidden */
  17288. _rebuild(): void;
  17289. /**
  17290. * Releases the required resources for the edges renderer
  17291. */
  17292. dispose(): void;
  17293. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  17294. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  17295. /**
  17296. * Checks if the pair of p0 and p1 is en edge
  17297. * @param faceIndex
  17298. * @param edge
  17299. * @param faceNormals
  17300. * @param p0
  17301. * @param p1
  17302. * @private
  17303. */
  17304. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  17305. /**
  17306. * push line into the position, normal and index buffer
  17307. * @protected
  17308. */
  17309. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  17310. /**
  17311. * Generates lines edges from adjacencjes
  17312. * @private
  17313. */
  17314. _generateEdgesLines(): void;
  17315. /**
  17316. * Checks wether or not the edges renderer is ready to render.
  17317. * @return true if ready, otherwise false.
  17318. */
  17319. isReady(): boolean;
  17320. /**
  17321. * Renders the edges of the attached mesh,
  17322. */
  17323. render(): void;
  17324. }
  17325. /**
  17326. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  17327. */
  17328. export class LineEdgesRenderer extends EdgesRenderer {
  17329. /**
  17330. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  17331. * @param source LineMesh used to generate edges
  17332. * @param epsilon not important (specified angle for edge detection)
  17333. * @param checkVerticesInsteadOfIndices not important for LineMesh
  17334. */
  17335. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  17336. /**
  17337. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  17338. */
  17339. _generateEdgesLines(): void;
  17340. }
  17341. }
  17342. declare module "babylonjs/Rendering/renderingGroup" {
  17343. import { SmartArray } from "babylonjs/Misc/smartArray";
  17344. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17345. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17346. import { Nullable } from "babylonjs/types";
  17347. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17348. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17349. import { Material } from "babylonjs/Materials/material";
  17350. import { Scene } from "babylonjs/scene";
  17351. /**
  17352. * This represents the object necessary to create a rendering group.
  17353. * This is exclusively used and created by the rendering manager.
  17354. * To modify the behavior, you use the available helpers in your scene or meshes.
  17355. * @hidden
  17356. */
  17357. export class RenderingGroup {
  17358. index: number;
  17359. private _scene;
  17360. private _opaqueSubMeshes;
  17361. private _transparentSubMeshes;
  17362. private _alphaTestSubMeshes;
  17363. private _depthOnlySubMeshes;
  17364. private _particleSystems;
  17365. private _spriteManagers;
  17366. private _opaqueSortCompareFn;
  17367. private _alphaTestSortCompareFn;
  17368. private _transparentSortCompareFn;
  17369. private _renderOpaque;
  17370. private _renderAlphaTest;
  17371. private _renderTransparent;
  17372. private _edgesRenderers;
  17373. onBeforeTransparentRendering: () => void;
  17374. /**
  17375. * Set the opaque sort comparison function.
  17376. * If null the sub meshes will be render in the order they were created
  17377. */
  17378. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17379. /**
  17380. * Set the alpha test sort comparison function.
  17381. * If null the sub meshes will be render in the order they were created
  17382. */
  17383. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17384. /**
  17385. * Set the transparent sort comparison function.
  17386. * If null the sub meshes will be render in the order they were created
  17387. */
  17388. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17389. /**
  17390. * Creates a new rendering group.
  17391. * @param index The rendering group index
  17392. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  17393. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  17394. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  17395. */
  17396. 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>);
  17397. /**
  17398. * Render all the sub meshes contained in the group.
  17399. * @param customRenderFunction Used to override the default render behaviour of the group.
  17400. * @returns true if rendered some submeshes.
  17401. */
  17402. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  17403. /**
  17404. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  17405. * @param subMeshes The submeshes to render
  17406. */
  17407. private renderOpaqueSorted;
  17408. /**
  17409. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  17410. * @param subMeshes The submeshes to render
  17411. */
  17412. private renderAlphaTestSorted;
  17413. /**
  17414. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  17415. * @param subMeshes The submeshes to render
  17416. */
  17417. private renderTransparentSorted;
  17418. /**
  17419. * Renders the submeshes in a specified order.
  17420. * @param subMeshes The submeshes to sort before render
  17421. * @param sortCompareFn The comparison function use to sort
  17422. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  17423. * @param transparent Specifies to activate blending if true
  17424. */
  17425. private static renderSorted;
  17426. /**
  17427. * Renders the submeshes in the order they were dispatched (no sort applied).
  17428. * @param subMeshes The submeshes to render
  17429. */
  17430. private static renderUnsorted;
  17431. /**
  17432. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17433. * are rendered back to front if in the same alpha index.
  17434. *
  17435. * @param a The first submesh
  17436. * @param b The second submesh
  17437. * @returns The result of the comparison
  17438. */
  17439. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  17440. /**
  17441. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17442. * are rendered back to front.
  17443. *
  17444. * @param a The first submesh
  17445. * @param b The second submesh
  17446. * @returns The result of the comparison
  17447. */
  17448. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  17449. /**
  17450. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17451. * are rendered front to back (prevent overdraw).
  17452. *
  17453. * @param a The first submesh
  17454. * @param b The second submesh
  17455. * @returns The result of the comparison
  17456. */
  17457. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17458. /**
  17459. * Resets the different lists of submeshes to prepare a new frame.
  17460. */
  17461. prepare(): void;
  17462. dispose(): void;
  17463. /**
  17464. * Inserts the submesh in its correct queue depending on its material.
  17465. * @param subMesh The submesh to dispatch
  17466. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17467. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17468. */
  17469. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17470. dispatchSprites(spriteManager: ISpriteManager): void;
  17471. dispatchParticles(particleSystem: IParticleSystem): void;
  17472. private _renderParticles;
  17473. private _renderSprites;
  17474. }
  17475. }
  17476. declare module "babylonjs/Rendering/renderingManager" {
  17477. import { Nullable } from "babylonjs/types";
  17478. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17479. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17480. import { SmartArray } from "babylonjs/Misc/smartArray";
  17481. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17482. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17483. import { Material } from "babylonjs/Materials/material";
  17484. import { Scene } from "babylonjs/scene";
  17485. import { Camera } from "babylonjs/Cameras/camera";
  17486. /**
  17487. * Interface describing the different options available in the rendering manager
  17488. * regarding Auto Clear between groups.
  17489. */
  17490. export interface IRenderingManagerAutoClearSetup {
  17491. /**
  17492. * Defines whether or not autoclear is enable.
  17493. */
  17494. autoClear: boolean;
  17495. /**
  17496. * Defines whether or not to autoclear the depth buffer.
  17497. */
  17498. depth: boolean;
  17499. /**
  17500. * Defines whether or not to autoclear the stencil buffer.
  17501. */
  17502. stencil: boolean;
  17503. }
  17504. /**
  17505. * This class is used by the onRenderingGroupObservable
  17506. */
  17507. export class RenderingGroupInfo {
  17508. /**
  17509. * The Scene that being rendered
  17510. */
  17511. scene: Scene;
  17512. /**
  17513. * The camera currently used for the rendering pass
  17514. */
  17515. camera: Nullable<Camera>;
  17516. /**
  17517. * The ID of the renderingGroup being processed
  17518. */
  17519. renderingGroupId: number;
  17520. }
  17521. /**
  17522. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17523. * It is enable to manage the different groups as well as the different necessary sort functions.
  17524. * This should not be used directly aside of the few static configurations
  17525. */
  17526. export class RenderingManager {
  17527. /**
  17528. * The max id used for rendering groups (not included)
  17529. */
  17530. static MAX_RENDERINGGROUPS: number;
  17531. /**
  17532. * The min id used for rendering groups (included)
  17533. */
  17534. static MIN_RENDERINGGROUPS: number;
  17535. /**
  17536. * Used to globally prevent autoclearing scenes.
  17537. */
  17538. static AUTOCLEAR: boolean;
  17539. /**
  17540. * @hidden
  17541. */
  17542. _useSceneAutoClearSetup: boolean;
  17543. private _scene;
  17544. private _renderingGroups;
  17545. private _depthStencilBufferAlreadyCleaned;
  17546. private _autoClearDepthStencil;
  17547. private _customOpaqueSortCompareFn;
  17548. private _customAlphaTestSortCompareFn;
  17549. private _customTransparentSortCompareFn;
  17550. private _renderingGroupInfo;
  17551. /**
  17552. * Instantiates a new rendering group for a particular scene
  17553. * @param scene Defines the scene the groups belongs to
  17554. */
  17555. constructor(scene: Scene);
  17556. private _clearDepthStencilBuffer;
  17557. /**
  17558. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17559. * @hidden
  17560. */
  17561. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17562. /**
  17563. * Resets the different information of the group to prepare a new frame
  17564. * @hidden
  17565. */
  17566. reset(): void;
  17567. /**
  17568. * Dispose and release the group and its associated resources.
  17569. * @hidden
  17570. */
  17571. dispose(): void;
  17572. /**
  17573. * Clear the info related to rendering groups preventing retention points during dispose.
  17574. */
  17575. freeRenderingGroups(): void;
  17576. private _prepareRenderingGroup;
  17577. /**
  17578. * Add a sprite manager to the rendering manager in order to render it this frame.
  17579. * @param spriteManager Define the sprite manager to render
  17580. */
  17581. dispatchSprites(spriteManager: ISpriteManager): void;
  17582. /**
  17583. * Add a particle system to the rendering manager in order to render it this frame.
  17584. * @param particleSystem Define the particle system to render
  17585. */
  17586. dispatchParticles(particleSystem: IParticleSystem): void;
  17587. /**
  17588. * Add a submesh to the manager in order to render it this frame
  17589. * @param subMesh The submesh to dispatch
  17590. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17591. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17592. */
  17593. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17594. /**
  17595. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17596. * This allowed control for front to back rendering or reversly depending of the special needs.
  17597. *
  17598. * @param renderingGroupId The rendering group id corresponding to its index
  17599. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17600. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17601. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17602. */
  17603. 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;
  17604. /**
  17605. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17606. *
  17607. * @param renderingGroupId The rendering group id corresponding to its index
  17608. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17609. * @param depth Automatically clears depth between groups if true and autoClear is true.
  17610. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  17611. */
  17612. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  17613. /**
  17614. * Gets the current auto clear configuration for one rendering group of the rendering
  17615. * manager.
  17616. * @param index the rendering group index to get the information for
  17617. * @returns The auto clear setup for the requested rendering group
  17618. */
  17619. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  17620. }
  17621. }
  17622. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  17623. import { Observable } from "babylonjs/Misc/observable";
  17624. import { SmartArray } from "babylonjs/Misc/smartArray";
  17625. import { Nullable } from "babylonjs/types";
  17626. import { Camera } from "babylonjs/Cameras/camera";
  17627. import { Scene } from "babylonjs/scene";
  17628. import { Matrix, Vector3, Color4 } from "babylonjs/Maths/math";
  17629. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  17630. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17631. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17632. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  17633. import { Texture } from "babylonjs/Materials/Textures/texture";
  17634. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  17635. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  17636. import { Engine } from "babylonjs/Engines/engine";
  17637. /**
  17638. * This Helps creating a texture that will be created from a camera in your scene.
  17639. * It is basically a dynamic texture that could be used to create special effects for instance.
  17640. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  17641. */
  17642. export class RenderTargetTexture extends Texture {
  17643. isCube: boolean;
  17644. /**
  17645. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  17646. */
  17647. static readonly REFRESHRATE_RENDER_ONCE: number;
  17648. /**
  17649. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  17650. */
  17651. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  17652. /**
  17653. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  17654. * the central point of your effect and can save a lot of performances.
  17655. */
  17656. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  17657. /**
  17658. * Use this predicate to dynamically define the list of mesh you want to render.
  17659. * If set, the renderList property will be overwritten.
  17660. */
  17661. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  17662. private _renderList;
  17663. /**
  17664. * Use this list to define the list of mesh you want to render.
  17665. */
  17666. renderList: Nullable<Array<AbstractMesh>>;
  17667. private _hookArray;
  17668. /**
  17669. * Define if particles should be rendered in your texture.
  17670. */
  17671. renderParticles: boolean;
  17672. /**
  17673. * Define if sprites should be rendered in your texture.
  17674. */
  17675. renderSprites: boolean;
  17676. /**
  17677. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  17678. */
  17679. coordinatesMode: number;
  17680. /**
  17681. * Define the camera used to render the texture.
  17682. */
  17683. activeCamera: Nullable<Camera>;
  17684. /**
  17685. * Override the render function of the texture with your own one.
  17686. */
  17687. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  17688. /**
  17689. * Define if camera post processes should be use while rendering the texture.
  17690. */
  17691. useCameraPostProcesses: boolean;
  17692. /**
  17693. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  17694. */
  17695. ignoreCameraViewport: boolean;
  17696. private _postProcessManager;
  17697. private _postProcesses;
  17698. private _resizeObserver;
  17699. /**
  17700. * An event triggered when the texture is unbind.
  17701. */
  17702. onBeforeBindObservable: Observable<RenderTargetTexture>;
  17703. /**
  17704. * An event triggered when the texture is unbind.
  17705. */
  17706. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  17707. private _onAfterUnbindObserver;
  17708. /**
  17709. * Set a after unbind callback in the texture.
  17710. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  17711. */
  17712. onAfterUnbind: () => void;
  17713. /**
  17714. * An event triggered before rendering the texture
  17715. */
  17716. onBeforeRenderObservable: Observable<number>;
  17717. private _onBeforeRenderObserver;
  17718. /**
  17719. * Set a before render callback in the texture.
  17720. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  17721. */
  17722. onBeforeRender: (faceIndex: number) => void;
  17723. /**
  17724. * An event triggered after rendering the texture
  17725. */
  17726. onAfterRenderObservable: Observable<number>;
  17727. private _onAfterRenderObserver;
  17728. /**
  17729. * Set a after render callback in the texture.
  17730. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  17731. */
  17732. onAfterRender: (faceIndex: number) => void;
  17733. /**
  17734. * An event triggered after the texture clear
  17735. */
  17736. onClearObservable: Observable<import("babylonjs/Engines/engine").Engine>;
  17737. private _onClearObserver;
  17738. /**
  17739. * Set a clear callback in the texture.
  17740. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  17741. */
  17742. onClear: (Engine: Engine) => void;
  17743. /**
  17744. * Define the clear color of the Render Target if it should be different from the scene.
  17745. */
  17746. clearColor: Color4;
  17747. protected _size: number | {
  17748. width: number;
  17749. height: number;
  17750. };
  17751. protected _initialSizeParameter: number | {
  17752. width: number;
  17753. height: number;
  17754. } | {
  17755. ratio: number;
  17756. };
  17757. protected _sizeRatio: Nullable<number>;
  17758. /** @hidden */
  17759. _generateMipMaps: boolean;
  17760. protected _renderingManager: RenderingManager;
  17761. /** @hidden */
  17762. _waitingRenderList: string[];
  17763. protected _doNotChangeAspectRatio: boolean;
  17764. protected _currentRefreshId: number;
  17765. protected _refreshRate: number;
  17766. protected _textureMatrix: Matrix;
  17767. protected _samples: number;
  17768. protected _renderTargetOptions: RenderTargetCreationOptions;
  17769. /**
  17770. * Gets render target creation options that were used.
  17771. */
  17772. readonly renderTargetOptions: RenderTargetCreationOptions;
  17773. protected _engine: Engine;
  17774. protected _onRatioRescale(): void;
  17775. /**
  17776. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  17777. * It must define where the camera used to render the texture is set
  17778. */
  17779. boundingBoxPosition: Vector3;
  17780. private _boundingBoxSize;
  17781. /**
  17782. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  17783. * When defined, the cubemap will switch to local mode
  17784. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  17785. * @example https://www.babylonjs-playground.com/#RNASML
  17786. */
  17787. boundingBoxSize: Vector3;
  17788. /**
  17789. * In case the RTT has been created with a depth texture, get the associated
  17790. * depth texture.
  17791. * Otherwise, return null.
  17792. */
  17793. depthStencilTexture: Nullable<InternalTexture>;
  17794. /**
  17795. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  17796. * or used a shadow, depth texture...
  17797. * @param name The friendly name of the texture
  17798. * @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)
  17799. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  17800. * @param generateMipMaps True if mip maps need to be generated after render.
  17801. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  17802. * @param type The type of the buffer in the RTT (int, half float, float...)
  17803. * @param isCube True if a cube texture needs to be created
  17804. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  17805. * @param generateDepthBuffer True to generate a depth buffer
  17806. * @param generateStencilBuffer True to generate a stencil buffer
  17807. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  17808. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  17809. * @param delayAllocation if the texture allocation should be delayed (default: false)
  17810. */
  17811. constructor(name: string, size: number | {
  17812. width: number;
  17813. height: number;
  17814. } | {
  17815. ratio: number;
  17816. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  17817. /**
  17818. * Creates a depth stencil texture.
  17819. * This is only available in WebGL 2 or with the depth texture extension available.
  17820. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  17821. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  17822. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  17823. */
  17824. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  17825. private _processSizeParameter;
  17826. /**
  17827. * Define the number of samples to use in case of MSAA.
  17828. * It defaults to one meaning no MSAA has been enabled.
  17829. */
  17830. samples: number;
  17831. /**
  17832. * Resets the refresh counter of the texture and start bak from scratch.
  17833. * Could be useful to regenerate the texture if it is setup to render only once.
  17834. */
  17835. resetRefreshCounter(): void;
  17836. /**
  17837. * Define the refresh rate of the texture or the rendering frequency.
  17838. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  17839. */
  17840. refreshRate: number;
  17841. /**
  17842. * Adds a post process to the render target rendering passes.
  17843. * @param postProcess define the post process to add
  17844. */
  17845. addPostProcess(postProcess: PostProcess): void;
  17846. /**
  17847. * Clear all the post processes attached to the render target
  17848. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  17849. */
  17850. clearPostProcesses(dispose?: boolean): void;
  17851. /**
  17852. * Remove one of the post process from the list of attached post processes to the texture
  17853. * @param postProcess define the post process to remove from the list
  17854. */
  17855. removePostProcess(postProcess: PostProcess): void;
  17856. /** @hidden */
  17857. _shouldRender(): boolean;
  17858. /**
  17859. * Gets the actual render size of the texture.
  17860. * @returns the width of the render size
  17861. */
  17862. getRenderSize(): number;
  17863. /**
  17864. * Gets the actual render width of the texture.
  17865. * @returns the width of the render size
  17866. */
  17867. getRenderWidth(): number;
  17868. /**
  17869. * Gets the actual render height of the texture.
  17870. * @returns the height of the render size
  17871. */
  17872. getRenderHeight(): number;
  17873. /**
  17874. * Get if the texture can be rescaled or not.
  17875. */
  17876. readonly canRescale: boolean;
  17877. /**
  17878. * Resize the texture using a ratio.
  17879. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  17880. */
  17881. scale(ratio: number): void;
  17882. /**
  17883. * Get the texture reflection matrix used to rotate/transform the reflection.
  17884. * @returns the reflection matrix
  17885. */
  17886. getReflectionTextureMatrix(): Matrix;
  17887. /**
  17888. * Resize the texture to a new desired size.
  17889. * Be carrefull as it will recreate all the data in the new texture.
  17890. * @param size Define the new size. It can be:
  17891. * - a number for squared texture,
  17892. * - an object containing { width: number, height: number }
  17893. * - or an object containing a ratio { ratio: number }
  17894. */
  17895. resize(size: number | {
  17896. width: number;
  17897. height: number;
  17898. } | {
  17899. ratio: number;
  17900. }): void;
  17901. /**
  17902. * Renders all the objects from the render list into the texture.
  17903. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  17904. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  17905. */
  17906. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  17907. private _bestReflectionRenderTargetDimension;
  17908. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  17909. private renderToTarget;
  17910. /**
  17911. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17912. * This allowed control for front to back rendering or reversly depending of the special needs.
  17913. *
  17914. * @param renderingGroupId The rendering group id corresponding to its index
  17915. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17916. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17917. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17918. */
  17919. 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;
  17920. /**
  17921. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17922. *
  17923. * @param renderingGroupId The rendering group id corresponding to its index
  17924. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17925. */
  17926. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  17927. /**
  17928. * Clones the texture.
  17929. * @returns the cloned texture
  17930. */
  17931. clone(): RenderTargetTexture;
  17932. /**
  17933. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  17934. * @returns The JSON representation of the texture
  17935. */
  17936. serialize(): any;
  17937. /**
  17938. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  17939. */
  17940. disposeFramebufferObjects(): void;
  17941. /**
  17942. * Dispose the texture and release its associated resources.
  17943. */
  17944. dispose(): void;
  17945. /** @hidden */
  17946. _rebuild(): void;
  17947. /**
  17948. * Clear the info related to rendering groups preventing retention point in material dispose.
  17949. */
  17950. freeRenderingGroups(): void;
  17951. }
  17952. }
  17953. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  17954. import { Scene } from "babylonjs/scene";
  17955. import { Plane } from "babylonjs/Maths/math";
  17956. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  17957. /**
  17958. * Mirror texture can be used to simulate the view from a mirror in a scene.
  17959. * It will dynamically be rendered every frame to adapt to the camera point of view.
  17960. * You can then easily use it as a reflectionTexture on a flat surface.
  17961. * In case the surface is not a plane, please consider relying on reflection probes.
  17962. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  17963. */
  17964. export class MirrorTexture extends RenderTargetTexture {
  17965. private scene;
  17966. /**
  17967. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  17968. * 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.
  17969. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  17970. */
  17971. mirrorPlane: Plane;
  17972. /**
  17973. * Define the blur ratio used to blur the reflection if needed.
  17974. */
  17975. blurRatio: number;
  17976. /**
  17977. * Define the adaptive blur kernel used to blur the reflection if needed.
  17978. * This will autocompute the closest best match for the `blurKernel`
  17979. */
  17980. adaptiveBlurKernel: number;
  17981. /**
  17982. * Define the blur kernel used to blur the reflection if needed.
  17983. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  17984. */
  17985. blurKernel: number;
  17986. /**
  17987. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  17988. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  17989. */
  17990. blurKernelX: number;
  17991. /**
  17992. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  17993. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  17994. */
  17995. blurKernelY: number;
  17996. private _autoComputeBlurKernel;
  17997. protected _onRatioRescale(): void;
  17998. private _updateGammaSpace;
  17999. private _imageProcessingConfigChangeObserver;
  18000. private _transformMatrix;
  18001. private _mirrorMatrix;
  18002. private _savedViewMatrix;
  18003. private _blurX;
  18004. private _blurY;
  18005. private _adaptiveBlurKernel;
  18006. private _blurKernelX;
  18007. private _blurKernelY;
  18008. private _blurRatio;
  18009. /**
  18010. * Instantiates a Mirror Texture.
  18011. * Mirror texture can be used to simulate the view from a mirror in a scene.
  18012. * It will dynamically be rendered every frame to adapt to the camera point of view.
  18013. * You can then easily use it as a reflectionTexture on a flat surface.
  18014. * In case the surface is not a plane, please consider relying on reflection probes.
  18015. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18016. * @param name
  18017. * @param size
  18018. * @param scene
  18019. * @param generateMipMaps
  18020. * @param type
  18021. * @param samplingMode
  18022. * @param generateDepthBuffer
  18023. */
  18024. constructor(name: string, size: number | {
  18025. width: number;
  18026. height: number;
  18027. } | {
  18028. ratio: number;
  18029. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  18030. private _preparePostProcesses;
  18031. /**
  18032. * Clone the mirror texture.
  18033. * @returns the cloned texture
  18034. */
  18035. clone(): MirrorTexture;
  18036. /**
  18037. * Serialize the texture to a JSON representation you could use in Parse later on
  18038. * @returns the serialized JSON representation
  18039. */
  18040. serialize(): any;
  18041. /**
  18042. * Dispose the texture and release its associated resources.
  18043. */
  18044. dispose(): void;
  18045. }
  18046. }
  18047. declare module "babylonjs/Materials/Textures/texture" {
  18048. import { Observable } from "babylonjs/Misc/observable";
  18049. import { Nullable } from "babylonjs/types";
  18050. import { Scene } from "babylonjs/scene";
  18051. import { Matrix } from "babylonjs/Maths/math";
  18052. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  18053. /**
  18054. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  18055. * @see http://doc.babylonjs.com/babylon101/materials#texture
  18056. */
  18057. export class Texture extends BaseTexture {
  18058. /** @hidden */
  18059. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  18060. /** @hidden */
  18061. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  18062. /** @hidden */
  18063. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  18064. /** nearest is mag = nearest and min = nearest and mip = linear */
  18065. static readonly NEAREST_SAMPLINGMODE: number;
  18066. /** nearest is mag = nearest and min = nearest and mip = linear */
  18067. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  18068. /** Bilinear is mag = linear and min = linear and mip = nearest */
  18069. static readonly BILINEAR_SAMPLINGMODE: number;
  18070. /** Bilinear is mag = linear and min = linear and mip = nearest */
  18071. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  18072. /** Trilinear is mag = linear and min = linear and mip = linear */
  18073. static readonly TRILINEAR_SAMPLINGMODE: number;
  18074. /** Trilinear is mag = linear and min = linear and mip = linear */
  18075. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  18076. /** mag = nearest and min = nearest and mip = nearest */
  18077. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  18078. /** mag = nearest and min = linear and mip = nearest */
  18079. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  18080. /** mag = nearest and min = linear and mip = linear */
  18081. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  18082. /** mag = nearest and min = linear and mip = none */
  18083. static readonly NEAREST_LINEAR: number;
  18084. /** mag = nearest and min = nearest and mip = none */
  18085. static readonly NEAREST_NEAREST: number;
  18086. /** mag = linear and min = nearest and mip = nearest */
  18087. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  18088. /** mag = linear and min = nearest and mip = linear */
  18089. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  18090. /** mag = linear and min = linear and mip = none */
  18091. static readonly LINEAR_LINEAR: number;
  18092. /** mag = linear and min = nearest and mip = none */
  18093. static readonly LINEAR_NEAREST: number;
  18094. /** Explicit coordinates mode */
  18095. static readonly EXPLICIT_MODE: number;
  18096. /** Spherical coordinates mode */
  18097. static readonly SPHERICAL_MODE: number;
  18098. /** Planar coordinates mode */
  18099. static readonly PLANAR_MODE: number;
  18100. /** Cubic coordinates mode */
  18101. static readonly CUBIC_MODE: number;
  18102. /** Projection coordinates mode */
  18103. static readonly PROJECTION_MODE: number;
  18104. /** Inverse Cubic coordinates mode */
  18105. static readonly SKYBOX_MODE: number;
  18106. /** Inverse Cubic coordinates mode */
  18107. static readonly INVCUBIC_MODE: number;
  18108. /** Equirectangular coordinates mode */
  18109. static readonly EQUIRECTANGULAR_MODE: number;
  18110. /** Equirectangular Fixed coordinates mode */
  18111. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  18112. /** Equirectangular Fixed Mirrored coordinates mode */
  18113. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  18114. /** Texture is not repeating outside of 0..1 UVs */
  18115. static readonly CLAMP_ADDRESSMODE: number;
  18116. /** Texture is repeating outside of 0..1 UVs */
  18117. static readonly WRAP_ADDRESSMODE: number;
  18118. /** Texture is repeating and mirrored */
  18119. static readonly MIRROR_ADDRESSMODE: number;
  18120. /**
  18121. * 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
  18122. */
  18123. static UseSerializedUrlIfAny: boolean;
  18124. /**
  18125. * Define the url of the texture.
  18126. */
  18127. url: Nullable<string>;
  18128. /**
  18129. * Define an offset on the texture to offset the u coordinates of the UVs
  18130. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  18131. */
  18132. uOffset: number;
  18133. /**
  18134. * Define an offset on the texture to offset the v coordinates of the UVs
  18135. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  18136. */
  18137. vOffset: number;
  18138. /**
  18139. * Define an offset on the texture to scale the u coordinates of the UVs
  18140. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18141. */
  18142. uScale: number;
  18143. /**
  18144. * Define an offset on the texture to scale the v coordinates of the UVs
  18145. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18146. */
  18147. vScale: number;
  18148. /**
  18149. * Define an offset on the texture to rotate around the u coordinates of the UVs
  18150. * @see http://doc.babylonjs.com/how_to/more_materials
  18151. */
  18152. uAng: number;
  18153. /**
  18154. * Define an offset on the texture to rotate around the v coordinates of the UVs
  18155. * @see http://doc.babylonjs.com/how_to/more_materials
  18156. */
  18157. vAng: number;
  18158. /**
  18159. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  18160. * @see http://doc.babylonjs.com/how_to/more_materials
  18161. */
  18162. wAng: number;
  18163. /**
  18164. * Defines the center of rotation (U)
  18165. */
  18166. uRotationCenter: number;
  18167. /**
  18168. * Defines the center of rotation (V)
  18169. */
  18170. vRotationCenter: number;
  18171. /**
  18172. * Defines the center of rotation (W)
  18173. */
  18174. wRotationCenter: number;
  18175. /**
  18176. * Are mip maps generated for this texture or not.
  18177. */
  18178. readonly noMipmap: boolean;
  18179. private _noMipmap;
  18180. /** @hidden */
  18181. _invertY: boolean;
  18182. private _rowGenerationMatrix;
  18183. private _cachedTextureMatrix;
  18184. private _projectionModeMatrix;
  18185. private _t0;
  18186. private _t1;
  18187. private _t2;
  18188. private _cachedUOffset;
  18189. private _cachedVOffset;
  18190. private _cachedUScale;
  18191. private _cachedVScale;
  18192. private _cachedUAng;
  18193. private _cachedVAng;
  18194. private _cachedWAng;
  18195. private _cachedProjectionMatrixId;
  18196. private _cachedCoordinatesMode;
  18197. /** @hidden */
  18198. protected _initialSamplingMode: number;
  18199. /** @hidden */
  18200. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  18201. private _deleteBuffer;
  18202. protected _format: Nullable<number>;
  18203. private _delayedOnLoad;
  18204. private _delayedOnError;
  18205. /**
  18206. * Observable triggered once the texture has been loaded.
  18207. */
  18208. onLoadObservable: Observable<Texture>;
  18209. protected _isBlocking: boolean;
  18210. /**
  18211. * Is the texture preventing material to render while loading.
  18212. * If false, a default texture will be used instead of the loading one during the preparation step.
  18213. */
  18214. isBlocking: boolean;
  18215. /**
  18216. * Get the current sampling mode associated with the texture.
  18217. */
  18218. readonly samplingMode: number;
  18219. /**
  18220. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  18221. */
  18222. readonly invertY: boolean;
  18223. /**
  18224. * Instantiates a new texture.
  18225. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  18226. * @see http://doc.babylonjs.com/babylon101/materials#texture
  18227. * @param url define the url of the picture to load as a texture
  18228. * @param scene define the scene the texture will belong to
  18229. * @param noMipmap define if the texture will require mip maps or not
  18230. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18231. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18232. * @param onLoad define a callback triggered when the texture has been loaded
  18233. * @param onError define a callback triggered when an error occurred during the loading session
  18234. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18235. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18236. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18237. */
  18238. 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);
  18239. /**
  18240. * Update the url (and optional buffer) of this texture if url was null during construction.
  18241. * @param url the url of the texture
  18242. * @param buffer the buffer of the texture (defaults to null)
  18243. * @param onLoad callback called when the texture is loaded (defaults to null)
  18244. */
  18245. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  18246. /**
  18247. * Finish the loading sequence of a texture flagged as delayed load.
  18248. * @hidden
  18249. */
  18250. delayLoad(): void;
  18251. private _prepareRowForTextureGeneration;
  18252. /**
  18253. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  18254. * @returns the transform matrix of the texture.
  18255. */
  18256. getTextureMatrix(): Matrix;
  18257. /**
  18258. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  18259. * @returns The reflection texture transform
  18260. */
  18261. getReflectionTextureMatrix(): Matrix;
  18262. /**
  18263. * Clones the texture.
  18264. * @returns the cloned texture
  18265. */
  18266. clone(): Texture;
  18267. /**
  18268. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  18269. * @returns The JSON representation of the texture
  18270. */
  18271. serialize(): any;
  18272. /**
  18273. * Get the current class name of the texture useful for serialization or dynamic coding.
  18274. * @returns "Texture"
  18275. */
  18276. getClassName(): string;
  18277. /**
  18278. * Dispose the texture and release its associated resources.
  18279. */
  18280. dispose(): void;
  18281. /**
  18282. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  18283. * @param parsedTexture Define the JSON representation of the texture
  18284. * @param scene Define the scene the parsed texture should be instantiated in
  18285. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  18286. * @returns The parsed texture if successful
  18287. */
  18288. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  18289. /**
  18290. * Creates a texture from its base 64 representation.
  18291. * @param data Define the base64 payload without the data: prefix
  18292. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18293. * @param scene Define the scene the texture should belong to
  18294. * @param noMipmap Forces the texture to not create mip map information if true
  18295. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18296. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18297. * @param onLoad define a callback triggered when the texture has been loaded
  18298. * @param onError define a callback triggered when an error occurred during the loading session
  18299. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18300. * @returns the created texture
  18301. */
  18302. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  18303. /**
  18304. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  18305. * @param data Define the base64 payload without the data: prefix
  18306. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18307. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18308. * @param scene Define the scene the texture should belong to
  18309. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18310. * @param noMipmap Forces the texture to not create mip map information if true
  18311. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18312. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18313. * @param onLoad define a callback triggered when the texture has been loaded
  18314. * @param onError define a callback triggered when an error occurred during the loading session
  18315. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18316. * @returns the created texture
  18317. */
  18318. 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;
  18319. }
  18320. }
  18321. declare module "babylonjs/Materials/Textures/rawTexture" {
  18322. import { Scene } from "babylonjs/scene";
  18323. import { Texture } from "babylonjs/Materials/Textures/texture";
  18324. /**
  18325. * Raw texture can help creating a texture directly from an array of data.
  18326. * This can be super useful if you either get the data from an uncompressed source or
  18327. * if you wish to create your texture pixel by pixel.
  18328. */
  18329. export class RawTexture extends Texture {
  18330. /**
  18331. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18332. */
  18333. format: number;
  18334. private _engine;
  18335. /**
  18336. * Instantiates a new RawTexture.
  18337. * Raw texture can help creating a texture directly from an array of data.
  18338. * This can be super useful if you either get the data from an uncompressed source or
  18339. * if you wish to create your texture pixel by pixel.
  18340. * @param data define the array of data to use to create the texture
  18341. * @param width define the width of the texture
  18342. * @param height define the height of the texture
  18343. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18344. * @param scene define the scene the texture belongs to
  18345. * @param generateMipMaps define whether mip maps should be generated or not
  18346. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18347. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18348. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18349. */
  18350. constructor(data: ArrayBufferView, width: number, height: number,
  18351. /**
  18352. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18353. */
  18354. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  18355. /**
  18356. * Updates the texture underlying data.
  18357. * @param data Define the new data of the texture
  18358. */
  18359. update(data: ArrayBufferView): void;
  18360. /**
  18361. * Creates a luminance texture from some data.
  18362. * @param data Define the texture data
  18363. * @param width Define the width of the texture
  18364. * @param height Define the height of the texture
  18365. * @param scene Define the scene the texture belongs to
  18366. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18367. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18368. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18369. * @returns the luminance texture
  18370. */
  18371. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18372. /**
  18373. * Creates a luminance alpha texture from some data.
  18374. * @param data Define the texture data
  18375. * @param width Define the width of the texture
  18376. * @param height Define the height of the texture
  18377. * @param scene Define the scene the texture belongs to
  18378. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18379. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18380. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18381. * @returns the luminance alpha texture
  18382. */
  18383. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18384. /**
  18385. * Creates an alpha texture from some data.
  18386. * @param data Define the texture data
  18387. * @param width Define the width of the texture
  18388. * @param height Define the height of the texture
  18389. * @param scene Define the scene the texture belongs to
  18390. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18391. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18392. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18393. * @returns the alpha texture
  18394. */
  18395. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18396. /**
  18397. * Creates a RGB texture from some data.
  18398. * @param data Define the texture data
  18399. * @param width Define the width of the texture
  18400. * @param height Define the height of the texture
  18401. * @param scene Define the scene the texture belongs to
  18402. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18403. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18404. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18405. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18406. * @returns the RGB alpha texture
  18407. */
  18408. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18409. /**
  18410. * Creates a RGBA texture from some data.
  18411. * @param data Define the texture data
  18412. * @param width Define the width of the texture
  18413. * @param height Define the height of the texture
  18414. * @param scene Define the scene the texture belongs to
  18415. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18416. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18417. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18418. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18419. * @returns the RGBA texture
  18420. */
  18421. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18422. /**
  18423. * Creates a R texture from some data.
  18424. * @param data Define the texture data
  18425. * @param width Define the width of the texture
  18426. * @param height Define the height of the texture
  18427. * @param scene Define the scene the texture belongs to
  18428. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18429. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18430. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18431. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18432. * @returns the R texture
  18433. */
  18434. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18435. }
  18436. }
  18437. declare module "babylonjs/Animations/runtimeAnimation" {
  18438. import { Animation } from "babylonjs/Animations/animation";
  18439. import { Animatable } from "babylonjs/Animations/animatable";
  18440. import { Scene } from "babylonjs/scene";
  18441. /**
  18442. * Defines a runtime animation
  18443. */
  18444. export class RuntimeAnimation {
  18445. private _events;
  18446. /**
  18447. * The current frame of the runtime animation
  18448. */
  18449. private _currentFrame;
  18450. /**
  18451. * The animation used by the runtime animation
  18452. */
  18453. private _animation;
  18454. /**
  18455. * The target of the runtime animation
  18456. */
  18457. private _target;
  18458. /**
  18459. * The initiating animatable
  18460. */
  18461. private _host;
  18462. /**
  18463. * The original value of the runtime animation
  18464. */
  18465. private _originalValue;
  18466. /**
  18467. * The original blend value of the runtime animation
  18468. */
  18469. private _originalBlendValue;
  18470. /**
  18471. * The offsets cache of the runtime animation
  18472. */
  18473. private _offsetsCache;
  18474. /**
  18475. * The high limits cache of the runtime animation
  18476. */
  18477. private _highLimitsCache;
  18478. /**
  18479. * Specifies if the runtime animation has been stopped
  18480. */
  18481. private _stopped;
  18482. /**
  18483. * The blending factor of the runtime animation
  18484. */
  18485. private _blendingFactor;
  18486. /**
  18487. * The BabylonJS scene
  18488. */
  18489. private _scene;
  18490. /**
  18491. * The current value of the runtime animation
  18492. */
  18493. private _currentValue;
  18494. /** @hidden */
  18495. _workValue: any;
  18496. /**
  18497. * The active target of the runtime animation
  18498. */
  18499. private _activeTarget;
  18500. /**
  18501. * The target path of the runtime animation
  18502. */
  18503. private _targetPath;
  18504. /**
  18505. * The weight of the runtime animation
  18506. */
  18507. private _weight;
  18508. /**
  18509. * The ratio offset of the runtime animation
  18510. */
  18511. private _ratioOffset;
  18512. /**
  18513. * The previous delay of the runtime animation
  18514. */
  18515. private _previousDelay;
  18516. /**
  18517. * The previous ratio of the runtime animation
  18518. */
  18519. private _previousRatio;
  18520. /**
  18521. * Gets the current frame of the runtime animation
  18522. */
  18523. readonly currentFrame: number;
  18524. /**
  18525. * Gets the weight of the runtime animation
  18526. */
  18527. readonly weight: number;
  18528. /**
  18529. * Gets the current value of the runtime animation
  18530. */
  18531. readonly currentValue: any;
  18532. /**
  18533. * Gets the target path of the runtime animation
  18534. */
  18535. readonly targetPath: string;
  18536. /**
  18537. * Gets the actual target of the runtime animation
  18538. */
  18539. readonly target: any;
  18540. /**
  18541. * Create a new RuntimeAnimation object
  18542. * @param target defines the target of the animation
  18543. * @param animation defines the source animation object
  18544. * @param scene defines the hosting scene
  18545. * @param host defines the initiating Animatable
  18546. */
  18547. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  18548. /**
  18549. * Gets the animation from the runtime animation
  18550. */
  18551. readonly animation: Animation;
  18552. /**
  18553. * Resets the runtime animation to the beginning
  18554. * @param restoreOriginal defines whether to restore the target property to the original value
  18555. */
  18556. reset(restoreOriginal?: boolean): void;
  18557. /**
  18558. * Specifies if the runtime animation is stopped
  18559. * @returns Boolean specifying if the runtime animation is stopped
  18560. */
  18561. isStopped(): boolean;
  18562. /**
  18563. * Disposes of the runtime animation
  18564. */
  18565. dispose(): void;
  18566. /**
  18567. * Interpolates the animation from the current frame
  18568. * @param currentFrame The frame to interpolate the animation to
  18569. * @param repeatCount The number of times that the animation should loop
  18570. * @param loopMode The type of looping mode to use
  18571. * @param offsetValue Animation offset value
  18572. * @param highLimitValue The high limit value
  18573. * @returns The interpolated value
  18574. */
  18575. private _interpolate;
  18576. /**
  18577. * Apply the interpolated value to the target
  18578. * @param currentValue defines the value computed by the animation
  18579. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  18580. */
  18581. setValue(currentValue: any, weight?: number): void;
  18582. private _setValue;
  18583. /**
  18584. * Gets the loop pmode of the runtime animation
  18585. * @returns Loop Mode
  18586. */
  18587. private _getCorrectLoopMode;
  18588. /**
  18589. * Move the current animation to a given frame
  18590. * @param frame defines the frame to move to
  18591. */
  18592. goToFrame(frame: number): void;
  18593. /**
  18594. * @hidden Internal use only
  18595. */
  18596. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  18597. /**
  18598. * Execute the current animation
  18599. * @param delay defines the delay to add to the current frame
  18600. * @param from defines the lower bound of the animation range
  18601. * @param to defines the upper bound of the animation range
  18602. * @param loop defines if the current animation must loop
  18603. * @param speedRatio defines the current speed ratio
  18604. * @param weight defines the weight of the animation (default is -1 so no weight)
  18605. * @param onLoop optional callback called when animation loops
  18606. * @returns a boolean indicating if the animation is running
  18607. */
  18608. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number, onLoop?: () => void): boolean;
  18609. }
  18610. }
  18611. declare module "babylonjs/Animations/animatable" {
  18612. import { Animation } from "babylonjs/Animations/animation";
  18613. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  18614. import { Nullable } from "babylonjs/types";
  18615. import { Observable } from "babylonjs/Misc/observable";
  18616. import { Scene } from "babylonjs/scene";
  18617. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math";
  18618. import { Node } from "babylonjs/node";
  18619. /**
  18620. * Class used to store an actual running animation
  18621. */
  18622. export class Animatable {
  18623. /** defines the target object */
  18624. target: any;
  18625. /** defines the starting frame number (default is 0) */
  18626. fromFrame: number;
  18627. /** defines the ending frame number (default is 100) */
  18628. toFrame: number;
  18629. /** defines if the animation must loop (default is false) */
  18630. loopAnimation: boolean;
  18631. /** defines a callback to call when animation ends if it is not looping */
  18632. onAnimationEnd?: (() => void) | null | undefined;
  18633. /** defines a callback to call when animation loops */
  18634. onAnimationLoop?: (() => void) | null | undefined;
  18635. private _localDelayOffset;
  18636. private _pausedDelay;
  18637. private _runtimeAnimations;
  18638. private _paused;
  18639. private _scene;
  18640. private _speedRatio;
  18641. private _weight;
  18642. private _syncRoot;
  18643. /**
  18644. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  18645. * This will only apply for non looping animation (default is true)
  18646. */
  18647. disposeOnEnd: boolean;
  18648. /**
  18649. * Gets a boolean indicating if the animation has started
  18650. */
  18651. animationStarted: boolean;
  18652. /**
  18653. * Observer raised when the animation ends
  18654. */
  18655. onAnimationEndObservable: Observable<Animatable>;
  18656. /**
  18657. * Observer raised when the animation loops
  18658. */
  18659. onAnimationLoopObservable: Observable<Animatable>;
  18660. /**
  18661. * Gets the root Animatable used to synchronize and normalize animations
  18662. */
  18663. readonly syncRoot: Animatable;
  18664. /**
  18665. * Gets the current frame of the first RuntimeAnimation
  18666. * Used to synchronize Animatables
  18667. */
  18668. readonly masterFrame: number;
  18669. /**
  18670. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  18671. */
  18672. weight: number;
  18673. /**
  18674. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  18675. */
  18676. speedRatio: number;
  18677. /**
  18678. * Creates a new Animatable
  18679. * @param scene defines the hosting scene
  18680. * @param target defines the target object
  18681. * @param fromFrame defines the starting frame number (default is 0)
  18682. * @param toFrame defines the ending frame number (default is 100)
  18683. * @param loopAnimation defines if the animation must loop (default is false)
  18684. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  18685. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  18686. * @param animations defines a group of animation to add to the new Animatable
  18687. * @param onAnimationLoop defines a callback to call when animation loops
  18688. */
  18689. constructor(scene: Scene,
  18690. /** defines the target object */
  18691. target: any,
  18692. /** defines the starting frame number (default is 0) */
  18693. fromFrame?: number,
  18694. /** defines the ending frame number (default is 100) */
  18695. toFrame?: number,
  18696. /** defines if the animation must loop (default is false) */
  18697. loopAnimation?: boolean, speedRatio?: number,
  18698. /** defines a callback to call when animation ends if it is not looping */
  18699. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  18700. /** defines a callback to call when animation loops */
  18701. onAnimationLoop?: (() => void) | null | undefined);
  18702. /**
  18703. * Synchronize and normalize current Animatable with a source Animatable
  18704. * This is useful when using animation weights and when animations are not of the same length
  18705. * @param root defines the root Animatable to synchronize with
  18706. * @returns the current Animatable
  18707. */
  18708. syncWith(root: Animatable): Animatable;
  18709. /**
  18710. * Gets the list of runtime animations
  18711. * @returns an array of RuntimeAnimation
  18712. */
  18713. getAnimations(): RuntimeAnimation[];
  18714. /**
  18715. * Adds more animations to the current animatable
  18716. * @param target defines the target of the animations
  18717. * @param animations defines the new animations to add
  18718. */
  18719. appendAnimations(target: any, animations: Animation[]): void;
  18720. /**
  18721. * Gets the source animation for a specific property
  18722. * @param property defines the propertyu to look for
  18723. * @returns null or the source animation for the given property
  18724. */
  18725. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  18726. /**
  18727. * Gets the runtime animation for a specific property
  18728. * @param property defines the propertyu to look for
  18729. * @returns null or the runtime animation for the given property
  18730. */
  18731. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  18732. /**
  18733. * Resets the animatable to its original state
  18734. */
  18735. reset(): void;
  18736. /**
  18737. * Allows the animatable to blend with current running animations
  18738. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  18739. * @param blendingSpeed defines the blending speed to use
  18740. */
  18741. enableBlending(blendingSpeed: number): void;
  18742. /**
  18743. * Disable animation blending
  18744. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  18745. */
  18746. disableBlending(): void;
  18747. /**
  18748. * Jump directly to a given frame
  18749. * @param frame defines the frame to jump to
  18750. */
  18751. goToFrame(frame: number): void;
  18752. /**
  18753. * Pause the animation
  18754. */
  18755. pause(): void;
  18756. /**
  18757. * Restart the animation
  18758. */
  18759. restart(): void;
  18760. private _raiseOnAnimationEnd;
  18761. /**
  18762. * Stop and delete the current animation
  18763. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  18764. * @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)
  18765. */
  18766. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  18767. /**
  18768. * Wait asynchronously for the animation to end
  18769. * @returns a promise which will be fullfilled when the animation ends
  18770. */
  18771. waitAsync(): Promise<Animatable>;
  18772. /** @hidden */
  18773. _animate(delay: number): boolean;
  18774. }
  18775. module "babylonjs/scene" {
  18776. interface Scene {
  18777. /** @hidden */
  18778. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  18779. /** @hidden */
  18780. _processLateAnimationBindingsForMatrices(holder: {
  18781. totalWeight: number;
  18782. animations: RuntimeAnimation[];
  18783. originalValue: Matrix;
  18784. }): any;
  18785. /** @hidden */
  18786. _processLateAnimationBindingsForQuaternions(holder: {
  18787. totalWeight: number;
  18788. animations: RuntimeAnimation[];
  18789. originalValue: Quaternion;
  18790. }, refQuaternion: Quaternion): Quaternion;
  18791. /** @hidden */
  18792. _processLateAnimationBindings(): void;
  18793. /**
  18794. * Will start the animation sequence of a given target
  18795. * @param target defines the target
  18796. * @param from defines from which frame should animation start
  18797. * @param to defines until which frame should animation run.
  18798. * @param weight defines the weight to apply to the animation (1.0 by default)
  18799. * @param loop defines if the animation loops
  18800. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  18801. * @param onAnimationEnd defines the function to be executed when the animation ends
  18802. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  18803. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  18804. * @param onAnimationLoop defines the callback to call when an animation loops
  18805. * @returns the animatable object created for this animation
  18806. */
  18807. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  18808. /**
  18809. * Will start the animation sequence of a given target
  18810. * @param target defines the target
  18811. * @param from defines from which frame should animation start
  18812. * @param to defines until which frame should animation run.
  18813. * @param loop defines if the animation loops
  18814. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  18815. * @param onAnimationEnd defines the function to be executed when the animation ends
  18816. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  18817. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  18818. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  18819. * @param onAnimationLoop defines the callback to call when an animation loops
  18820. * @returns the animatable object created for this animation
  18821. */
  18822. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  18823. /**
  18824. * Will start the animation sequence of a given target and its hierarchy
  18825. * @param target defines the target
  18826. * @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.
  18827. * @param from defines from which frame should animation start
  18828. * @param to defines until which frame should animation run.
  18829. * @param loop defines if the animation loops
  18830. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  18831. * @param onAnimationEnd defines the function to be executed when the animation ends
  18832. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  18833. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  18834. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  18835. * @param onAnimationLoop defines the callback to call when an animation loops
  18836. * @returns the list of created animatables
  18837. */
  18838. 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[];
  18839. /**
  18840. * Begin a new animation on a given node
  18841. * @param target defines the target where the animation will take place
  18842. * @param animations defines the list of animations to start
  18843. * @param from defines the initial value
  18844. * @param to defines the final value
  18845. * @param loop defines if you want animation to loop (off by default)
  18846. * @param speedRatio defines the speed ratio to apply to all animations
  18847. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  18848. * @param onAnimationLoop defines the callback to call when an animation loops
  18849. * @returns the list of created animatables
  18850. */
  18851. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  18852. /**
  18853. * Begin a new animation on a given node and its hierarchy
  18854. * @param target defines the root node where the animation will take place
  18855. * @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.
  18856. * @param animations defines the list of animations to start
  18857. * @param from defines the initial value
  18858. * @param to defines the final value
  18859. * @param loop defines if you want animation to loop (off by default)
  18860. * @param speedRatio defines the speed ratio to apply to all animations
  18861. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  18862. * @param onAnimationLoop defines the callback to call when an animation loops
  18863. * @returns the list of animatables created for all nodes
  18864. */
  18865. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  18866. /**
  18867. * Gets the animatable associated with a specific target
  18868. * @param target defines the target of the animatable
  18869. * @returns the required animatable if found
  18870. */
  18871. getAnimatableByTarget(target: any): Nullable<Animatable>;
  18872. /**
  18873. * Gets all animatables associated with a given target
  18874. * @param target defines the target to look animatables for
  18875. * @returns an array of Animatables
  18876. */
  18877. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  18878. /**
  18879. * Will stop the animation of the given target
  18880. * @param target - the target
  18881. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  18882. * @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)
  18883. */
  18884. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  18885. /**
  18886. * Stops and removes all animations that have been applied to the scene
  18887. */
  18888. stopAllAnimations(): void;
  18889. }
  18890. }
  18891. module "babylonjs/Bones/bone" {
  18892. interface Bone {
  18893. /**
  18894. * Copy an animation range from another bone
  18895. * @param source defines the source bone
  18896. * @param rangeName defines the range name to copy
  18897. * @param frameOffset defines the frame offset
  18898. * @param rescaleAsRequired defines if rescaling must be applied if required
  18899. * @param skelDimensionsRatio defines the scaling ratio
  18900. * @returns true if operation was successful
  18901. */
  18902. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  18903. }
  18904. }
  18905. }
  18906. declare module "babylonjs/Bones/skeleton" {
  18907. import { Bone } from "babylonjs/Bones/bone";
  18908. import { IAnimatable } from "babylonjs/Misc/tools";
  18909. import { Observable } from "babylonjs/Misc/observable";
  18910. import { Vector3, Matrix } from "babylonjs/Maths/math";
  18911. import { Scene } from "babylonjs/scene";
  18912. import { Nullable } from "babylonjs/types";
  18913. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18914. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  18915. import { Animatable } from "babylonjs/Animations/animatable";
  18916. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  18917. import { Animation } from "babylonjs/Animations/animation";
  18918. import { AnimationRange } from "babylonjs/Animations/animationRange";
  18919. /**
  18920. * Class used to handle skinning animations
  18921. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  18922. */
  18923. export class Skeleton implements IAnimatable {
  18924. /** defines the skeleton name */
  18925. name: string;
  18926. /** defines the skeleton Id */
  18927. id: string;
  18928. /**
  18929. * Defines the list of child bones
  18930. */
  18931. bones: Bone[];
  18932. /**
  18933. * Defines an estimate of the dimension of the skeleton at rest
  18934. */
  18935. dimensionsAtRest: Vector3;
  18936. /**
  18937. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  18938. */
  18939. needInitialSkinMatrix: boolean;
  18940. /**
  18941. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  18942. */
  18943. overrideMesh: Nullable<AbstractMesh>;
  18944. /**
  18945. * Gets the list of animations attached to this skeleton
  18946. */
  18947. animations: Array<Animation>;
  18948. private _scene;
  18949. private _isDirty;
  18950. private _transformMatrices;
  18951. private _transformMatrixTexture;
  18952. private _meshesWithPoseMatrix;
  18953. private _animatables;
  18954. private _identity;
  18955. private _synchronizedWithMesh;
  18956. private _ranges;
  18957. private _lastAbsoluteTransformsUpdateId;
  18958. private _canUseTextureForBones;
  18959. /** @hidden */
  18960. _numBonesWithLinkedTransformNode: number;
  18961. /**
  18962. * Specifies if the skeleton should be serialized
  18963. */
  18964. doNotSerialize: boolean;
  18965. /**
  18966. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  18967. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  18968. */
  18969. useTextureToStoreBoneMatrices: boolean;
  18970. private _animationPropertiesOverride;
  18971. /**
  18972. * Gets or sets the animation properties override
  18973. */
  18974. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  18975. /**
  18976. * An observable triggered before computing the skeleton's matrices
  18977. */
  18978. onBeforeComputeObservable: Observable<Skeleton>;
  18979. /**
  18980. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  18981. */
  18982. readonly isUsingTextureForMatrices: boolean;
  18983. /**
  18984. * Creates a new skeleton
  18985. * @param name defines the skeleton name
  18986. * @param id defines the skeleton Id
  18987. * @param scene defines the hosting scene
  18988. */
  18989. constructor(
  18990. /** defines the skeleton name */
  18991. name: string,
  18992. /** defines the skeleton Id */
  18993. id: string, scene: Scene);
  18994. /**
  18995. * Gets the current object class name.
  18996. * @return the class name
  18997. */
  18998. getClassName(): string;
  18999. /**
  19000. * Returns an array containing the root bones
  19001. * @returns an array containing the root bones
  19002. */
  19003. getChildren(): Array<Bone>;
  19004. /**
  19005. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  19006. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  19007. * @returns a Float32Array containing matrices data
  19008. */
  19009. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  19010. /**
  19011. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  19012. * @returns a raw texture containing the data
  19013. */
  19014. getTransformMatrixTexture(): Nullable<RawTexture>;
  19015. /**
  19016. * Gets the current hosting scene
  19017. * @returns a scene object
  19018. */
  19019. getScene(): Scene;
  19020. /**
  19021. * Gets a string representing the current skeleton data
  19022. * @param fullDetails defines a boolean indicating if we want a verbose version
  19023. * @returns a string representing the current skeleton data
  19024. */
  19025. toString(fullDetails?: boolean): string;
  19026. /**
  19027. * Get bone's index searching by name
  19028. * @param name defines bone's name to search for
  19029. * @return the indice of the bone. Returns -1 if not found
  19030. */
  19031. getBoneIndexByName(name: string): number;
  19032. /**
  19033. * Creater a new animation range
  19034. * @param name defines the name of the range
  19035. * @param from defines the start key
  19036. * @param to defines the end key
  19037. */
  19038. createAnimationRange(name: string, from: number, to: number): void;
  19039. /**
  19040. * Delete a specific animation range
  19041. * @param name defines the name of the range
  19042. * @param deleteFrames defines if frames must be removed as well
  19043. */
  19044. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  19045. /**
  19046. * Gets a specific animation range
  19047. * @param name defines the name of the range to look for
  19048. * @returns the requested animation range or null if not found
  19049. */
  19050. getAnimationRange(name: string): Nullable<AnimationRange>;
  19051. /**
  19052. * Gets the list of all animation ranges defined on this skeleton
  19053. * @returns an array
  19054. */
  19055. getAnimationRanges(): Nullable<AnimationRange>[];
  19056. /**
  19057. * Copy animation range from a source skeleton.
  19058. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  19059. * @param source defines the source skeleton
  19060. * @param name defines the name of the range to copy
  19061. * @param rescaleAsRequired defines if rescaling must be applied if required
  19062. * @returns true if operation was successful
  19063. */
  19064. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  19065. /**
  19066. * Forces the skeleton to go to rest pose
  19067. */
  19068. returnToRest(): void;
  19069. private _getHighestAnimationFrame;
  19070. /**
  19071. * Begin a specific animation range
  19072. * @param name defines the name of the range to start
  19073. * @param loop defines if looping must be turned on (false by default)
  19074. * @param speedRatio defines the speed ratio to apply (1 by default)
  19075. * @param onAnimationEnd defines a callback which will be called when animation will end
  19076. * @returns a new animatable
  19077. */
  19078. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  19079. /** @hidden */
  19080. _markAsDirty(): void;
  19081. /** @hidden */
  19082. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  19083. /** @hidden */
  19084. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  19085. private _computeTransformMatrices;
  19086. /**
  19087. * Build all resources required to render a skeleton
  19088. */
  19089. prepare(): void;
  19090. /**
  19091. * Gets the list of animatables currently running for this skeleton
  19092. * @returns an array of animatables
  19093. */
  19094. getAnimatables(): IAnimatable[];
  19095. /**
  19096. * Clone the current skeleton
  19097. * @param name defines the name of the new skeleton
  19098. * @param id defines the id of the enw skeleton
  19099. * @returns the new skeleton
  19100. */
  19101. clone(name: string, id: string): Skeleton;
  19102. /**
  19103. * Enable animation blending for this skeleton
  19104. * @param blendingSpeed defines the blending speed to apply
  19105. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  19106. */
  19107. enableBlending(blendingSpeed?: number): void;
  19108. /**
  19109. * Releases all resources associated with the current skeleton
  19110. */
  19111. dispose(): void;
  19112. /**
  19113. * Serialize the skeleton in a JSON object
  19114. * @returns a JSON object
  19115. */
  19116. serialize(): any;
  19117. /**
  19118. * Creates a new skeleton from serialized data
  19119. * @param parsedSkeleton defines the serialized data
  19120. * @param scene defines the hosting scene
  19121. * @returns a new skeleton
  19122. */
  19123. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  19124. /**
  19125. * Compute all node absolute transforms
  19126. * @param forceUpdate defines if computation must be done even if cache is up to date
  19127. */
  19128. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  19129. /**
  19130. * Gets the root pose matrix
  19131. * @returns a matrix
  19132. */
  19133. getPoseMatrix(): Nullable<Matrix>;
  19134. /**
  19135. * Sorts bones per internal index
  19136. */
  19137. sortBones(): void;
  19138. private _sortBones;
  19139. }
  19140. }
  19141. declare module "babylonjs/Morph/morphTarget" {
  19142. import { IAnimatable } from "babylonjs/Misc/tools";
  19143. import { Observable } from "babylonjs/Misc/observable";
  19144. import { Nullable, FloatArray } from "babylonjs/types";
  19145. import { Scene } from "babylonjs/scene";
  19146. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19147. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  19148. /**
  19149. * Defines a target to use with MorphTargetManager
  19150. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  19151. */
  19152. export class MorphTarget implements IAnimatable {
  19153. /** defines the name of the target */
  19154. name: string;
  19155. /**
  19156. * Gets or sets the list of animations
  19157. */
  19158. animations: import("babylonjs/Animations/animation").Animation[];
  19159. private _scene;
  19160. private _positions;
  19161. private _normals;
  19162. private _tangents;
  19163. private _influence;
  19164. /**
  19165. * Observable raised when the influence changes
  19166. */
  19167. onInfluenceChanged: Observable<boolean>;
  19168. /** @hidden */
  19169. _onDataLayoutChanged: Observable<void>;
  19170. /**
  19171. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  19172. */
  19173. influence: number;
  19174. /**
  19175. * Gets or sets the id of the morph Target
  19176. */
  19177. id: string;
  19178. private _animationPropertiesOverride;
  19179. /**
  19180. * Gets or sets the animation properties override
  19181. */
  19182. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  19183. /**
  19184. * Creates a new MorphTarget
  19185. * @param name defines the name of the target
  19186. * @param influence defines the influence to use
  19187. * @param scene defines the scene the morphtarget belongs to
  19188. */
  19189. constructor(
  19190. /** defines the name of the target */
  19191. name: string, influence?: number, scene?: Nullable<Scene>);
  19192. /**
  19193. * Gets a boolean defining if the target contains position data
  19194. */
  19195. readonly hasPositions: boolean;
  19196. /**
  19197. * Gets a boolean defining if the target contains normal data
  19198. */
  19199. readonly hasNormals: boolean;
  19200. /**
  19201. * Gets a boolean defining if the target contains tangent data
  19202. */
  19203. readonly hasTangents: boolean;
  19204. /**
  19205. * Affects position data to this target
  19206. * @param data defines the position data to use
  19207. */
  19208. setPositions(data: Nullable<FloatArray>): void;
  19209. /**
  19210. * Gets the position data stored in this target
  19211. * @returns a FloatArray containing the position data (or null if not present)
  19212. */
  19213. getPositions(): Nullable<FloatArray>;
  19214. /**
  19215. * Affects normal data to this target
  19216. * @param data defines the normal data to use
  19217. */
  19218. setNormals(data: Nullable<FloatArray>): void;
  19219. /**
  19220. * Gets the normal data stored in this target
  19221. * @returns a FloatArray containing the normal data (or null if not present)
  19222. */
  19223. getNormals(): Nullable<FloatArray>;
  19224. /**
  19225. * Affects tangent data to this target
  19226. * @param data defines the tangent data to use
  19227. */
  19228. setTangents(data: Nullable<FloatArray>): void;
  19229. /**
  19230. * Gets the tangent data stored in this target
  19231. * @returns a FloatArray containing the tangent data (or null if not present)
  19232. */
  19233. getTangents(): Nullable<FloatArray>;
  19234. /**
  19235. * Serializes the current target into a Serialization object
  19236. * @returns the serialized object
  19237. */
  19238. serialize(): any;
  19239. /**
  19240. * Returns the string "MorphTarget"
  19241. * @returns "MorphTarget"
  19242. */
  19243. getClassName(): string;
  19244. /**
  19245. * Creates a new target from serialized data
  19246. * @param serializationObject defines the serialized data to use
  19247. * @returns a new MorphTarget
  19248. */
  19249. static Parse(serializationObject: any): MorphTarget;
  19250. /**
  19251. * Creates a MorphTarget from mesh data
  19252. * @param mesh defines the source mesh
  19253. * @param name defines the name to use for the new target
  19254. * @param influence defines the influence to attach to the target
  19255. * @returns a new MorphTarget
  19256. */
  19257. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  19258. }
  19259. }
  19260. declare module "babylonjs/Morph/morphTargetManager" {
  19261. import { Nullable } from "babylonjs/types";
  19262. import { Scene } from "babylonjs/scene";
  19263. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  19264. /**
  19265. * This class is used to deform meshes using morphing between different targets
  19266. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  19267. */
  19268. export class MorphTargetManager {
  19269. private _targets;
  19270. private _targetInfluenceChangedObservers;
  19271. private _targetDataLayoutChangedObservers;
  19272. private _activeTargets;
  19273. private _scene;
  19274. private _influences;
  19275. private _supportsNormals;
  19276. private _supportsTangents;
  19277. private _vertexCount;
  19278. private _uniqueId;
  19279. private _tempInfluences;
  19280. /**
  19281. * Creates a new MorphTargetManager
  19282. * @param scene defines the current scene
  19283. */
  19284. constructor(scene?: Nullable<Scene>);
  19285. /**
  19286. * Gets the unique ID of this manager
  19287. */
  19288. readonly uniqueId: number;
  19289. /**
  19290. * Gets the number of vertices handled by this manager
  19291. */
  19292. readonly vertexCount: number;
  19293. /**
  19294. * Gets a boolean indicating if this manager supports morphing of normals
  19295. */
  19296. readonly supportsNormals: boolean;
  19297. /**
  19298. * Gets a boolean indicating if this manager supports morphing of tangents
  19299. */
  19300. readonly supportsTangents: boolean;
  19301. /**
  19302. * Gets the number of targets stored in this manager
  19303. */
  19304. readonly numTargets: number;
  19305. /**
  19306. * Gets the number of influencers (ie. the number of targets with influences > 0)
  19307. */
  19308. readonly numInfluencers: number;
  19309. /**
  19310. * Gets the list of influences (one per target)
  19311. */
  19312. readonly influences: Float32Array;
  19313. /**
  19314. * Gets the active target at specified index. An active target is a target with an influence > 0
  19315. * @param index defines the index to check
  19316. * @returns the requested target
  19317. */
  19318. getActiveTarget(index: number): MorphTarget;
  19319. /**
  19320. * Gets the target at specified index
  19321. * @param index defines the index to check
  19322. * @returns the requested target
  19323. */
  19324. getTarget(index: number): MorphTarget;
  19325. /**
  19326. * Add a new target to this manager
  19327. * @param target defines the target to add
  19328. */
  19329. addTarget(target: MorphTarget): void;
  19330. /**
  19331. * Removes a target from the manager
  19332. * @param target defines the target to remove
  19333. */
  19334. removeTarget(target: MorphTarget): void;
  19335. /**
  19336. * Serializes the current manager into a Serialization object
  19337. * @returns the serialized object
  19338. */
  19339. serialize(): any;
  19340. private _syncActiveTargets;
  19341. /**
  19342. * Syncrhonize the targets with all the meshes using this morph target manager
  19343. */
  19344. synchronize(): void;
  19345. /**
  19346. * Creates a new MorphTargetManager from serialized data
  19347. * @param serializationObject defines the serialized data
  19348. * @param scene defines the hosting scene
  19349. * @returns the new MorphTargetManager
  19350. */
  19351. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  19352. }
  19353. }
  19354. declare module "babylonjs/Meshes/groundMesh" {
  19355. import { Scene } from "babylonjs/scene";
  19356. import { Vector3 } from "babylonjs/Maths/math";
  19357. import { Mesh } from "babylonjs/Meshes/mesh";
  19358. /**
  19359. * Mesh representing the gorund
  19360. */
  19361. export class GroundMesh extends Mesh {
  19362. /** If octree should be generated */
  19363. generateOctree: boolean;
  19364. private _heightQuads;
  19365. /** @hidden */
  19366. _subdivisionsX: number;
  19367. /** @hidden */
  19368. _subdivisionsY: number;
  19369. /** @hidden */
  19370. _width: number;
  19371. /** @hidden */
  19372. _height: number;
  19373. /** @hidden */
  19374. _minX: number;
  19375. /** @hidden */
  19376. _maxX: number;
  19377. /** @hidden */
  19378. _minZ: number;
  19379. /** @hidden */
  19380. _maxZ: number;
  19381. constructor(name: string, scene: Scene);
  19382. /**
  19383. * "GroundMesh"
  19384. * @returns "GroundMesh"
  19385. */
  19386. getClassName(): string;
  19387. /**
  19388. * The minimum of x and y subdivisions
  19389. */
  19390. readonly subdivisions: number;
  19391. /**
  19392. * X subdivisions
  19393. */
  19394. readonly subdivisionsX: number;
  19395. /**
  19396. * Y subdivisions
  19397. */
  19398. readonly subdivisionsY: number;
  19399. /**
  19400. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  19401. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  19402. * @param chunksCount the number of subdivisions for x and y
  19403. * @param octreeBlocksSize (Default: 32)
  19404. */
  19405. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  19406. /**
  19407. * Returns a height (y) value in the Worl system :
  19408. * the ground altitude at the coordinates (x, z) expressed in the World system.
  19409. * @param x x coordinate
  19410. * @param z z coordinate
  19411. * @returns the ground y position if (x, z) are outside the ground surface.
  19412. */
  19413. getHeightAtCoordinates(x: number, z: number): number;
  19414. /**
  19415. * Returns a normalized vector (Vector3) orthogonal to the ground
  19416. * at the ground coordinates (x, z) expressed in the World system.
  19417. * @param x x coordinate
  19418. * @param z z coordinate
  19419. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  19420. */
  19421. getNormalAtCoordinates(x: number, z: number): Vector3;
  19422. /**
  19423. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  19424. * at the ground coordinates (x, z) expressed in the World system.
  19425. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  19426. * @param x x coordinate
  19427. * @param z z coordinate
  19428. * @param ref vector to store the result
  19429. * @returns the GroundMesh.
  19430. */
  19431. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  19432. /**
  19433. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  19434. * if the ground has been updated.
  19435. * This can be used in the render loop.
  19436. * @returns the GroundMesh.
  19437. */
  19438. updateCoordinateHeights(): GroundMesh;
  19439. private _getFacetAt;
  19440. private _initHeightQuads;
  19441. private _computeHeightQuads;
  19442. /**
  19443. * Serializes this ground mesh
  19444. * @param serializationObject object to write serialization to
  19445. */
  19446. serialize(serializationObject: any): void;
  19447. /**
  19448. * Parses a serialized ground mesh
  19449. * @param parsedMesh the serialized mesh
  19450. * @param scene the scene to create the ground mesh in
  19451. * @returns the created ground mesh
  19452. */
  19453. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  19454. }
  19455. }
  19456. declare module "babylonjs/Physics/physicsJoint" {
  19457. import { Vector3 } from "babylonjs/Maths/math";
  19458. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  19459. /**
  19460. * Interface for Physics-Joint data
  19461. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19462. */
  19463. export interface PhysicsJointData {
  19464. /**
  19465. * The main pivot of the joint
  19466. */
  19467. mainPivot?: Vector3;
  19468. /**
  19469. * The connected pivot of the joint
  19470. */
  19471. connectedPivot?: Vector3;
  19472. /**
  19473. * The main axis of the joint
  19474. */
  19475. mainAxis?: Vector3;
  19476. /**
  19477. * The connected axis of the joint
  19478. */
  19479. connectedAxis?: Vector3;
  19480. /**
  19481. * The collision of the joint
  19482. */
  19483. collision?: boolean;
  19484. /**
  19485. * Native Oimo/Cannon/Energy data
  19486. */
  19487. nativeParams?: any;
  19488. }
  19489. /**
  19490. * This is a holder class for the physics joint created by the physics plugin
  19491. * It holds a set of functions to control the underlying joint
  19492. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19493. */
  19494. export class PhysicsJoint {
  19495. /**
  19496. * The type of the physics joint
  19497. */
  19498. type: number;
  19499. /**
  19500. * The data for the physics joint
  19501. */
  19502. jointData: PhysicsJointData;
  19503. private _physicsJoint;
  19504. protected _physicsPlugin: IPhysicsEnginePlugin;
  19505. /**
  19506. * Initializes the physics joint
  19507. * @param type The type of the physics joint
  19508. * @param jointData The data for the physics joint
  19509. */
  19510. constructor(
  19511. /**
  19512. * The type of the physics joint
  19513. */
  19514. type: number,
  19515. /**
  19516. * The data for the physics joint
  19517. */
  19518. jointData: PhysicsJointData);
  19519. /**
  19520. * Gets the physics joint
  19521. */
  19522. /**
  19523. * Sets the physics joint
  19524. */
  19525. physicsJoint: any;
  19526. /**
  19527. * Sets the physics plugin
  19528. */
  19529. physicsPlugin: IPhysicsEnginePlugin;
  19530. /**
  19531. * Execute a function that is physics-plugin specific.
  19532. * @param {Function} func the function that will be executed.
  19533. * It accepts two parameters: the physics world and the physics joint
  19534. */
  19535. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  19536. /**
  19537. * Distance-Joint type
  19538. */
  19539. static DistanceJoint: number;
  19540. /**
  19541. * Hinge-Joint type
  19542. */
  19543. static HingeJoint: number;
  19544. /**
  19545. * Ball-and-Socket joint type
  19546. */
  19547. static BallAndSocketJoint: number;
  19548. /**
  19549. * Wheel-Joint type
  19550. */
  19551. static WheelJoint: number;
  19552. /**
  19553. * Slider-Joint type
  19554. */
  19555. static SliderJoint: number;
  19556. /**
  19557. * Prismatic-Joint type
  19558. */
  19559. static PrismaticJoint: number;
  19560. /**
  19561. * Universal-Joint type
  19562. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  19563. */
  19564. static UniversalJoint: number;
  19565. /**
  19566. * Hinge-Joint 2 type
  19567. */
  19568. static Hinge2Joint: number;
  19569. /**
  19570. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  19571. */
  19572. static PointToPointJoint: number;
  19573. /**
  19574. * Spring-Joint type
  19575. */
  19576. static SpringJoint: number;
  19577. /**
  19578. * Lock-Joint type
  19579. */
  19580. static LockJoint: number;
  19581. }
  19582. /**
  19583. * A class representing a physics distance joint
  19584. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19585. */
  19586. export class DistanceJoint extends PhysicsJoint {
  19587. /**
  19588. *
  19589. * @param jointData The data for the Distance-Joint
  19590. */
  19591. constructor(jointData: DistanceJointData);
  19592. /**
  19593. * Update the predefined distance.
  19594. * @param maxDistance The maximum preferred distance
  19595. * @param minDistance The minimum preferred distance
  19596. */
  19597. updateDistance(maxDistance: number, minDistance?: number): void;
  19598. }
  19599. /**
  19600. * Represents a Motor-Enabled Joint
  19601. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19602. */
  19603. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  19604. /**
  19605. * Initializes the Motor-Enabled Joint
  19606. * @param type The type of the joint
  19607. * @param jointData The physica joint data for the joint
  19608. */
  19609. constructor(type: number, jointData: PhysicsJointData);
  19610. /**
  19611. * Set the motor values.
  19612. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19613. * @param force the force to apply
  19614. * @param maxForce max force for this motor.
  19615. */
  19616. setMotor(force?: number, maxForce?: number): void;
  19617. /**
  19618. * Set the motor's limits.
  19619. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19620. * @param upperLimit The upper limit of the motor
  19621. * @param lowerLimit The lower limit of the motor
  19622. */
  19623. setLimit(upperLimit: number, lowerLimit?: number): void;
  19624. }
  19625. /**
  19626. * This class represents a single physics Hinge-Joint
  19627. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19628. */
  19629. export class HingeJoint extends MotorEnabledJoint {
  19630. /**
  19631. * Initializes the Hinge-Joint
  19632. * @param jointData The joint data for the Hinge-Joint
  19633. */
  19634. constructor(jointData: PhysicsJointData);
  19635. /**
  19636. * Set the motor values.
  19637. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19638. * @param {number} force the force to apply
  19639. * @param {number} maxForce max force for this motor.
  19640. */
  19641. setMotor(force?: number, maxForce?: number): void;
  19642. /**
  19643. * Set the motor's limits.
  19644. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19645. * @param upperLimit The upper limit of the motor
  19646. * @param lowerLimit The lower limit of the motor
  19647. */
  19648. setLimit(upperLimit: number, lowerLimit?: number): void;
  19649. }
  19650. /**
  19651. * This class represents a dual hinge physics joint (same as wheel joint)
  19652. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19653. */
  19654. export class Hinge2Joint extends MotorEnabledJoint {
  19655. /**
  19656. * Initializes the Hinge2-Joint
  19657. * @param jointData The joint data for the Hinge2-Joint
  19658. */
  19659. constructor(jointData: PhysicsJointData);
  19660. /**
  19661. * Set the motor values.
  19662. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19663. * @param {number} targetSpeed the speed the motor is to reach
  19664. * @param {number} maxForce max force for this motor.
  19665. * @param {motorIndex} the motor's index, 0 or 1.
  19666. */
  19667. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  19668. /**
  19669. * Set the motor limits.
  19670. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19671. * @param {number} upperLimit the upper limit
  19672. * @param {number} lowerLimit lower limit
  19673. * @param {motorIndex} the motor's index, 0 or 1.
  19674. */
  19675. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  19676. }
  19677. /**
  19678. * Interface for a motor enabled joint
  19679. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19680. */
  19681. export interface IMotorEnabledJoint {
  19682. /**
  19683. * Physics joint
  19684. */
  19685. physicsJoint: any;
  19686. /**
  19687. * Sets the motor of the motor-enabled joint
  19688. * @param force The force of the motor
  19689. * @param maxForce The maximum force of the motor
  19690. * @param motorIndex The index of the motor
  19691. */
  19692. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  19693. /**
  19694. * Sets the limit of the motor
  19695. * @param upperLimit The upper limit of the motor
  19696. * @param lowerLimit The lower limit of the motor
  19697. * @param motorIndex The index of the motor
  19698. */
  19699. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  19700. }
  19701. /**
  19702. * Joint data for a Distance-Joint
  19703. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19704. */
  19705. export interface DistanceJointData extends PhysicsJointData {
  19706. /**
  19707. * Max distance the 2 joint objects can be apart
  19708. */
  19709. maxDistance: number;
  19710. }
  19711. /**
  19712. * Joint data from a spring joint
  19713. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19714. */
  19715. export interface SpringJointData extends PhysicsJointData {
  19716. /**
  19717. * Length of the spring
  19718. */
  19719. length: number;
  19720. /**
  19721. * Stiffness of the spring
  19722. */
  19723. stiffness: number;
  19724. /**
  19725. * Damping of the spring
  19726. */
  19727. damping: number;
  19728. /** this callback will be called when applying the force to the impostors. */
  19729. forceApplicationCallback: () => void;
  19730. }
  19731. }
  19732. declare module "babylonjs/Physics/IPhysicsEngine" {
  19733. import { Nullable } from "babylonjs/types";
  19734. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  19735. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19736. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  19737. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  19738. /**
  19739. * Interface used to describe a physics joint
  19740. */
  19741. export interface PhysicsImpostorJoint {
  19742. /** Defines the main impostor to which the joint is linked */
  19743. mainImpostor: PhysicsImpostor;
  19744. /** Defines the impostor that is connected to the main impostor using this joint */
  19745. connectedImpostor: PhysicsImpostor;
  19746. /** Defines the joint itself */
  19747. joint: PhysicsJoint;
  19748. }
  19749. /** @hidden */
  19750. export interface IPhysicsEnginePlugin {
  19751. world: any;
  19752. name: string;
  19753. setGravity(gravity: Vector3): void;
  19754. setTimeStep(timeStep: number): void;
  19755. getTimeStep(): number;
  19756. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  19757. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  19758. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  19759. generatePhysicsBody(impostor: PhysicsImpostor): void;
  19760. removePhysicsBody(impostor: PhysicsImpostor): void;
  19761. generateJoint(joint: PhysicsImpostorJoint): void;
  19762. removeJoint(joint: PhysicsImpostorJoint): void;
  19763. isSupported(): boolean;
  19764. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  19765. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  19766. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  19767. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  19768. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  19769. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  19770. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  19771. getBodyMass(impostor: PhysicsImpostor): number;
  19772. getBodyFriction(impostor: PhysicsImpostor): number;
  19773. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  19774. getBodyRestitution(impostor: PhysicsImpostor): number;
  19775. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  19776. sleepBody(impostor: PhysicsImpostor): void;
  19777. wakeUpBody(impostor: PhysicsImpostor): void;
  19778. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  19779. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  19780. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  19781. getRadius(impostor: PhysicsImpostor): number;
  19782. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  19783. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  19784. dispose(): void;
  19785. }
  19786. /**
  19787. * Interface used to define a physics engine
  19788. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  19789. */
  19790. export interface IPhysicsEngine {
  19791. /**
  19792. * Gets the gravity vector used by the simulation
  19793. */
  19794. gravity: Vector3;
  19795. /**
  19796. * Sets the gravity vector used by the simulation
  19797. * @param gravity defines the gravity vector to use
  19798. */
  19799. setGravity(gravity: Vector3): void;
  19800. /**
  19801. * Set the time step of the physics engine.
  19802. * Default is 1/60.
  19803. * To slow it down, enter 1/600 for example.
  19804. * To speed it up, 1/30
  19805. * @param newTimeStep the new timestep to apply to this world.
  19806. */
  19807. setTimeStep(newTimeStep: number): void;
  19808. /**
  19809. * Get the time step of the physics engine.
  19810. * @returns the current time step
  19811. */
  19812. getTimeStep(): number;
  19813. /**
  19814. * Release all resources
  19815. */
  19816. dispose(): void;
  19817. /**
  19818. * Gets the name of the current physics plugin
  19819. * @returns the name of the plugin
  19820. */
  19821. getPhysicsPluginName(): string;
  19822. /**
  19823. * Adding a new impostor for the impostor tracking.
  19824. * This will be done by the impostor itself.
  19825. * @param impostor the impostor to add
  19826. */
  19827. addImpostor(impostor: PhysicsImpostor): void;
  19828. /**
  19829. * Remove an impostor from the engine.
  19830. * This impostor and its mesh will not longer be updated by the physics engine.
  19831. * @param impostor the impostor to remove
  19832. */
  19833. removeImpostor(impostor: PhysicsImpostor): void;
  19834. /**
  19835. * Add a joint to the physics engine
  19836. * @param mainImpostor defines the main impostor to which the joint is added.
  19837. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  19838. * @param joint defines the joint that will connect both impostors.
  19839. */
  19840. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  19841. /**
  19842. * Removes a joint from the simulation
  19843. * @param mainImpostor defines the impostor used with the joint
  19844. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  19845. * @param joint defines the joint to remove
  19846. */
  19847. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  19848. /**
  19849. * Gets the current plugin used to run the simulation
  19850. * @returns current plugin
  19851. */
  19852. getPhysicsPlugin(): IPhysicsEnginePlugin;
  19853. /**
  19854. * Gets the list of physic impostors
  19855. * @returns an array of PhysicsImpostor
  19856. */
  19857. getImpostors(): Array<PhysicsImpostor>;
  19858. /**
  19859. * Gets the impostor for a physics enabled object
  19860. * @param object defines the object impersonated by the impostor
  19861. * @returns the PhysicsImpostor or null if not found
  19862. */
  19863. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  19864. /**
  19865. * Gets the impostor for a physics body object
  19866. * @param body defines physics body used by the impostor
  19867. * @returns the PhysicsImpostor or null if not found
  19868. */
  19869. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  19870. /**
  19871. * Called by the scene. No need to call it.
  19872. * @param delta defines the timespam between frames
  19873. */
  19874. _step(delta: number): void;
  19875. }
  19876. }
  19877. declare module "babylonjs/Physics/physicsImpostor" {
  19878. import { Nullable, IndicesArray } from "babylonjs/types";
  19879. import { Vector3, Matrix, Quaternion, Space } from "babylonjs/Maths/math";
  19880. import { TransformNode } from "babylonjs/Meshes/transformNode";
  19881. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19882. import { Scene } from "babylonjs/scene";
  19883. import { Bone } from "babylonjs/Bones/bone";
  19884. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  19885. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  19886. /**
  19887. * The interface for the physics imposter parameters
  19888. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19889. */
  19890. export interface PhysicsImpostorParameters {
  19891. /**
  19892. * The mass of the physics imposter
  19893. */
  19894. mass: number;
  19895. /**
  19896. * The friction of the physics imposter
  19897. */
  19898. friction?: number;
  19899. /**
  19900. * The coefficient of restitution of the physics imposter
  19901. */
  19902. restitution?: number;
  19903. /**
  19904. * The native options of the physics imposter
  19905. */
  19906. nativeOptions?: any;
  19907. /**
  19908. * Specifies if the parent should be ignored
  19909. */
  19910. ignoreParent?: boolean;
  19911. /**
  19912. * Specifies if bi-directional transformations should be disabled
  19913. */
  19914. disableBidirectionalTransformation?: boolean;
  19915. }
  19916. /**
  19917. * Interface for a physics-enabled object
  19918. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19919. */
  19920. export interface IPhysicsEnabledObject {
  19921. /**
  19922. * The position of the physics-enabled object
  19923. */
  19924. position: Vector3;
  19925. /**
  19926. * The rotation of the physics-enabled object
  19927. */
  19928. rotationQuaternion: Nullable<Quaternion>;
  19929. /**
  19930. * The scale of the physics-enabled object
  19931. */
  19932. scaling: Vector3;
  19933. /**
  19934. * The rotation of the physics-enabled object
  19935. */
  19936. rotation?: Vector3;
  19937. /**
  19938. * The parent of the physics-enabled object
  19939. */
  19940. parent?: any;
  19941. /**
  19942. * The bounding info of the physics-enabled object
  19943. * @returns The bounding info of the physics-enabled object
  19944. */
  19945. getBoundingInfo(): BoundingInfo;
  19946. /**
  19947. * Computes the world matrix
  19948. * @param force Specifies if the world matrix should be computed by force
  19949. * @returns A world matrix
  19950. */
  19951. computeWorldMatrix(force: boolean): Matrix;
  19952. /**
  19953. * Gets the world matrix
  19954. * @returns A world matrix
  19955. */
  19956. getWorldMatrix?(): Matrix;
  19957. /**
  19958. * Gets the child meshes
  19959. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  19960. * @returns An array of abstract meshes
  19961. */
  19962. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  19963. /**
  19964. * Gets the vertex data
  19965. * @param kind The type of vertex data
  19966. * @returns A nullable array of numbers, or a float32 array
  19967. */
  19968. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  19969. /**
  19970. * Gets the indices from the mesh
  19971. * @returns A nullable array of index arrays
  19972. */
  19973. getIndices?(): Nullable<IndicesArray>;
  19974. /**
  19975. * Gets the scene from the mesh
  19976. * @returns the indices array or null
  19977. */
  19978. getScene?(): Scene;
  19979. /**
  19980. * Gets the absolute position from the mesh
  19981. * @returns the absolute position
  19982. */
  19983. getAbsolutePosition(): Vector3;
  19984. /**
  19985. * Gets the absolute pivot point from the mesh
  19986. * @returns the absolute pivot point
  19987. */
  19988. getAbsolutePivotPoint(): Vector3;
  19989. /**
  19990. * Rotates the mesh
  19991. * @param axis The axis of rotation
  19992. * @param amount The amount of rotation
  19993. * @param space The space of the rotation
  19994. * @returns The rotation transform node
  19995. */
  19996. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  19997. /**
  19998. * Translates the mesh
  19999. * @param axis The axis of translation
  20000. * @param distance The distance of translation
  20001. * @param space The space of the translation
  20002. * @returns The transform node
  20003. */
  20004. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  20005. /**
  20006. * Sets the absolute position of the mesh
  20007. * @param absolutePosition The absolute position of the mesh
  20008. * @returns The transform node
  20009. */
  20010. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  20011. /**
  20012. * Gets the class name of the mesh
  20013. * @returns The class name
  20014. */
  20015. getClassName(): string;
  20016. }
  20017. /**
  20018. * Represents a physics imposter
  20019. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20020. */
  20021. export class PhysicsImpostor {
  20022. /**
  20023. * The physics-enabled object used as the physics imposter
  20024. */
  20025. object: IPhysicsEnabledObject;
  20026. /**
  20027. * The type of the physics imposter
  20028. */
  20029. type: number;
  20030. private _options;
  20031. private _scene?;
  20032. /**
  20033. * The default object size of the imposter
  20034. */
  20035. static DEFAULT_OBJECT_SIZE: Vector3;
  20036. /**
  20037. * The identity quaternion of the imposter
  20038. */
  20039. static IDENTITY_QUATERNION: Quaternion;
  20040. /** @hidden */
  20041. _pluginData: any;
  20042. private _physicsEngine;
  20043. private _physicsBody;
  20044. private _bodyUpdateRequired;
  20045. private _onBeforePhysicsStepCallbacks;
  20046. private _onAfterPhysicsStepCallbacks;
  20047. /** @hidden */
  20048. _onPhysicsCollideCallbacks: Array<{
  20049. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  20050. otherImpostors: Array<PhysicsImpostor>;
  20051. }>;
  20052. private _deltaPosition;
  20053. private _deltaRotation;
  20054. private _deltaRotationConjugated;
  20055. private _parent;
  20056. private _isDisposed;
  20057. private static _tmpVecs;
  20058. private static _tmpQuat;
  20059. /**
  20060. * Specifies if the physics imposter is disposed
  20061. */
  20062. readonly isDisposed: boolean;
  20063. /**
  20064. * Gets the mass of the physics imposter
  20065. */
  20066. mass: number;
  20067. /**
  20068. * Gets the coefficient of friction
  20069. */
  20070. /**
  20071. * Sets the coefficient of friction
  20072. */
  20073. friction: number;
  20074. /**
  20075. * Gets the coefficient of restitution
  20076. */
  20077. /**
  20078. * Sets the coefficient of restitution
  20079. */
  20080. restitution: number;
  20081. /**
  20082. * The unique id of the physics imposter
  20083. * set by the physics engine when adding this impostor to the array
  20084. */
  20085. uniqueId: number;
  20086. private _joints;
  20087. /**
  20088. * Initializes the physics imposter
  20089. * @param object The physics-enabled object used as the physics imposter
  20090. * @param type The type of the physics imposter
  20091. * @param _options The options for the physics imposter
  20092. * @param _scene The Babylon scene
  20093. */
  20094. constructor(
  20095. /**
  20096. * The physics-enabled object used as the physics imposter
  20097. */
  20098. object: IPhysicsEnabledObject,
  20099. /**
  20100. * The type of the physics imposter
  20101. */
  20102. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  20103. /**
  20104. * This function will completly initialize this impostor.
  20105. * It will create a new body - but only if this mesh has no parent.
  20106. * If it has, this impostor will not be used other than to define the impostor
  20107. * of the child mesh.
  20108. * @hidden
  20109. */
  20110. _init(): void;
  20111. private _getPhysicsParent;
  20112. /**
  20113. * Should a new body be generated.
  20114. * @returns boolean specifying if body initialization is required
  20115. */
  20116. isBodyInitRequired(): boolean;
  20117. /**
  20118. * Sets the updated scaling
  20119. * @param updated Specifies if the scaling is updated
  20120. */
  20121. setScalingUpdated(): void;
  20122. /**
  20123. * Force a regeneration of this or the parent's impostor's body.
  20124. * Use under cautious - This will remove all joints already implemented.
  20125. */
  20126. forceUpdate(): void;
  20127. /**
  20128. * Gets the body that holds this impostor. Either its own, or its parent.
  20129. */
  20130. /**
  20131. * Set the physics body. Used mainly by the physics engine/plugin
  20132. */
  20133. physicsBody: any;
  20134. /**
  20135. * Get the parent of the physics imposter
  20136. * @returns Physics imposter or null
  20137. */
  20138. /**
  20139. * Sets the parent of the physics imposter
  20140. */
  20141. parent: Nullable<PhysicsImpostor>;
  20142. /**
  20143. * Resets the update flags
  20144. */
  20145. resetUpdateFlags(): void;
  20146. /**
  20147. * Gets the object extend size
  20148. * @returns the object extend size
  20149. */
  20150. getObjectExtendSize(): Vector3;
  20151. /**
  20152. * Gets the object center
  20153. * @returns The object center
  20154. */
  20155. getObjectCenter(): Vector3;
  20156. /**
  20157. * Get a specific parametes from the options parameter
  20158. * @param paramName The object parameter name
  20159. * @returns The object parameter
  20160. */
  20161. getParam(paramName: string): any;
  20162. /**
  20163. * Sets a specific parameter in the options given to the physics plugin
  20164. * @param paramName The parameter name
  20165. * @param value The value of the parameter
  20166. */
  20167. setParam(paramName: string, value: number): void;
  20168. /**
  20169. * Specifically change the body's mass option. Won't recreate the physics body object
  20170. * @param mass The mass of the physics imposter
  20171. */
  20172. setMass(mass: number): void;
  20173. /**
  20174. * Gets the linear velocity
  20175. * @returns linear velocity or null
  20176. */
  20177. getLinearVelocity(): Nullable<Vector3>;
  20178. /**
  20179. * Sets the linear velocity
  20180. * @param velocity linear velocity or null
  20181. */
  20182. setLinearVelocity(velocity: Nullable<Vector3>): void;
  20183. /**
  20184. * Gets the angular velocity
  20185. * @returns angular velocity or null
  20186. */
  20187. getAngularVelocity(): Nullable<Vector3>;
  20188. /**
  20189. * Sets the angular velocity
  20190. * @param velocity The velocity or null
  20191. */
  20192. setAngularVelocity(velocity: Nullable<Vector3>): void;
  20193. /**
  20194. * Execute a function with the physics plugin native code
  20195. * Provide a function the will have two variables - the world object and the physics body object
  20196. * @param func The function to execute with the physics plugin native code
  20197. */
  20198. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  20199. /**
  20200. * Register a function that will be executed before the physics world is stepping forward
  20201. * @param func The function to execute before the physics world is stepped forward
  20202. */
  20203. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20204. /**
  20205. * Unregister a function that will be executed before the physics world is stepping forward
  20206. * @param func The function to execute before the physics world is stepped forward
  20207. */
  20208. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20209. /**
  20210. * Register a function that will be executed after the physics step
  20211. * @param func The function to execute after physics step
  20212. */
  20213. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20214. /**
  20215. * Unregisters a function that will be executed after the physics step
  20216. * @param func The function to execute after physics step
  20217. */
  20218. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20219. /**
  20220. * register a function that will be executed when this impostor collides against a different body
  20221. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  20222. * @param func Callback that is executed on collision
  20223. */
  20224. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  20225. /**
  20226. * Unregisters the physics imposter on contact
  20227. * @param collideAgainst The physics object to collide against
  20228. * @param func Callback to execute on collision
  20229. */
  20230. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  20231. private _tmpQuat;
  20232. private _tmpQuat2;
  20233. /**
  20234. * Get the parent rotation
  20235. * @returns The parent rotation
  20236. */
  20237. getParentsRotation(): Quaternion;
  20238. /**
  20239. * this function is executed by the physics engine.
  20240. */
  20241. beforeStep: () => void;
  20242. /**
  20243. * this function is executed by the physics engine
  20244. */
  20245. afterStep: () => void;
  20246. /**
  20247. * Legacy collision detection event support
  20248. */
  20249. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  20250. /**
  20251. * event and body object due to cannon's event-based architecture.
  20252. */
  20253. onCollide: (e: {
  20254. body: any;
  20255. }) => void;
  20256. /**
  20257. * Apply a force
  20258. * @param force The force to apply
  20259. * @param contactPoint The contact point for the force
  20260. * @returns The physics imposter
  20261. */
  20262. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  20263. /**
  20264. * Apply an impulse
  20265. * @param force The impulse force
  20266. * @param contactPoint The contact point for the impulse force
  20267. * @returns The physics imposter
  20268. */
  20269. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  20270. /**
  20271. * A help function to create a joint
  20272. * @param otherImpostor A physics imposter used to create a joint
  20273. * @param jointType The type of joint
  20274. * @param jointData The data for the joint
  20275. * @returns The physics imposter
  20276. */
  20277. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  20278. /**
  20279. * Add a joint to this impostor with a different impostor
  20280. * @param otherImpostor A physics imposter used to add a joint
  20281. * @param joint The joint to add
  20282. * @returns The physics imposter
  20283. */
  20284. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  20285. /**
  20286. * Will keep this body still, in a sleep mode.
  20287. * @returns the physics imposter
  20288. */
  20289. sleep(): PhysicsImpostor;
  20290. /**
  20291. * Wake the body up.
  20292. * @returns The physics imposter
  20293. */
  20294. wakeUp(): PhysicsImpostor;
  20295. /**
  20296. * Clones the physics imposter
  20297. * @param newObject The physics imposter clones to this physics-enabled object
  20298. * @returns A nullable physics imposter
  20299. */
  20300. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  20301. /**
  20302. * Disposes the physics imposter
  20303. */
  20304. dispose(): void;
  20305. /**
  20306. * Sets the delta position
  20307. * @param position The delta position amount
  20308. */
  20309. setDeltaPosition(position: Vector3): void;
  20310. /**
  20311. * Sets the delta rotation
  20312. * @param rotation The delta rotation amount
  20313. */
  20314. setDeltaRotation(rotation: Quaternion): void;
  20315. /**
  20316. * Gets the box size of the physics imposter and stores the result in the input parameter
  20317. * @param result Stores the box size
  20318. * @returns The physics imposter
  20319. */
  20320. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  20321. /**
  20322. * Gets the radius of the physics imposter
  20323. * @returns Radius of the physics imposter
  20324. */
  20325. getRadius(): number;
  20326. /**
  20327. * Sync a bone with this impostor
  20328. * @param bone The bone to sync to the impostor.
  20329. * @param boneMesh The mesh that the bone is influencing.
  20330. * @param jointPivot The pivot of the joint / bone in local space.
  20331. * @param distToJoint Optional distance from the impostor to the joint.
  20332. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  20333. */
  20334. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  20335. /**
  20336. * Sync impostor to a bone
  20337. * @param bone The bone that the impostor will be synced to.
  20338. * @param boneMesh The mesh that the bone is influencing.
  20339. * @param jointPivot The pivot of the joint / bone in local space.
  20340. * @param distToJoint Optional distance from the impostor to the joint.
  20341. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  20342. * @param boneAxis Optional vector3 axis the bone is aligned with
  20343. */
  20344. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  20345. /**
  20346. * No-Imposter type
  20347. */
  20348. static NoImpostor: number;
  20349. /**
  20350. * Sphere-Imposter type
  20351. */
  20352. static SphereImpostor: number;
  20353. /**
  20354. * Box-Imposter type
  20355. */
  20356. static BoxImpostor: number;
  20357. /**
  20358. * Plane-Imposter type
  20359. */
  20360. static PlaneImpostor: number;
  20361. /**
  20362. * Mesh-imposter type
  20363. */
  20364. static MeshImpostor: number;
  20365. /**
  20366. * Cylinder-Imposter type
  20367. */
  20368. static CylinderImpostor: number;
  20369. /**
  20370. * Particle-Imposter type
  20371. */
  20372. static ParticleImpostor: number;
  20373. /**
  20374. * Heightmap-Imposter type
  20375. */
  20376. static HeightmapImpostor: number;
  20377. }
  20378. }
  20379. declare module "babylonjs/Meshes/mesh" {
  20380. import { Observable } from "babylonjs/Misc/observable";
  20381. import { IAnimatable } from "babylonjs/Misc/tools";
  20382. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  20383. import { Camera } from "babylonjs/Cameras/camera";
  20384. import { Scene } from "babylonjs/scene";
  20385. import { Matrix, Vector3, Vector2, Color4, Plane, Vector4, Path3D } from "babylonjs/Maths/math";
  20386. import { Engine } from "babylonjs/Engines/engine";
  20387. import { Node } from "babylonjs/node";
  20388. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  20389. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  20390. import { Buffer } from "babylonjs/Meshes/buffer";
  20391. import { Geometry } from "babylonjs/Meshes/geometry";
  20392. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20393. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20394. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  20395. import { Effect } from "babylonjs/Materials/effect";
  20396. import { Material } from "babylonjs/Materials/material";
  20397. import { Skeleton } from "babylonjs/Bones/skeleton";
  20398. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  20399. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  20400. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  20401. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  20402. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  20403. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  20404. /**
  20405. * Class used to represent a specific level of detail of a mesh
  20406. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  20407. */
  20408. export class MeshLODLevel {
  20409. /** Defines the distance where this level should star being displayed */
  20410. distance: number;
  20411. /** Defines the mesh to use to render this level */
  20412. mesh: Nullable<Mesh>;
  20413. /**
  20414. * Creates a new LOD level
  20415. * @param distance defines the distance where this level should star being displayed
  20416. * @param mesh defines the mesh to use to render this level
  20417. */
  20418. constructor(
  20419. /** Defines the distance where this level should star being displayed */
  20420. distance: number,
  20421. /** Defines the mesh to use to render this level */
  20422. mesh: Nullable<Mesh>);
  20423. }
  20424. /**
  20425. * @hidden
  20426. **/
  20427. export class _CreationDataStorage {
  20428. closePath?: boolean;
  20429. closeArray?: boolean;
  20430. idx: number[];
  20431. dashSize: number;
  20432. gapSize: number;
  20433. path3D: Path3D;
  20434. pathArray: Vector3[][];
  20435. arc: number;
  20436. radius: number;
  20437. cap: number;
  20438. tessellation: number;
  20439. }
  20440. /**
  20441. * @hidden
  20442. **/
  20443. class _InstanceDataStorage {
  20444. visibleInstances: any;
  20445. renderIdForInstances: number[];
  20446. batchCache: _InstancesBatch;
  20447. instancesBufferSize: number;
  20448. instancesBuffer: Nullable<Buffer>;
  20449. instancesData: Float32Array;
  20450. overridenInstanceCount: number;
  20451. }
  20452. /**
  20453. * @hidden
  20454. **/
  20455. export class _InstancesBatch {
  20456. mustReturn: boolean;
  20457. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  20458. renderSelf: boolean[];
  20459. }
  20460. /**
  20461. * Class used to represent renderable models
  20462. */
  20463. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  20464. /**
  20465. * Mesh side orientation : usually the external or front surface
  20466. */
  20467. static readonly FRONTSIDE: number;
  20468. /**
  20469. * Mesh side orientation : usually the internal or back surface
  20470. */
  20471. static readonly BACKSIDE: number;
  20472. /**
  20473. * Mesh side orientation : both internal and external or front and back surfaces
  20474. */
  20475. static readonly DOUBLESIDE: number;
  20476. /**
  20477. * Mesh side orientation : by default, `FRONTSIDE`
  20478. */
  20479. static readonly DEFAULTSIDE: number;
  20480. /**
  20481. * Mesh cap setting : no cap
  20482. */
  20483. static readonly NO_CAP: number;
  20484. /**
  20485. * Mesh cap setting : one cap at the beginning of the mesh
  20486. */
  20487. static readonly CAP_START: number;
  20488. /**
  20489. * Mesh cap setting : one cap at the end of the mesh
  20490. */
  20491. static readonly CAP_END: number;
  20492. /**
  20493. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  20494. */
  20495. static readonly CAP_ALL: number;
  20496. /**
  20497. * Gets the default side orientation.
  20498. * @param orientation the orientation to value to attempt to get
  20499. * @returns the default orientation
  20500. * @hidden
  20501. */
  20502. static _GetDefaultSideOrientation(orientation?: number): number;
  20503. private _onBeforeRenderObservable;
  20504. private _onBeforeBindObservable;
  20505. private _onAfterRenderObservable;
  20506. private _onBeforeDrawObservable;
  20507. /**
  20508. * An event triggered before rendering the mesh
  20509. */
  20510. readonly onBeforeRenderObservable: Observable<Mesh>;
  20511. /**
  20512. * An event triggered before binding the mesh
  20513. */
  20514. readonly onBeforeBindObservable: Observable<Mesh>;
  20515. /**
  20516. * An event triggered after rendering the mesh
  20517. */
  20518. readonly onAfterRenderObservable: Observable<Mesh>;
  20519. /**
  20520. * An event triggered before drawing the mesh
  20521. */
  20522. readonly onBeforeDrawObservable: Observable<Mesh>;
  20523. private _onBeforeDrawObserver;
  20524. /**
  20525. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  20526. */
  20527. onBeforeDraw: () => void;
  20528. /**
  20529. * Gets the delay loading state of the mesh (when delay loading is turned on)
  20530. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  20531. */
  20532. delayLoadState: number;
  20533. /**
  20534. * Gets the list of instances created from this mesh
  20535. * it is not supposed to be modified manually.
  20536. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  20537. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  20538. */
  20539. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  20540. /**
  20541. * Gets the file containing delay loading data for this mesh
  20542. */
  20543. delayLoadingFile: string;
  20544. /** @hidden */
  20545. _binaryInfo: any;
  20546. private _LODLevels;
  20547. /**
  20548. * User defined function used to change how LOD level selection is done
  20549. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  20550. */
  20551. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  20552. private _morphTargetManager;
  20553. /**
  20554. * Gets or sets the morph target manager
  20555. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  20556. */
  20557. morphTargetManager: Nullable<MorphTargetManager>;
  20558. /** @hidden */
  20559. _creationDataStorage: Nullable<_CreationDataStorage>;
  20560. /** @hidden */
  20561. _geometry: Nullable<Geometry>;
  20562. /** @hidden */
  20563. _delayInfo: Array<string>;
  20564. /** @hidden */
  20565. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  20566. /** @hidden */
  20567. _instanceDataStorage: _InstanceDataStorage;
  20568. private _effectiveMaterial;
  20569. /** @hidden */
  20570. _shouldGenerateFlatShading: boolean;
  20571. private _preActivateId;
  20572. /** @hidden */
  20573. _originalBuilderSideOrientation: number;
  20574. /**
  20575. * Use this property to change the original side orientation defined at construction time
  20576. */
  20577. overrideMaterialSideOrientation: Nullable<number>;
  20578. private _areNormalsFrozen;
  20579. private _sourcePositions;
  20580. private _sourceNormals;
  20581. private _source;
  20582. private meshMap;
  20583. /**
  20584. * Gets the source mesh (the one used to clone this one from)
  20585. */
  20586. readonly source: Nullable<Mesh>;
  20587. /**
  20588. * Gets or sets a boolean indicating that this mesh does not use index buffer
  20589. */
  20590. isUnIndexed: boolean;
  20591. /**
  20592. * @constructor
  20593. * @param name The value used by scene.getMeshByName() to do a lookup.
  20594. * @param scene The scene to add this mesh to.
  20595. * @param parent The parent of this mesh, if it has one
  20596. * @param source An optional Mesh from which geometry is shared, cloned.
  20597. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  20598. * When false, achieved by calling a clone(), also passing False.
  20599. * This will make creation of children, recursive.
  20600. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  20601. */
  20602. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  20603. /**
  20604. * Gets the class name
  20605. * @returns the string "Mesh".
  20606. */
  20607. getClassName(): string;
  20608. /** @hidden */
  20609. readonly _isMesh: boolean;
  20610. /**
  20611. * Returns a description of this mesh
  20612. * @param fullDetails define if full details about this mesh must be used
  20613. * @returns a descriptive string representing this mesh
  20614. */
  20615. toString(fullDetails?: boolean): string;
  20616. /** @hidden */
  20617. _unBindEffect(): void;
  20618. /**
  20619. * Gets a boolean indicating if this mesh has LOD
  20620. */
  20621. readonly hasLODLevels: boolean;
  20622. /**
  20623. * Gets the list of MeshLODLevel associated with the current mesh
  20624. * @returns an array of MeshLODLevel
  20625. */
  20626. getLODLevels(): MeshLODLevel[];
  20627. private _sortLODLevels;
  20628. /**
  20629. * Add a mesh as LOD level triggered at the given distance.
  20630. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20631. * @param distance The distance from the center of the object to show this level
  20632. * @param mesh The mesh to be added as LOD level (can be null)
  20633. * @return This mesh (for chaining)
  20634. */
  20635. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  20636. /**
  20637. * Returns the LOD level mesh at the passed distance or null if not found.
  20638. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20639. * @param distance The distance from the center of the object to show this level
  20640. * @returns a Mesh or `null`
  20641. */
  20642. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  20643. /**
  20644. * Remove a mesh from the LOD array
  20645. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20646. * @param mesh defines the mesh to be removed
  20647. * @return This mesh (for chaining)
  20648. */
  20649. removeLODLevel(mesh: Mesh): Mesh;
  20650. /**
  20651. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  20652. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20653. * @param camera defines the camera to use to compute distance
  20654. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  20655. * @return This mesh (for chaining)
  20656. */
  20657. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  20658. /**
  20659. * Gets the mesh internal Geometry object
  20660. */
  20661. readonly geometry: Nullable<Geometry>;
  20662. /**
  20663. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  20664. * @returns the total number of vertices
  20665. */
  20666. getTotalVertices(): number;
  20667. /**
  20668. * Returns the content of an associated vertex buffer
  20669. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  20670. * - VertexBuffer.PositionKind
  20671. * - VertexBuffer.UVKind
  20672. * - VertexBuffer.UV2Kind
  20673. * - VertexBuffer.UV3Kind
  20674. * - VertexBuffer.UV4Kind
  20675. * - VertexBuffer.UV5Kind
  20676. * - VertexBuffer.UV6Kind
  20677. * - VertexBuffer.ColorKind
  20678. * - VertexBuffer.MatricesIndicesKind
  20679. * - VertexBuffer.MatricesIndicesExtraKind
  20680. * - VertexBuffer.MatricesWeightsKind
  20681. * - VertexBuffer.MatricesWeightsExtraKind
  20682. * @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
  20683. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  20684. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  20685. */
  20686. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  20687. /**
  20688. * Returns the mesh VertexBuffer object from the requested `kind`
  20689. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  20690. * - VertexBuffer.PositionKind
  20691. * - VertexBuffer.UVKind
  20692. * - VertexBuffer.UV2Kind
  20693. * - VertexBuffer.UV3Kind
  20694. * - VertexBuffer.UV4Kind
  20695. * - VertexBuffer.UV5Kind
  20696. * - VertexBuffer.UV6Kind
  20697. * - VertexBuffer.ColorKind
  20698. * - VertexBuffer.MatricesIndicesKind
  20699. * - VertexBuffer.MatricesIndicesExtraKind
  20700. * - VertexBuffer.MatricesWeightsKind
  20701. * - VertexBuffer.MatricesWeightsExtraKind
  20702. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  20703. */
  20704. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  20705. /**
  20706. * Tests if a specific vertex buffer is associated with this mesh
  20707. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  20708. * - VertexBuffer.PositionKind
  20709. * - VertexBuffer.UVKind
  20710. * - VertexBuffer.UV2Kind
  20711. * - VertexBuffer.UV3Kind
  20712. * - VertexBuffer.UV4Kind
  20713. * - VertexBuffer.UV5Kind
  20714. * - VertexBuffer.UV6Kind
  20715. * - VertexBuffer.ColorKind
  20716. * - VertexBuffer.MatricesIndicesKind
  20717. * - VertexBuffer.MatricesIndicesExtraKind
  20718. * - VertexBuffer.MatricesWeightsKind
  20719. * - VertexBuffer.MatricesWeightsExtraKind
  20720. * @returns a boolean
  20721. */
  20722. isVerticesDataPresent(kind: string): boolean;
  20723. /**
  20724. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  20725. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  20726. * - VertexBuffer.PositionKind
  20727. * - VertexBuffer.UVKind
  20728. * - VertexBuffer.UV2Kind
  20729. * - VertexBuffer.UV3Kind
  20730. * - VertexBuffer.UV4Kind
  20731. * - VertexBuffer.UV5Kind
  20732. * - VertexBuffer.UV6Kind
  20733. * - VertexBuffer.ColorKind
  20734. * - VertexBuffer.MatricesIndicesKind
  20735. * - VertexBuffer.MatricesIndicesExtraKind
  20736. * - VertexBuffer.MatricesWeightsKind
  20737. * - VertexBuffer.MatricesWeightsExtraKind
  20738. * @returns a boolean
  20739. */
  20740. isVertexBufferUpdatable(kind: string): boolean;
  20741. /**
  20742. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  20743. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  20744. * - VertexBuffer.PositionKind
  20745. * - VertexBuffer.UVKind
  20746. * - VertexBuffer.UV2Kind
  20747. * - VertexBuffer.UV3Kind
  20748. * - VertexBuffer.UV4Kind
  20749. * - VertexBuffer.UV5Kind
  20750. * - VertexBuffer.UV6Kind
  20751. * - VertexBuffer.ColorKind
  20752. * - VertexBuffer.MatricesIndicesKind
  20753. * - VertexBuffer.MatricesIndicesExtraKind
  20754. * - VertexBuffer.MatricesWeightsKind
  20755. * - VertexBuffer.MatricesWeightsExtraKind
  20756. * @returns an array of strings
  20757. */
  20758. getVerticesDataKinds(): string[];
  20759. /**
  20760. * Returns a positive integer : the total number of indices in this mesh geometry.
  20761. * @returns the numner of indices or zero if the mesh has no geometry.
  20762. */
  20763. getTotalIndices(): number;
  20764. /**
  20765. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  20766. * @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.
  20767. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  20768. * @returns the indices array or an empty array if the mesh has no geometry
  20769. */
  20770. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  20771. readonly isBlocked: boolean;
  20772. /**
  20773. * Determine if the current mesh is ready to be rendered
  20774. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  20775. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  20776. * @returns true if all associated assets are ready (material, textures, shaders)
  20777. */
  20778. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  20779. /**
  20780. * 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.
  20781. */
  20782. readonly areNormalsFrozen: boolean;
  20783. /**
  20784. * 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.
  20785. * @returns the current mesh
  20786. */
  20787. freezeNormals(): Mesh;
  20788. /**
  20789. * 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
  20790. * @returns the current mesh
  20791. */
  20792. unfreezeNormals(): Mesh;
  20793. /**
  20794. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  20795. */
  20796. overridenInstanceCount: number;
  20797. /** @hidden */
  20798. _preActivate(): Mesh;
  20799. /** @hidden */
  20800. _preActivateForIntermediateRendering(renderId: number): Mesh;
  20801. /** @hidden */
  20802. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  20803. /**
  20804. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  20805. * This means the mesh underlying bounding box and sphere are recomputed.
  20806. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  20807. * @returns the current mesh
  20808. */
  20809. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  20810. /** @hidden */
  20811. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  20812. /**
  20813. * This function will subdivide the mesh into multiple submeshes
  20814. * @param count defines the expected number of submeshes
  20815. */
  20816. subdivide(count: number): void;
  20817. /**
  20818. * Copy a FloatArray into a specific associated vertex buffer
  20819. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  20820. * - VertexBuffer.PositionKind
  20821. * - VertexBuffer.UVKind
  20822. * - VertexBuffer.UV2Kind
  20823. * - VertexBuffer.UV3Kind
  20824. * - VertexBuffer.UV4Kind
  20825. * - VertexBuffer.UV5Kind
  20826. * - VertexBuffer.UV6Kind
  20827. * - VertexBuffer.ColorKind
  20828. * - VertexBuffer.MatricesIndicesKind
  20829. * - VertexBuffer.MatricesIndicesExtraKind
  20830. * - VertexBuffer.MatricesWeightsKind
  20831. * - VertexBuffer.MatricesWeightsExtraKind
  20832. * @param data defines the data source
  20833. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  20834. * @param stride defines the data stride size (can be null)
  20835. * @returns the current mesh
  20836. */
  20837. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  20838. /**
  20839. * Flags an associated vertex buffer as updatable
  20840. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  20841. * - VertexBuffer.PositionKind
  20842. * - VertexBuffer.UVKind
  20843. * - VertexBuffer.UV2Kind
  20844. * - VertexBuffer.UV3Kind
  20845. * - VertexBuffer.UV4Kind
  20846. * - VertexBuffer.UV5Kind
  20847. * - VertexBuffer.UV6Kind
  20848. * - VertexBuffer.ColorKind
  20849. * - VertexBuffer.MatricesIndicesKind
  20850. * - VertexBuffer.MatricesIndicesExtraKind
  20851. * - VertexBuffer.MatricesWeightsKind
  20852. * - VertexBuffer.MatricesWeightsExtraKind
  20853. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  20854. */
  20855. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  20856. /**
  20857. * Sets the mesh global Vertex Buffer
  20858. * @param buffer defines the buffer to use
  20859. * @returns the current mesh
  20860. */
  20861. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  20862. /**
  20863. * Update a specific associated vertex buffer
  20864. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  20865. * - VertexBuffer.PositionKind
  20866. * - VertexBuffer.UVKind
  20867. * - VertexBuffer.UV2Kind
  20868. * - VertexBuffer.UV3Kind
  20869. * - VertexBuffer.UV4Kind
  20870. * - VertexBuffer.UV5Kind
  20871. * - VertexBuffer.UV6Kind
  20872. * - VertexBuffer.ColorKind
  20873. * - VertexBuffer.MatricesIndicesKind
  20874. * - VertexBuffer.MatricesIndicesExtraKind
  20875. * - VertexBuffer.MatricesWeightsKind
  20876. * - VertexBuffer.MatricesWeightsExtraKind
  20877. * @param data defines the data source
  20878. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  20879. * @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)
  20880. * @returns the current mesh
  20881. */
  20882. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  20883. /**
  20884. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  20885. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  20886. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  20887. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  20888. * @returns the current mesh
  20889. */
  20890. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  20891. /**
  20892. * Creates a un-shared specific occurence of the geometry for the mesh.
  20893. * @returns the current mesh
  20894. */
  20895. makeGeometryUnique(): Mesh;
  20896. /**
  20897. * Set the index buffer of this mesh
  20898. * @param indices defines the source data
  20899. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  20900. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  20901. * @returns the current mesh
  20902. */
  20903. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  20904. /**
  20905. * Update the current index buffer
  20906. * @param indices defines the source data
  20907. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  20908. * @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)
  20909. * @returns the current mesh
  20910. */
  20911. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  20912. /**
  20913. * Invert the geometry to move from a right handed system to a left handed one.
  20914. * @returns the current mesh
  20915. */
  20916. toLeftHanded(): Mesh;
  20917. /** @hidden */
  20918. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  20919. /** @hidden */
  20920. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number, alternate?: boolean): Mesh;
  20921. /**
  20922. * Registers for this mesh a javascript function called just before the rendering process
  20923. * @param func defines the function to call before rendering this mesh
  20924. * @returns the current mesh
  20925. */
  20926. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  20927. /**
  20928. * Disposes a previously registered javascript function called before the rendering
  20929. * @param func defines the function to remove
  20930. * @returns the current mesh
  20931. */
  20932. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  20933. /**
  20934. * Registers for this mesh a javascript function called just after the rendering is complete
  20935. * @param func defines the function to call after rendering this mesh
  20936. * @returns the current mesh
  20937. */
  20938. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  20939. /**
  20940. * Disposes a previously registered javascript function called after the rendering.
  20941. * @param func defines the function to remove
  20942. * @returns the current mesh
  20943. */
  20944. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  20945. /** @hidden */
  20946. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  20947. /** @hidden */
  20948. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  20949. /** @hidden */
  20950. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  20951. /**
  20952. * 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
  20953. * @param subMesh defines the subMesh to render
  20954. * @param enableAlphaMode defines if alpha mode can be changed
  20955. * @returns the current mesh
  20956. */
  20957. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  20958. private _onBeforeDraw;
  20959. /**
  20960. * Renormalize the mesh and patch it up if there are no weights
  20961. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  20962. * However in the case of zero weights then we set just a single influence to 1.
  20963. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  20964. */
  20965. cleanMatrixWeights(): void;
  20966. private normalizeSkinFourWeights;
  20967. private normalizeSkinWeightsAndExtra;
  20968. /**
  20969. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  20970. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  20971. * the user know there was an issue with importing the mesh
  20972. * @returns a validation object with skinned, valid and report string
  20973. */
  20974. validateSkinning(): {
  20975. skinned: boolean;
  20976. valid: boolean;
  20977. report: string;
  20978. };
  20979. /** @hidden */
  20980. _checkDelayState(): Mesh;
  20981. private _queueLoad;
  20982. /**
  20983. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  20984. * A mesh is in the frustum if its bounding box intersects the frustum
  20985. * @param frustumPlanes defines the frustum to test
  20986. * @returns true if the mesh is in the frustum planes
  20987. */
  20988. isInFrustum(frustumPlanes: Plane[]): boolean;
  20989. /**
  20990. * Sets the mesh material by the material or multiMaterial `id` property
  20991. * @param id is a string identifying the material or the multiMaterial
  20992. * @returns the current mesh
  20993. */
  20994. setMaterialByID(id: string): Mesh;
  20995. /**
  20996. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  20997. * @returns an array of IAnimatable
  20998. */
  20999. getAnimatables(): IAnimatable[];
  21000. /**
  21001. * Modifies the mesh geometry according to the passed transformation matrix.
  21002. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  21003. * The mesh normals are modified using the same transformation.
  21004. * Note that, under the hood, this method sets a new VertexBuffer each call.
  21005. * @param transform defines the transform matrix to use
  21006. * @see http://doc.babylonjs.com/resources/baking_transformations
  21007. * @returns the current mesh
  21008. */
  21009. bakeTransformIntoVertices(transform: Matrix): Mesh;
  21010. /**
  21011. * Modifies the mesh geometry according to its own current World Matrix.
  21012. * The mesh World Matrix is then reset.
  21013. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  21014. * Note that, under the hood, this method sets a new VertexBuffer each call.
  21015. * @see http://doc.babylonjs.com/resources/baking_transformations
  21016. * @returns the current mesh
  21017. */
  21018. bakeCurrentTransformIntoVertices(): Mesh;
  21019. /** @hidden */
  21020. readonly _positions: Nullable<Vector3[]>;
  21021. /** @hidden */
  21022. _resetPointsArrayCache(): Mesh;
  21023. /** @hidden */
  21024. _generatePointsArray(): boolean;
  21025. /**
  21026. * Returns a new Mesh object generated from the current mesh properties.
  21027. * This method must not get confused with createInstance()
  21028. * @param name is a string, the name given to the new mesh
  21029. * @param newParent can be any Node object (default `null`)
  21030. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  21031. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  21032. * @returns a new mesh
  21033. */
  21034. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  21035. /**
  21036. * Releases resources associated with this mesh.
  21037. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  21038. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  21039. */
  21040. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  21041. /**
  21042. * Modifies the mesh geometry according to a displacement map.
  21043. * 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.
  21044. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  21045. * @param url is a string, the URL from the image file is to be downloaded.
  21046. * @param minHeight is the lower limit of the displacement.
  21047. * @param maxHeight is the upper limit of the displacement.
  21048. * @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.
  21049. * @param uvOffset is an optional vector2 used to offset UV.
  21050. * @param uvScale is an optional vector2 used to scale UV.
  21051. * @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.
  21052. * @returns the Mesh.
  21053. */
  21054. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  21055. /**
  21056. * Modifies the mesh geometry according to a displacementMap buffer.
  21057. * 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.
  21058. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  21059. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  21060. * @param heightMapWidth is the width of the buffer image.
  21061. * @param heightMapHeight is the height of the buffer image.
  21062. * @param minHeight is the lower limit of the displacement.
  21063. * @param maxHeight is the upper limit of the displacement.
  21064. * @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.
  21065. * @param uvOffset is an optional vector2 used to offset UV.
  21066. * @param uvScale is an optional vector2 used to scale UV.
  21067. * @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.
  21068. * @returns the Mesh.
  21069. */
  21070. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  21071. /**
  21072. * Modify the mesh to get a flat shading rendering.
  21073. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  21074. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  21075. * @returns current mesh
  21076. */
  21077. convertToFlatShadedMesh(): Mesh;
  21078. /**
  21079. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  21080. * In other words, more vertices, no more indices and a single bigger VBO.
  21081. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  21082. * @returns current mesh
  21083. */
  21084. convertToUnIndexedMesh(): Mesh;
  21085. /**
  21086. * Inverses facet orientations.
  21087. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  21088. * @param flipNormals will also inverts the normals
  21089. * @returns current mesh
  21090. */
  21091. flipFaces(flipNormals?: boolean): Mesh;
  21092. /** @hidden */
  21093. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  21094. /** @hidden */
  21095. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  21096. /**
  21097. * Creates a new InstancedMesh object from the mesh model.
  21098. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  21099. * @param name defines the name of the new instance
  21100. * @returns a new InstancedMesh
  21101. */
  21102. createInstance(name: string): InstancedMesh;
  21103. /**
  21104. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  21105. * After this call, all the mesh instances have the same submeshes than the current mesh.
  21106. * @returns the current mesh
  21107. */
  21108. synchronizeInstances(): Mesh;
  21109. /**
  21110. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  21111. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  21112. * This should be used together with the simplification to avoid disappearing triangles.
  21113. * @param successCallback an optional success callback to be called after the optimization finished.
  21114. * @returns the current mesh
  21115. */
  21116. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  21117. /**
  21118. * Serialize current mesh
  21119. * @param serializationObject defines the object which will receive the serialization data
  21120. */
  21121. serialize(serializationObject: any): void;
  21122. /** @hidden */
  21123. _syncGeometryWithMorphTargetManager(): void;
  21124. /** @hidden */
  21125. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  21126. /**
  21127. * Returns a new Mesh object parsed from the source provided.
  21128. * @param parsedMesh is the source
  21129. * @param scene defines the hosting scene
  21130. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  21131. * @returns a new Mesh
  21132. */
  21133. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  21134. /**
  21135. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  21136. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21137. * @param name defines the name of the mesh to create
  21138. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  21139. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  21140. * @param closePath creates a seam between the first and the last points of each path of the path array
  21141. * @param offset is taken in account only if the `pathArray` is containing a single path
  21142. * @param scene defines the hosting scene
  21143. * @param updatable defines if the mesh must be flagged as updatable
  21144. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21145. * @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)
  21146. * @returns a new Mesh
  21147. */
  21148. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21149. /**
  21150. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  21151. * @param name defines the name of the mesh to create
  21152. * @param radius sets the radius size (float) of the polygon (default 0.5)
  21153. * @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
  21154. * @param scene defines the hosting scene
  21155. * @param updatable defines if the mesh must be flagged as updatable
  21156. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21157. * @returns a new Mesh
  21158. */
  21159. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  21160. /**
  21161. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  21162. * @param name defines the name of the mesh to create
  21163. * @param size sets the size (float) of each box side (default 1)
  21164. * @param scene defines the hosting scene
  21165. * @param updatable defines if the mesh must be flagged as updatable
  21166. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21167. * @returns a new Mesh
  21168. */
  21169. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  21170. /**
  21171. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  21172. * @param name defines the name of the mesh to create
  21173. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  21174. * @param diameter sets the diameter size (float) of the sphere (default 1)
  21175. * @param scene defines the hosting scene
  21176. * @param updatable defines if the mesh must be flagged as updatable
  21177. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21178. * @returns a new Mesh
  21179. */
  21180. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21181. /**
  21182. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  21183. * @param name defines the name of the mesh to create
  21184. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  21185. * @param diameterTop set the top cap diameter (floats, default 1)
  21186. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  21187. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  21188. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  21189. * @param scene defines the hosting scene
  21190. * @param updatable defines if the mesh must be flagged as updatable
  21191. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21192. * @returns a new Mesh
  21193. */
  21194. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  21195. /**
  21196. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  21197. * @param name defines the name of the mesh to create
  21198. * @param diameter sets the diameter size (float) of the torus (default 1)
  21199. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  21200. * @param tessellation sets the number of torus sides (postive integer, default 16)
  21201. * @param scene defines the hosting scene
  21202. * @param updatable defines if the mesh must be flagged as updatable
  21203. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21204. * @returns a new Mesh
  21205. */
  21206. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21207. /**
  21208. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  21209. * @param name defines the name of the mesh to create
  21210. * @param radius sets the global radius size (float) of the torus knot (default 2)
  21211. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  21212. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  21213. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  21214. * @param p the number of windings on X axis (positive integers, default 2)
  21215. * @param q the number of windings on Y axis (positive integers, default 3)
  21216. * @param scene defines the hosting scene
  21217. * @param updatable defines if the mesh must be flagged as updatable
  21218. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21219. * @returns a new Mesh
  21220. */
  21221. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21222. /**
  21223. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  21224. * @param name defines the name of the mesh to create
  21225. * @param points is an array successive Vector3
  21226. * @param scene defines the hosting scene
  21227. * @param updatable defines if the mesh must be flagged as updatable
  21228. * @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).
  21229. * @returns a new Mesh
  21230. */
  21231. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  21232. /**
  21233. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  21234. * @param name defines the name of the mesh to create
  21235. * @param points is an array successive Vector3
  21236. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  21237. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  21238. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  21239. * @param scene defines the hosting scene
  21240. * @param updatable defines if the mesh must be flagged as updatable
  21241. * @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)
  21242. * @returns a new Mesh
  21243. */
  21244. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  21245. /**
  21246. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  21247. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  21248. * 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.
  21249. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21250. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21251. * Remember you can only change the shape positions, not their number when updating a polygon.
  21252. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  21253. * @param name defines the name of the mesh to create
  21254. * @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
  21255. * @param scene defines the hosting scene
  21256. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  21257. * @param updatable defines if the mesh must be flagged as updatable
  21258. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21259. * @param earcutInjection can be used to inject your own earcut reference
  21260. * @returns a new Mesh
  21261. */
  21262. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  21263. /**
  21264. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  21265. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  21266. * @param name defines the name of the mesh to create
  21267. * @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
  21268. * @param depth defines the height of extrusion
  21269. * @param scene defines the hosting scene
  21270. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  21271. * @param updatable defines if the mesh must be flagged as updatable
  21272. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21273. * @param earcutInjection can be used to inject your own earcut reference
  21274. * @returns a new Mesh
  21275. */
  21276. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  21277. /**
  21278. * Creates an extruded shape mesh.
  21279. * 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
  21280. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21281. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  21282. * @param name defines the name of the mesh to create
  21283. * @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
  21284. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  21285. * @param scale is the value to scale the shape
  21286. * @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
  21287. * @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
  21288. * @param scene defines the hosting scene
  21289. * @param updatable defines if the mesh must be flagged as updatable
  21290. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21291. * @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)
  21292. * @returns a new Mesh
  21293. */
  21294. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21295. /**
  21296. * Creates an custom extruded shape mesh.
  21297. * The custom extrusion is a parametric shape.
  21298. * It has no predefined shape. Its final shape will depend on the input parameters.
  21299. * Please consider using the same method from the MeshBuilder class instead
  21300. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  21301. * @param name defines the name of the mesh to create
  21302. * @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
  21303. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  21304. * @param scaleFunction is a custom Javascript function called on each path point
  21305. * @param rotationFunction is a custom Javascript function called on each path point
  21306. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  21307. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  21308. * @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
  21309. * @param scene defines the hosting scene
  21310. * @param updatable defines if the mesh must be flagged as updatable
  21311. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21312. * @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)
  21313. * @returns a new Mesh
  21314. */
  21315. 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;
  21316. /**
  21317. * Creates lathe mesh.
  21318. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  21319. * Please consider using the same method from the MeshBuilder class instead
  21320. * @param name defines the name of the mesh to create
  21321. * @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
  21322. * @param radius is the radius value of the lathe
  21323. * @param tessellation is the side number of the lathe.
  21324. * @param scene defines the hosting scene
  21325. * @param updatable defines if the mesh must be flagged as updatable
  21326. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21327. * @returns a new Mesh
  21328. */
  21329. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21330. /**
  21331. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  21332. * @param name defines the name of the mesh to create
  21333. * @param size sets the size (float) of both sides of the plane at once (default 1)
  21334. * @param scene defines the hosting scene
  21335. * @param updatable defines if the mesh must be flagged as updatable
  21336. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21337. * @returns a new Mesh
  21338. */
  21339. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21340. /**
  21341. * Creates a ground mesh.
  21342. * Please consider using the same method from the MeshBuilder class instead
  21343. * @param name defines the name of the mesh to create
  21344. * @param width set the width of the ground
  21345. * @param height set the height of the ground
  21346. * @param subdivisions sets the number of subdivisions per side
  21347. * @param scene defines the hosting scene
  21348. * @param updatable defines if the mesh must be flagged as updatable
  21349. * @returns a new Mesh
  21350. */
  21351. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  21352. /**
  21353. * Creates a tiled ground mesh.
  21354. * Please consider using the same method from the MeshBuilder class instead
  21355. * @param name defines the name of the mesh to create
  21356. * @param xmin set the ground minimum X coordinate
  21357. * @param zmin set the ground minimum Y coordinate
  21358. * @param xmax set the ground maximum X coordinate
  21359. * @param zmax set the ground maximum Z coordinate
  21360. * @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
  21361. * @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
  21362. * @param scene defines the hosting scene
  21363. * @param updatable defines if the mesh must be flagged as updatable
  21364. * @returns a new Mesh
  21365. */
  21366. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  21367. w: number;
  21368. h: number;
  21369. }, precision: {
  21370. w: number;
  21371. h: number;
  21372. }, scene: Scene, updatable?: boolean): Mesh;
  21373. /**
  21374. * Creates a ground mesh from a height map.
  21375. * Please consider using the same method from the MeshBuilder class instead
  21376. * @see http://doc.babylonjs.com/babylon101/height_map
  21377. * @param name defines the name of the mesh to create
  21378. * @param url sets the URL of the height map image resource
  21379. * @param width set the ground width size
  21380. * @param height set the ground height size
  21381. * @param subdivisions sets the number of subdivision per side
  21382. * @param minHeight is the minimum altitude on the ground
  21383. * @param maxHeight is the maximum altitude on the ground
  21384. * @param scene defines the hosting scene
  21385. * @param updatable defines if the mesh must be flagged as updatable
  21386. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  21387. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  21388. * @returns a new Mesh
  21389. */
  21390. 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;
  21391. /**
  21392. * Creates a tube mesh.
  21393. * The tube is a parametric shape.
  21394. * It has no predefined shape. Its final shape will depend on the input parameters.
  21395. * Please consider using the same method from the MeshBuilder class instead
  21396. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21397. * @param name defines the name of the mesh to create
  21398. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  21399. * @param radius sets the tube radius size
  21400. * @param tessellation is the number of sides on the tubular surface
  21401. * @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
  21402. * @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
  21403. * @param scene defines the hosting scene
  21404. * @param updatable defines if the mesh must be flagged as updatable
  21405. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21406. * @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)
  21407. * @returns a new Mesh
  21408. */
  21409. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  21410. (i: number, distance: number): number;
  21411. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21412. /**
  21413. * Creates a polyhedron mesh.
  21414. * Please consider using the same method from the MeshBuilder class instead.
  21415. * * 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
  21416. * * The parameter `size` (positive float, default 1) sets the polygon size
  21417. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  21418. * * 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`
  21419. * * 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
  21420. * * 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)`)
  21421. * * 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
  21422. * * 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
  21423. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21424. * * If you create a double-sided mesh, you can choose what parts of 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
  21425. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21426. * @param name defines the name of the mesh to create
  21427. * @param options defines the options used to create the mesh
  21428. * @param scene defines the hosting scene
  21429. * @returns a new Mesh
  21430. */
  21431. static CreatePolyhedron(name: string, options: {
  21432. type?: number;
  21433. size?: number;
  21434. sizeX?: number;
  21435. sizeY?: number;
  21436. sizeZ?: number;
  21437. custom?: any;
  21438. faceUV?: Vector4[];
  21439. faceColors?: Color4[];
  21440. updatable?: boolean;
  21441. sideOrientation?: number;
  21442. }, scene: Scene): Mesh;
  21443. /**
  21444. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  21445. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  21446. * * 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`)
  21447. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  21448. * * 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
  21449. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21450. * * If you create a double-sided mesh, you can choose what parts of 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
  21451. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21452. * @param name defines the name of the mesh
  21453. * @param options defines the options used to create the mesh
  21454. * @param scene defines the hosting scene
  21455. * @returns a new Mesh
  21456. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  21457. */
  21458. static CreateIcoSphere(name: string, options: {
  21459. radius?: number;
  21460. flat?: boolean;
  21461. subdivisions?: number;
  21462. sideOrientation?: number;
  21463. updatable?: boolean;
  21464. }, scene: Scene): Mesh;
  21465. /**
  21466. * Creates a decal mesh.
  21467. * Please consider using the same method from the MeshBuilder class instead.
  21468. * A decal is a mesh usually applied as a model onto the surface of another mesh
  21469. * @param name defines the name of the mesh
  21470. * @param sourceMesh defines the mesh receiving the decal
  21471. * @param position sets the position of the decal in world coordinates
  21472. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  21473. * @param size sets the decal scaling
  21474. * @param angle sets the angle to rotate the decal
  21475. * @returns a new Mesh
  21476. */
  21477. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  21478. /**
  21479. * Prepare internal position array for software CPU skinning
  21480. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  21481. */
  21482. setPositionsForCPUSkinning(): Float32Array;
  21483. /**
  21484. * Prepare internal normal array for software CPU skinning
  21485. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  21486. */
  21487. setNormalsForCPUSkinning(): Float32Array;
  21488. /**
  21489. * Updates the vertex buffer by applying transformation from the bones
  21490. * @param skeleton defines the skeleton to apply to current mesh
  21491. * @returns the current mesh
  21492. */
  21493. applySkeleton(skeleton: Skeleton): Mesh;
  21494. /**
  21495. * 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
  21496. * @param meshes defines the list of meshes to scan
  21497. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  21498. */
  21499. static MinMax(meshes: AbstractMesh[]): {
  21500. min: Vector3;
  21501. max: Vector3;
  21502. };
  21503. /**
  21504. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  21505. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  21506. * @returns a vector3
  21507. */
  21508. static Center(meshesOrMinMaxVector: {
  21509. min: Vector3;
  21510. max: Vector3;
  21511. } | AbstractMesh[]): Vector3;
  21512. /**
  21513. * Merge the array of meshes into a single mesh for performance reasons.
  21514. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  21515. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  21516. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  21517. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  21518. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  21519. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  21520. * @returns a new mesh
  21521. */
  21522. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  21523. /** @hidden */
  21524. addInstance(instance: InstancedMesh): void;
  21525. /** @hidden */
  21526. removeInstance(instance: InstancedMesh): void;
  21527. }
  21528. }
  21529. declare module "babylonjs/Materials/material" {
  21530. import { IAnimatable } from "babylonjs/Misc/tools";
  21531. import { SmartArray } from "babylonjs/Misc/smartArray";
  21532. import { Observable } from "babylonjs/Misc/observable";
  21533. import { Nullable } from "babylonjs/types";
  21534. import { Scene } from "babylonjs/scene";
  21535. import { Matrix } from "babylonjs/Maths/math";
  21536. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  21537. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21538. import { Mesh } from "babylonjs/Meshes/mesh";
  21539. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  21540. import { Effect } from "babylonjs/Materials/effect";
  21541. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21542. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  21543. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21544. import { Animation } from "babylonjs/Animations/animation";
  21545. /**
  21546. * Base class for the main features of a material in Babylon.js
  21547. */
  21548. export class Material implements IAnimatable {
  21549. /**
  21550. * Returns the triangle fill mode
  21551. */
  21552. static readonly TriangleFillMode: number;
  21553. /**
  21554. * Returns the wireframe mode
  21555. */
  21556. static readonly WireFrameFillMode: number;
  21557. /**
  21558. * Returns the point fill mode
  21559. */
  21560. static readonly PointFillMode: number;
  21561. /**
  21562. * Returns the point list draw mode
  21563. */
  21564. static readonly PointListDrawMode: number;
  21565. /**
  21566. * Returns the line list draw mode
  21567. */
  21568. static readonly LineListDrawMode: number;
  21569. /**
  21570. * Returns the line loop draw mode
  21571. */
  21572. static readonly LineLoopDrawMode: number;
  21573. /**
  21574. * Returns the line strip draw mode
  21575. */
  21576. static readonly LineStripDrawMode: number;
  21577. /**
  21578. * Returns the triangle strip draw mode
  21579. */
  21580. static readonly TriangleStripDrawMode: number;
  21581. /**
  21582. * Returns the triangle fan draw mode
  21583. */
  21584. static readonly TriangleFanDrawMode: number;
  21585. /**
  21586. * Stores the clock-wise side orientation
  21587. */
  21588. static readonly ClockWiseSideOrientation: number;
  21589. /**
  21590. * Stores the counter clock-wise side orientation
  21591. */
  21592. static readonly CounterClockWiseSideOrientation: number;
  21593. /**
  21594. * The dirty texture flag value
  21595. */
  21596. static readonly TextureDirtyFlag: number;
  21597. /**
  21598. * The dirty light flag value
  21599. */
  21600. static readonly LightDirtyFlag: number;
  21601. /**
  21602. * The dirty fresnel flag value
  21603. */
  21604. static readonly FresnelDirtyFlag: number;
  21605. /**
  21606. * The dirty attribute flag value
  21607. */
  21608. static readonly AttributesDirtyFlag: number;
  21609. /**
  21610. * The dirty misc flag value
  21611. */
  21612. static readonly MiscDirtyFlag: number;
  21613. /**
  21614. * The all dirty flag value
  21615. */
  21616. static readonly AllDirtyFlag: number;
  21617. /**
  21618. * The ID of the material
  21619. */
  21620. id: string;
  21621. /**
  21622. * Gets or sets the unique id of the material
  21623. */
  21624. uniqueId: number;
  21625. /**
  21626. * The name of the material
  21627. */
  21628. name: string;
  21629. /**
  21630. * Gets or sets user defined metadata
  21631. */
  21632. metadata: any;
  21633. /**
  21634. * For internal use only. Please do not use.
  21635. */
  21636. reservedDataStore: any;
  21637. /**
  21638. * Specifies if the ready state should be checked on each call
  21639. */
  21640. checkReadyOnEveryCall: boolean;
  21641. /**
  21642. * Specifies if the ready state should be checked once
  21643. */
  21644. checkReadyOnlyOnce: boolean;
  21645. /**
  21646. * The state of the material
  21647. */
  21648. state: string;
  21649. /**
  21650. * The alpha value of the material
  21651. */
  21652. protected _alpha: number;
  21653. /**
  21654. * Sets the alpha value of the material
  21655. */
  21656. /**
  21657. * Gets the alpha value of the material
  21658. */
  21659. alpha: number;
  21660. /**
  21661. * Specifies if back face culling is enabled
  21662. */
  21663. protected _backFaceCulling: boolean;
  21664. /**
  21665. * Sets the back-face culling state
  21666. */
  21667. /**
  21668. * Gets the back-face culling state
  21669. */
  21670. backFaceCulling: boolean;
  21671. /**
  21672. * Stores the value for side orientation
  21673. */
  21674. sideOrientation: number;
  21675. /**
  21676. * Callback triggered when the material is compiled
  21677. */
  21678. onCompiled: (effect: Effect) => void;
  21679. /**
  21680. * Callback triggered when an error occurs
  21681. */
  21682. onError: (effect: Effect, errors: string) => void;
  21683. /**
  21684. * Callback triggered to get the render target textures
  21685. */
  21686. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  21687. /**
  21688. * Gets a boolean indicating that current material needs to register RTT
  21689. */
  21690. readonly hasRenderTargetTextures: boolean;
  21691. /**
  21692. * Specifies if the material should be serialized
  21693. */
  21694. doNotSerialize: boolean;
  21695. /**
  21696. * @hidden
  21697. */
  21698. _storeEffectOnSubMeshes: boolean;
  21699. /**
  21700. * Stores the animations for the material
  21701. */
  21702. animations: Array<Animation>;
  21703. /**
  21704. * An event triggered when the material is disposed
  21705. */
  21706. onDisposeObservable: Observable<Material>;
  21707. /**
  21708. * An observer which watches for dispose events
  21709. */
  21710. private _onDisposeObserver;
  21711. private _onUnBindObservable;
  21712. /**
  21713. * Called during a dispose event
  21714. */
  21715. onDispose: () => void;
  21716. private _onBindObservable;
  21717. /**
  21718. * An event triggered when the material is bound
  21719. */
  21720. readonly onBindObservable: Observable<AbstractMesh>;
  21721. /**
  21722. * An observer which watches for bind events
  21723. */
  21724. private _onBindObserver;
  21725. /**
  21726. * Called during a bind event
  21727. */
  21728. onBind: (Mesh: AbstractMesh) => void;
  21729. /**
  21730. * An event triggered when the material is unbound
  21731. */
  21732. readonly onUnBindObservable: Observable<Material>;
  21733. /**
  21734. * Stores the value of the alpha mode
  21735. */
  21736. private _alphaMode;
  21737. /**
  21738. * Sets the value of the alpha mode.
  21739. *
  21740. * | Value | Type | Description |
  21741. * | --- | --- | --- |
  21742. * | 0 | ALPHA_DISABLE | |
  21743. * | 1 | ALPHA_ADD | |
  21744. * | 2 | ALPHA_COMBINE | |
  21745. * | 3 | ALPHA_SUBTRACT | |
  21746. * | 4 | ALPHA_MULTIPLY | |
  21747. * | 5 | ALPHA_MAXIMIZED | |
  21748. * | 6 | ALPHA_ONEONE | |
  21749. * | 7 | ALPHA_PREMULTIPLIED | |
  21750. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  21751. * | 9 | ALPHA_INTERPOLATE | |
  21752. * | 10 | ALPHA_SCREENMODE | |
  21753. *
  21754. */
  21755. /**
  21756. * Gets the value of the alpha mode
  21757. */
  21758. alphaMode: number;
  21759. /**
  21760. * Stores the state of the need depth pre-pass value
  21761. */
  21762. private _needDepthPrePass;
  21763. /**
  21764. * Sets the need depth pre-pass value
  21765. */
  21766. /**
  21767. * Gets the depth pre-pass value
  21768. */
  21769. needDepthPrePass: boolean;
  21770. /**
  21771. * Specifies if depth writing should be disabled
  21772. */
  21773. disableDepthWrite: boolean;
  21774. /**
  21775. * Specifies if depth writing should be forced
  21776. */
  21777. forceDepthWrite: boolean;
  21778. /**
  21779. * Specifies if there should be a separate pass for culling
  21780. */
  21781. separateCullingPass: boolean;
  21782. /**
  21783. * Stores the state specifing if fog should be enabled
  21784. */
  21785. private _fogEnabled;
  21786. /**
  21787. * Sets the state for enabling fog
  21788. */
  21789. /**
  21790. * Gets the value of the fog enabled state
  21791. */
  21792. fogEnabled: boolean;
  21793. /**
  21794. * Stores the size of points
  21795. */
  21796. pointSize: number;
  21797. /**
  21798. * Stores the z offset value
  21799. */
  21800. zOffset: number;
  21801. /**
  21802. * Gets a value specifying if wireframe mode is enabled
  21803. */
  21804. /**
  21805. * Sets the state of wireframe mode
  21806. */
  21807. wireframe: boolean;
  21808. /**
  21809. * Gets the value specifying if point clouds are enabled
  21810. */
  21811. /**
  21812. * Sets the state of point cloud mode
  21813. */
  21814. pointsCloud: boolean;
  21815. /**
  21816. * Gets the material fill mode
  21817. */
  21818. /**
  21819. * Sets the material fill mode
  21820. */
  21821. fillMode: number;
  21822. /**
  21823. * @hidden
  21824. * Stores the effects for the material
  21825. */
  21826. _effect: Nullable<Effect>;
  21827. /**
  21828. * @hidden
  21829. * Specifies if the material was previously ready
  21830. */
  21831. _wasPreviouslyReady: boolean;
  21832. /**
  21833. * Specifies if uniform buffers should be used
  21834. */
  21835. private _useUBO;
  21836. /**
  21837. * Stores a reference to the scene
  21838. */
  21839. private _scene;
  21840. /**
  21841. * Stores the fill mode state
  21842. */
  21843. private _fillMode;
  21844. /**
  21845. * Specifies if the depth write state should be cached
  21846. */
  21847. private _cachedDepthWriteState;
  21848. /**
  21849. * Stores the uniform buffer
  21850. */
  21851. protected _uniformBuffer: UniformBuffer;
  21852. /** @hidden */
  21853. _indexInSceneMaterialArray: number;
  21854. /** @hidden */
  21855. meshMap: Nullable<{
  21856. [id: string]: AbstractMesh | undefined;
  21857. }>;
  21858. /**
  21859. * Creates a material instance
  21860. * @param name defines the name of the material
  21861. * @param scene defines the scene to reference
  21862. * @param doNotAdd specifies if the material should be added to the scene
  21863. */
  21864. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  21865. /**
  21866. * Returns a string representation of the current material
  21867. * @param fullDetails defines a boolean indicating which levels of logging is desired
  21868. * @returns a string with material information
  21869. */
  21870. toString(fullDetails?: boolean): string;
  21871. /**
  21872. * Gets the class name of the material
  21873. * @returns a string with the class name of the material
  21874. */
  21875. getClassName(): string;
  21876. /**
  21877. * Specifies if updates for the material been locked
  21878. */
  21879. readonly isFrozen: boolean;
  21880. /**
  21881. * Locks updates for the material
  21882. */
  21883. freeze(): void;
  21884. /**
  21885. * Unlocks updates for the material
  21886. */
  21887. unfreeze(): void;
  21888. /**
  21889. * Specifies if the material is ready to be used
  21890. * @param mesh defines the mesh to check
  21891. * @param useInstances specifies if instances should be used
  21892. * @returns a boolean indicating if the material is ready to be used
  21893. */
  21894. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21895. /**
  21896. * Specifies that the submesh is ready to be used
  21897. * @param mesh defines the mesh to check
  21898. * @param subMesh defines which submesh to check
  21899. * @param useInstances specifies that instances should be used
  21900. * @returns a boolean indicating that the submesh is ready or not
  21901. */
  21902. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21903. /**
  21904. * Returns the material effect
  21905. * @returns the effect associated with the material
  21906. */
  21907. getEffect(): Nullable<Effect>;
  21908. /**
  21909. * Returns the current scene
  21910. * @returns a Scene
  21911. */
  21912. getScene(): Scene;
  21913. /**
  21914. * Specifies if the material will require alpha blending
  21915. * @returns a boolean specifying if alpha blending is needed
  21916. */
  21917. needAlphaBlending(): boolean;
  21918. /**
  21919. * Specifies if the mesh will require alpha blending
  21920. * @param mesh defines the mesh to check
  21921. * @returns a boolean specifying if alpha blending is needed for the mesh
  21922. */
  21923. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  21924. /**
  21925. * Specifies if this material should be rendered in alpha test mode
  21926. * @returns a boolean specifying if an alpha test is needed.
  21927. */
  21928. needAlphaTesting(): boolean;
  21929. /**
  21930. * Gets the texture used for the alpha test
  21931. * @returns the texture to use for alpha testing
  21932. */
  21933. getAlphaTestTexture(): Nullable<BaseTexture>;
  21934. /**
  21935. * Marks the material to indicate that it needs to be re-calculated
  21936. */
  21937. markDirty(): void;
  21938. /** @hidden */
  21939. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  21940. /**
  21941. * Binds the material to the mesh
  21942. * @param world defines the world transformation matrix
  21943. * @param mesh defines the mesh to bind the material to
  21944. */
  21945. bind(world: Matrix, mesh?: Mesh): void;
  21946. /**
  21947. * Binds the submesh to the material
  21948. * @param world defines the world transformation matrix
  21949. * @param mesh defines the mesh containing the submesh
  21950. * @param subMesh defines the submesh to bind the material to
  21951. */
  21952. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  21953. /**
  21954. * Binds the world matrix to the material
  21955. * @param world defines the world transformation matrix
  21956. */
  21957. bindOnlyWorldMatrix(world: Matrix): void;
  21958. /**
  21959. * Binds the scene's uniform buffer to the effect.
  21960. * @param effect defines the effect to bind to the scene uniform buffer
  21961. * @param sceneUbo defines the uniform buffer storing scene data
  21962. */
  21963. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  21964. /**
  21965. * Binds the view matrix to the effect
  21966. * @param effect defines the effect to bind the view matrix to
  21967. */
  21968. bindView(effect: Effect): void;
  21969. /**
  21970. * Binds the view projection matrix to the effect
  21971. * @param effect defines the effect to bind the view projection matrix to
  21972. */
  21973. bindViewProjection(effect: Effect): void;
  21974. /**
  21975. * Specifies if material alpha testing should be turned on for the mesh
  21976. * @param mesh defines the mesh to check
  21977. */
  21978. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  21979. /**
  21980. * Processes to execute after binding the material to a mesh
  21981. * @param mesh defines the rendered mesh
  21982. */
  21983. protected _afterBind(mesh?: Mesh): void;
  21984. /**
  21985. * Unbinds the material from the mesh
  21986. */
  21987. unbind(): void;
  21988. /**
  21989. * Gets the active textures from the material
  21990. * @returns an array of textures
  21991. */
  21992. getActiveTextures(): BaseTexture[];
  21993. /**
  21994. * Specifies if the material uses a texture
  21995. * @param texture defines the texture to check against the material
  21996. * @returns a boolean specifying if the material uses the texture
  21997. */
  21998. hasTexture(texture: BaseTexture): boolean;
  21999. /**
  22000. * Makes a duplicate of the material, and gives it a new name
  22001. * @param name defines the new name for the duplicated material
  22002. * @returns the cloned material
  22003. */
  22004. clone(name: string): Nullable<Material>;
  22005. /**
  22006. * Gets the meshes bound to the material
  22007. * @returns an array of meshes bound to the material
  22008. */
  22009. getBindedMeshes(): AbstractMesh[];
  22010. /**
  22011. * Force shader compilation
  22012. * @param mesh defines the mesh associated with this material
  22013. * @param onCompiled defines a function to execute once the material is compiled
  22014. * @param options defines the options to configure the compilation
  22015. */
  22016. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  22017. clipPlane: boolean;
  22018. }>): void;
  22019. /**
  22020. * Force shader compilation
  22021. * @param mesh defines the mesh that will use this material
  22022. * @param options defines additional options for compiling the shaders
  22023. * @returns a promise that resolves when the compilation completes
  22024. */
  22025. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  22026. clipPlane: boolean;
  22027. }>): Promise<void>;
  22028. private static readonly _ImageProcessingDirtyCallBack;
  22029. private static readonly _TextureDirtyCallBack;
  22030. private static readonly _FresnelDirtyCallBack;
  22031. private static readonly _MiscDirtyCallBack;
  22032. private static readonly _LightsDirtyCallBack;
  22033. private static readonly _AttributeDirtyCallBack;
  22034. private static _FresnelAndMiscDirtyCallBack;
  22035. private static _TextureAndMiscDirtyCallBack;
  22036. private static readonly _DirtyCallbackArray;
  22037. private static readonly _RunDirtyCallBacks;
  22038. /**
  22039. * Marks a define in the material to indicate that it needs to be re-computed
  22040. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  22041. */
  22042. markAsDirty(flag: number): void;
  22043. /**
  22044. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  22045. * @param func defines a function which checks material defines against the submeshes
  22046. */
  22047. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  22048. /**
  22049. * Indicates that image processing needs to be re-calculated for all submeshes
  22050. */
  22051. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  22052. /**
  22053. * Indicates that textures need to be re-calculated for all submeshes
  22054. */
  22055. protected _markAllSubMeshesAsTexturesDirty(): void;
  22056. /**
  22057. * Indicates that fresnel needs to be re-calculated for all submeshes
  22058. */
  22059. protected _markAllSubMeshesAsFresnelDirty(): void;
  22060. /**
  22061. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  22062. */
  22063. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  22064. /**
  22065. * Indicates that lights need to be re-calculated for all submeshes
  22066. */
  22067. protected _markAllSubMeshesAsLightsDirty(): void;
  22068. /**
  22069. * Indicates that attributes need to be re-calculated for all submeshes
  22070. */
  22071. protected _markAllSubMeshesAsAttributesDirty(): void;
  22072. /**
  22073. * Indicates that misc needs to be re-calculated for all submeshes
  22074. */
  22075. protected _markAllSubMeshesAsMiscDirty(): void;
  22076. /**
  22077. * Indicates that textures and misc need to be re-calculated for all submeshes
  22078. */
  22079. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  22080. /**
  22081. * Disposes the material
  22082. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  22083. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  22084. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  22085. */
  22086. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  22087. /** @hidden */
  22088. private releaseVertexArrayObject;
  22089. /**
  22090. * Serializes this material
  22091. * @returns the serialized material object
  22092. */
  22093. serialize(): any;
  22094. /**
  22095. * Creates a material from parsed material data
  22096. * @param parsedMaterial defines parsed material data
  22097. * @param scene defines the hosting scene
  22098. * @param rootUrl defines the root URL to use to load textures
  22099. * @returns a new material
  22100. */
  22101. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): any;
  22102. }
  22103. }
  22104. declare module "babylonjs/Meshes/subMesh" {
  22105. import { Nullable, IndicesArray, DeepImmutable } from "babylonjs/types";
  22106. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  22107. import { Engine } from "babylonjs/Engines/engine";
  22108. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  22109. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  22110. import { Effect } from "babylonjs/Materials/effect";
  22111. import { Collider } from "babylonjs/Collisions/collider";
  22112. import { Material } from "babylonjs/Materials/material";
  22113. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  22114. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22115. import { Mesh } from "babylonjs/Meshes/mesh";
  22116. import { Ray } from "babylonjs/Culling/ray";
  22117. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  22118. /**
  22119. * Base class for submeshes
  22120. */
  22121. export class BaseSubMesh {
  22122. /** @hidden */
  22123. _materialDefines: Nullable<MaterialDefines>;
  22124. /** @hidden */
  22125. _materialEffect: Nullable<Effect>;
  22126. /**
  22127. * Gets associated effect
  22128. */
  22129. readonly effect: Nullable<Effect>;
  22130. /**
  22131. * Sets associated effect (effect used to render this submesh)
  22132. * @param effect defines the effect to associate with
  22133. * @param defines defines the set of defines used to compile this effect
  22134. */
  22135. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  22136. }
  22137. /**
  22138. * Defines a subdivision inside a mesh
  22139. */
  22140. export class SubMesh extends BaseSubMesh implements ICullable {
  22141. /** the material index to use */
  22142. materialIndex: number;
  22143. /** vertex index start */
  22144. verticesStart: number;
  22145. /** vertices count */
  22146. verticesCount: number;
  22147. /** index start */
  22148. indexStart: number;
  22149. /** indices count */
  22150. indexCount: number;
  22151. /** @hidden */
  22152. _linesIndexCount: number;
  22153. private _mesh;
  22154. private _renderingMesh;
  22155. private _boundingInfo;
  22156. private _linesIndexBuffer;
  22157. /** @hidden */
  22158. _lastColliderWorldVertices: Nullable<Vector3[]>;
  22159. /** @hidden */
  22160. _trianglePlanes: Plane[];
  22161. /** @hidden */
  22162. _lastColliderTransformMatrix: Matrix;
  22163. /** @hidden */
  22164. _renderId: number;
  22165. /** @hidden */
  22166. _alphaIndex: number;
  22167. /** @hidden */
  22168. _distanceToCamera: number;
  22169. /** @hidden */
  22170. _id: number;
  22171. private _currentMaterial;
  22172. /**
  22173. * Add a new submesh to a mesh
  22174. * @param materialIndex defines the material index to use
  22175. * @param verticesStart defines vertex index start
  22176. * @param verticesCount defines vertices count
  22177. * @param indexStart defines index start
  22178. * @param indexCount defines indices count
  22179. * @param mesh defines the parent mesh
  22180. * @param renderingMesh defines an optional rendering mesh
  22181. * @param createBoundingBox defines if bounding box should be created for this submesh
  22182. * @returns the new submesh
  22183. */
  22184. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  22185. /**
  22186. * Creates a new submesh
  22187. * @param materialIndex defines the material index to use
  22188. * @param verticesStart defines vertex index start
  22189. * @param verticesCount defines vertices count
  22190. * @param indexStart defines index start
  22191. * @param indexCount defines indices count
  22192. * @param mesh defines the parent mesh
  22193. * @param renderingMesh defines an optional rendering mesh
  22194. * @param createBoundingBox defines if bounding box should be created for this submesh
  22195. */
  22196. constructor(
  22197. /** the material index to use */
  22198. materialIndex: number,
  22199. /** vertex index start */
  22200. verticesStart: number,
  22201. /** vertices count */
  22202. verticesCount: number,
  22203. /** index start */
  22204. indexStart: number,
  22205. /** indices count */
  22206. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  22207. /**
  22208. * Returns true if this submesh covers the entire parent mesh
  22209. * @ignorenaming
  22210. */
  22211. readonly IsGlobal: boolean;
  22212. /**
  22213. * Returns the submesh BoudingInfo object
  22214. * @returns current bounding info (or mesh's one if the submesh is global)
  22215. */
  22216. getBoundingInfo(): BoundingInfo;
  22217. /**
  22218. * Sets the submesh BoundingInfo
  22219. * @param boundingInfo defines the new bounding info to use
  22220. * @returns the SubMesh
  22221. */
  22222. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  22223. /**
  22224. * Returns the mesh of the current submesh
  22225. * @return the parent mesh
  22226. */
  22227. getMesh(): AbstractMesh;
  22228. /**
  22229. * Returns the rendering mesh of the submesh
  22230. * @returns the rendering mesh (could be different from parent mesh)
  22231. */
  22232. getRenderingMesh(): Mesh;
  22233. /**
  22234. * Returns the submesh material
  22235. * @returns null or the current material
  22236. */
  22237. getMaterial(): Nullable<Material>;
  22238. /**
  22239. * Sets a new updated BoundingInfo object to the submesh
  22240. * @returns the SubMesh
  22241. */
  22242. refreshBoundingInfo(): SubMesh;
  22243. /** @hidden */
  22244. _checkCollision(collider: Collider): boolean;
  22245. /**
  22246. * Updates the submesh BoundingInfo
  22247. * @param world defines the world matrix to use to update the bounding info
  22248. * @returns the submesh
  22249. */
  22250. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  22251. /**
  22252. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  22253. * @param frustumPlanes defines the frustum planes
  22254. * @returns true if the submesh is intersecting with the frustum
  22255. */
  22256. isInFrustum(frustumPlanes: Plane[]): boolean;
  22257. /**
  22258. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  22259. * @param frustumPlanes defines the frustum planes
  22260. * @returns true if the submesh is inside the frustum
  22261. */
  22262. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  22263. /**
  22264. * Renders the submesh
  22265. * @param enableAlphaMode defines if alpha needs to be used
  22266. * @returns the submesh
  22267. */
  22268. render(enableAlphaMode: boolean): SubMesh;
  22269. /**
  22270. * @hidden
  22271. */
  22272. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  22273. /**
  22274. * Checks if the submesh intersects with a ray
  22275. * @param ray defines the ray to test
  22276. * @returns true is the passed ray intersects the submesh bounding box
  22277. */
  22278. canIntersects(ray: Ray): boolean;
  22279. /**
  22280. * Intersects current submesh with a ray
  22281. * @param ray defines the ray to test
  22282. * @param positions defines mesh's positions array
  22283. * @param indices defines mesh's indices array
  22284. * @param fastCheck defines if only bounding info should be used
  22285. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  22286. * @returns intersection info or null if no intersection
  22287. */
  22288. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  22289. /** @hidden */
  22290. private _intersectLines;
  22291. /** @hidden */
  22292. private _intersectTriangles;
  22293. /** @hidden */
  22294. _rebuild(): void;
  22295. /**
  22296. * Creates a new submesh from the passed mesh
  22297. * @param newMesh defines the new hosting mesh
  22298. * @param newRenderingMesh defines an optional rendering mesh
  22299. * @returns the new submesh
  22300. */
  22301. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  22302. /**
  22303. * Release associated resources
  22304. */
  22305. dispose(): void;
  22306. /**
  22307. * Gets the class name
  22308. * @returns the string "SubMesh".
  22309. */
  22310. getClassName(): string;
  22311. /**
  22312. * Creates a new submesh from indices data
  22313. * @param materialIndex the index of the main mesh material
  22314. * @param startIndex the index where to start the copy in the mesh indices array
  22315. * @param indexCount the number of indices to copy then from the startIndex
  22316. * @param mesh the main mesh to create the submesh from
  22317. * @param renderingMesh the optional rendering mesh
  22318. * @returns a new submesh
  22319. */
  22320. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  22321. }
  22322. }
  22323. declare module "babylonjs/Meshes/geometry" {
  22324. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  22325. import { Scene } from "babylonjs/scene";
  22326. import { Vector3, Vector2 } from "babylonjs/Maths/math";
  22327. import { Engine } from "babylonjs/Engines/engine";
  22328. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  22329. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  22330. import { Effect } from "babylonjs/Materials/effect";
  22331. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  22332. import { Mesh } from "babylonjs/Meshes/mesh";
  22333. /**
  22334. * Class used to store geometry data (vertex buffers + index buffer)
  22335. */
  22336. export class Geometry implements IGetSetVerticesData {
  22337. /**
  22338. * Gets or sets the ID of the geometry
  22339. */
  22340. id: string;
  22341. /**
  22342. * Gets or sets the unique ID of the geometry
  22343. */
  22344. uniqueId: number;
  22345. /**
  22346. * Gets the delay loading state of the geometry (none by default which means not delayed)
  22347. */
  22348. delayLoadState: number;
  22349. /**
  22350. * Gets the file containing the data to load when running in delay load state
  22351. */
  22352. delayLoadingFile: Nullable<string>;
  22353. /**
  22354. * Callback called when the geometry is updated
  22355. */
  22356. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  22357. private _scene;
  22358. private _engine;
  22359. private _meshes;
  22360. private _totalVertices;
  22361. /** @hidden */
  22362. _indices: IndicesArray;
  22363. /** @hidden */
  22364. _vertexBuffers: {
  22365. [key: string]: VertexBuffer;
  22366. };
  22367. private _isDisposed;
  22368. private _extend;
  22369. private _boundingBias;
  22370. /** @hidden */
  22371. _delayInfo: Array<string>;
  22372. private _indexBuffer;
  22373. private _indexBufferIsUpdatable;
  22374. /** @hidden */
  22375. _boundingInfo: Nullable<BoundingInfo>;
  22376. /** @hidden */
  22377. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  22378. /** @hidden */
  22379. _softwareSkinningFrameId: number;
  22380. private _vertexArrayObjects;
  22381. private _updatable;
  22382. /** @hidden */
  22383. _positions: Nullable<Vector3[]>;
  22384. /**
  22385. * 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
  22386. */
  22387. /**
  22388. * 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
  22389. */
  22390. boundingBias: Vector2;
  22391. /**
  22392. * Static function used to attach a new empty geometry to a mesh
  22393. * @param mesh defines the mesh to attach the geometry to
  22394. * @returns the new Geometry
  22395. */
  22396. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  22397. /**
  22398. * Creates a new geometry
  22399. * @param id defines the unique ID
  22400. * @param scene defines the hosting scene
  22401. * @param vertexData defines the VertexData used to get geometry data
  22402. * @param updatable defines if geometry must be updatable (false by default)
  22403. * @param mesh defines the mesh that will be associated with the geometry
  22404. */
  22405. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  22406. /**
  22407. * Gets the current extend of the geometry
  22408. */
  22409. readonly extend: {
  22410. minimum: Vector3;
  22411. maximum: Vector3;
  22412. };
  22413. /**
  22414. * Gets the hosting scene
  22415. * @returns the hosting Scene
  22416. */
  22417. getScene(): Scene;
  22418. /**
  22419. * Gets the hosting engine
  22420. * @returns the hosting Engine
  22421. */
  22422. getEngine(): Engine;
  22423. /**
  22424. * Defines if the geometry is ready to use
  22425. * @returns true if the geometry is ready to be used
  22426. */
  22427. isReady(): boolean;
  22428. /**
  22429. * Gets a value indicating that the geometry should not be serialized
  22430. */
  22431. readonly doNotSerialize: boolean;
  22432. /** @hidden */
  22433. _rebuild(): void;
  22434. /**
  22435. * Affects all geometry data in one call
  22436. * @param vertexData defines the geometry data
  22437. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  22438. */
  22439. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  22440. /**
  22441. * Set specific vertex data
  22442. * @param kind defines the data kind (Position, normal, etc...)
  22443. * @param data defines the vertex data to use
  22444. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22445. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22446. */
  22447. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  22448. /**
  22449. * Removes a specific vertex data
  22450. * @param kind defines the data kind (Position, normal, etc...)
  22451. */
  22452. removeVerticesData(kind: string): void;
  22453. /**
  22454. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  22455. * @param buffer defines the vertex buffer to use
  22456. * @param totalVertices defines the total number of vertices for position kind (could be null)
  22457. */
  22458. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  22459. /**
  22460. * Update a specific vertex buffer
  22461. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  22462. * It will do nothing if the buffer is not updatable
  22463. * @param kind defines the data kind (Position, normal, etc...)
  22464. * @param data defines the data to use
  22465. * @param offset defines the offset in the target buffer where to store the data
  22466. * @param useBytes set to true if the offset is in bytes
  22467. */
  22468. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  22469. /**
  22470. * Update a specific vertex buffer
  22471. * This function will create a new buffer if the current one is not updatable
  22472. * @param kind defines the data kind (Position, normal, etc...)
  22473. * @param data defines the data to use
  22474. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  22475. */
  22476. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  22477. private _updateBoundingInfo;
  22478. /** @hidden */
  22479. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  22480. /**
  22481. * Gets total number of vertices
  22482. * @returns the total number of vertices
  22483. */
  22484. getTotalVertices(): number;
  22485. /**
  22486. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22487. * @param kind defines the data kind (Position, normal, etc...)
  22488. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22489. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22490. * @returns a float array containing vertex data
  22491. */
  22492. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22493. /**
  22494. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  22495. * @param kind defines the data kind (Position, normal, etc...)
  22496. * @returns true if the vertex buffer with the specified kind is updatable
  22497. */
  22498. isVertexBufferUpdatable(kind: string): boolean;
  22499. /**
  22500. * Gets a specific vertex buffer
  22501. * @param kind defines the data kind (Position, normal, etc...)
  22502. * @returns a VertexBuffer
  22503. */
  22504. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  22505. /**
  22506. * Returns all vertex buffers
  22507. * @return an object holding all vertex buffers indexed by kind
  22508. */
  22509. getVertexBuffers(): Nullable<{
  22510. [key: string]: VertexBuffer;
  22511. }>;
  22512. /**
  22513. * Gets a boolean indicating if specific vertex buffer is present
  22514. * @param kind defines the data kind (Position, normal, etc...)
  22515. * @returns true if data is present
  22516. */
  22517. isVerticesDataPresent(kind: string): boolean;
  22518. /**
  22519. * Gets a list of all attached data kinds (Position, normal, etc...)
  22520. * @returns a list of string containing all kinds
  22521. */
  22522. getVerticesDataKinds(): string[];
  22523. /**
  22524. * Update index buffer
  22525. * @param indices defines the indices to store in the index buffer
  22526. * @param offset defines the offset in the target buffer where to store the data
  22527. * @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)
  22528. */
  22529. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  22530. /**
  22531. * Creates a new index buffer
  22532. * @param indices defines the indices to store in the index buffer
  22533. * @param totalVertices defines the total number of vertices (could be null)
  22534. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22535. */
  22536. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  22537. /**
  22538. * Return the total number of indices
  22539. * @returns the total number of indices
  22540. */
  22541. getTotalIndices(): number;
  22542. /**
  22543. * Gets the index buffer array
  22544. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22545. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22546. * @returns the index buffer array
  22547. */
  22548. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22549. /**
  22550. * Gets the index buffer
  22551. * @return the index buffer
  22552. */
  22553. getIndexBuffer(): Nullable<WebGLBuffer>;
  22554. /** @hidden */
  22555. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  22556. /**
  22557. * Release the associated resources for a specific mesh
  22558. * @param mesh defines the source mesh
  22559. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  22560. */
  22561. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  22562. /**
  22563. * Apply current geometry to a given mesh
  22564. * @param mesh defines the mesh to apply geometry to
  22565. */
  22566. applyToMesh(mesh: Mesh): void;
  22567. private _updateExtend;
  22568. private _applyToMesh;
  22569. private notifyUpdate;
  22570. /**
  22571. * Load the geometry if it was flagged as delay loaded
  22572. * @param scene defines the hosting scene
  22573. * @param onLoaded defines a callback called when the geometry is loaded
  22574. */
  22575. load(scene: Scene, onLoaded?: () => void): void;
  22576. private _queueLoad;
  22577. /**
  22578. * Invert the geometry to move from a right handed system to a left handed one.
  22579. */
  22580. toLeftHanded(): void;
  22581. /** @hidden */
  22582. _resetPointsArrayCache(): void;
  22583. /** @hidden */
  22584. _generatePointsArray(): boolean;
  22585. /**
  22586. * Gets a value indicating if the geometry is disposed
  22587. * @returns true if the geometry was disposed
  22588. */
  22589. isDisposed(): boolean;
  22590. private _disposeVertexArrayObjects;
  22591. /**
  22592. * Free all associated resources
  22593. */
  22594. dispose(): void;
  22595. /**
  22596. * Clone the current geometry into a new geometry
  22597. * @param id defines the unique ID of the new geometry
  22598. * @returns a new geometry object
  22599. */
  22600. copy(id: string): Geometry;
  22601. /**
  22602. * Serialize the current geometry info (and not the vertices data) into a JSON object
  22603. * @return a JSON representation of the current geometry data (without the vertices data)
  22604. */
  22605. serialize(): any;
  22606. private toNumberArray;
  22607. /**
  22608. * Serialize all vertices data into a JSON oject
  22609. * @returns a JSON representation of the current geometry data
  22610. */
  22611. serializeVerticeData(): any;
  22612. /**
  22613. * Extracts a clone of a mesh geometry
  22614. * @param mesh defines the source mesh
  22615. * @param id defines the unique ID of the new geometry object
  22616. * @returns the new geometry object
  22617. */
  22618. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  22619. /**
  22620. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  22621. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  22622. * Be aware Math.random() could cause collisions, but:
  22623. * "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"
  22624. * @returns a string containing a new GUID
  22625. */
  22626. static RandomId(): string;
  22627. /** @hidden */
  22628. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  22629. private static _CleanMatricesWeights;
  22630. /**
  22631. * Create a new geometry from persisted data (Using .babylon file format)
  22632. * @param parsedVertexData defines the persisted data
  22633. * @param scene defines the hosting scene
  22634. * @param rootUrl defines the root url to use to load assets (like delayed data)
  22635. * @returns the new geometry object
  22636. */
  22637. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  22638. }
  22639. }
  22640. declare module "babylonjs/Meshes/mesh.vertexData" {
  22641. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  22642. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  22643. import { Geometry } from "babylonjs/Meshes/geometry";
  22644. import { Mesh } from "babylonjs/Meshes/mesh";
  22645. /**
  22646. * Define an interface for all classes that will get and set the data on vertices
  22647. */
  22648. export interface IGetSetVerticesData {
  22649. /**
  22650. * Gets a boolean indicating if specific vertex data is present
  22651. * @param kind defines the vertex data kind to use
  22652. * @returns true is data kind is present
  22653. */
  22654. isVerticesDataPresent(kind: string): boolean;
  22655. /**
  22656. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22657. * @param kind defines the data kind (Position, normal, etc...)
  22658. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22659. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22660. * @returns a float array containing vertex data
  22661. */
  22662. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22663. /**
  22664. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  22665. * @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.
  22666. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22667. * @returns the indices array or an empty array if the mesh has no geometry
  22668. */
  22669. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22670. /**
  22671. * Set specific vertex data
  22672. * @param kind defines the data kind (Position, normal, etc...)
  22673. * @param data defines the vertex data to use
  22674. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22675. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22676. */
  22677. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  22678. /**
  22679. * Update a specific associated vertex buffer
  22680. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  22681. * - VertexBuffer.PositionKind
  22682. * - VertexBuffer.UVKind
  22683. * - VertexBuffer.UV2Kind
  22684. * - VertexBuffer.UV3Kind
  22685. * - VertexBuffer.UV4Kind
  22686. * - VertexBuffer.UV5Kind
  22687. * - VertexBuffer.UV6Kind
  22688. * - VertexBuffer.ColorKind
  22689. * - VertexBuffer.MatricesIndicesKind
  22690. * - VertexBuffer.MatricesIndicesExtraKind
  22691. * - VertexBuffer.MatricesWeightsKind
  22692. * - VertexBuffer.MatricesWeightsExtraKind
  22693. * @param data defines the data source
  22694. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  22695. * @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)
  22696. */
  22697. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  22698. /**
  22699. * Creates a new index buffer
  22700. * @param indices defines the indices to store in the index buffer
  22701. * @param totalVertices defines the total number of vertices (could be null)
  22702. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22703. */
  22704. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  22705. }
  22706. /**
  22707. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  22708. */
  22709. export class VertexData {
  22710. /**
  22711. * Mesh side orientation : usually the external or front surface
  22712. */
  22713. static readonly FRONTSIDE: number;
  22714. /**
  22715. * Mesh side orientation : usually the internal or back surface
  22716. */
  22717. static readonly BACKSIDE: number;
  22718. /**
  22719. * Mesh side orientation : both internal and external or front and back surfaces
  22720. */
  22721. static readonly DOUBLESIDE: number;
  22722. /**
  22723. * Mesh side orientation : by default, `FRONTSIDE`
  22724. */
  22725. static readonly DEFAULTSIDE: number;
  22726. /**
  22727. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  22728. */
  22729. positions: Nullable<FloatArray>;
  22730. /**
  22731. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22732. */
  22733. normals: Nullable<FloatArray>;
  22734. /**
  22735. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22736. */
  22737. tangents: Nullable<FloatArray>;
  22738. /**
  22739. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22740. */
  22741. uvs: Nullable<FloatArray>;
  22742. /**
  22743. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22744. */
  22745. uvs2: Nullable<FloatArray>;
  22746. /**
  22747. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22748. */
  22749. uvs3: Nullable<FloatArray>;
  22750. /**
  22751. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22752. */
  22753. uvs4: Nullable<FloatArray>;
  22754. /**
  22755. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22756. */
  22757. uvs5: Nullable<FloatArray>;
  22758. /**
  22759. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22760. */
  22761. uvs6: Nullable<FloatArray>;
  22762. /**
  22763. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22764. */
  22765. colors: Nullable<FloatArray>;
  22766. /**
  22767. * 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).
  22768. */
  22769. matricesIndices: Nullable<FloatArray>;
  22770. /**
  22771. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22772. */
  22773. matricesWeights: Nullable<FloatArray>;
  22774. /**
  22775. * An array extending the number of possible indices
  22776. */
  22777. matricesIndicesExtra: Nullable<FloatArray>;
  22778. /**
  22779. * An array extending the number of possible weights when the number of indices is extended
  22780. */
  22781. matricesWeightsExtra: Nullable<FloatArray>;
  22782. /**
  22783. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22784. */
  22785. indices: Nullable<IndicesArray>;
  22786. /**
  22787. * Uses the passed data array to set the set the values for the specified kind of data
  22788. * @param data a linear array of floating numbers
  22789. * @param kind the type of data that is being set, eg positions, colors etc
  22790. */
  22791. set(data: FloatArray, kind: string): void;
  22792. /**
  22793. * Associates the vertexData to the passed Mesh.
  22794. * Sets it as updatable or not (default `false`)
  22795. * @param mesh the mesh the vertexData is applied to
  22796. * @param updatable when used and having the value true allows new data to update the vertexData
  22797. * @returns the VertexData
  22798. */
  22799. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22800. /**
  22801. * Associates the vertexData to the passed Geometry.
  22802. * Sets it as updatable or not (default `false`)
  22803. * @param geometry the geometry the vertexData is applied to
  22804. * @param updatable when used and having the value true allows new data to update the vertexData
  22805. * @returns VertexData
  22806. */
  22807. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22808. /**
  22809. * Updates the associated mesh
  22810. * @param mesh the mesh to be updated
  22811. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22812. * @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
  22813. * @returns VertexData
  22814. */
  22815. updateMesh(mesh: Mesh): VertexData;
  22816. /**
  22817. * Updates the associated geometry
  22818. * @param geometry the geometry to be updated
  22819. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22820. * @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
  22821. * @returns VertexData.
  22822. */
  22823. updateGeometry(geometry: Geometry): VertexData;
  22824. private _applyTo;
  22825. private _update;
  22826. /**
  22827. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22828. * @param matrix the transforming matrix
  22829. * @returns the VertexData
  22830. */
  22831. transform(matrix: Matrix): VertexData;
  22832. /**
  22833. * Merges the passed VertexData into the current one
  22834. * @param other the VertexData to be merged into the current one
  22835. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22836. * @returns the modified VertexData
  22837. */
  22838. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22839. private _mergeElement;
  22840. private _validate;
  22841. /**
  22842. * Serializes the VertexData
  22843. * @returns a serialized object
  22844. */
  22845. serialize(): any;
  22846. /**
  22847. * Extracts the vertexData from a mesh
  22848. * @param mesh the mesh from which to extract the VertexData
  22849. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22850. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22851. * @returns the object VertexData associated to the passed mesh
  22852. */
  22853. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22854. /**
  22855. * Extracts the vertexData from the geometry
  22856. * @param geometry the geometry from which to extract the VertexData
  22857. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22858. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22859. * @returns the object VertexData associated to the passed mesh
  22860. */
  22861. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22862. private static _ExtractFrom;
  22863. /**
  22864. * Creates the VertexData for a Ribbon
  22865. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22866. * * pathArray array of paths, each of which an array of successive Vector3
  22867. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22868. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22869. * * 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
  22870. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22871. * * 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)
  22872. * * 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)
  22873. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22874. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22875. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22876. * @returns the VertexData of the ribbon
  22877. */
  22878. static CreateRibbon(options: {
  22879. pathArray: Vector3[][];
  22880. closeArray?: boolean;
  22881. closePath?: boolean;
  22882. offset?: number;
  22883. sideOrientation?: number;
  22884. frontUVs?: Vector4;
  22885. backUVs?: Vector4;
  22886. invertUV?: boolean;
  22887. uvs?: Vector2[];
  22888. colors?: Color4[];
  22889. }): VertexData;
  22890. /**
  22891. * Creates the VertexData for a box
  22892. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22893. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22894. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22895. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22896. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22897. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22898. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22899. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22900. * * 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)
  22901. * * 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)
  22902. * @returns the VertexData of the box
  22903. */
  22904. static CreateBox(options: {
  22905. size?: number;
  22906. width?: number;
  22907. height?: number;
  22908. depth?: number;
  22909. faceUV?: Vector4[];
  22910. faceColors?: Color4[];
  22911. sideOrientation?: number;
  22912. frontUVs?: Vector4;
  22913. backUVs?: Vector4;
  22914. }): VertexData;
  22915. /**
  22916. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22917. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22918. * * segments sets the number of horizontal strips optional, default 32
  22919. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22920. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22921. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22922. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22923. * * 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
  22924. * * 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
  22925. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22926. * * 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)
  22927. * * 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)
  22928. * @returns the VertexData of the ellipsoid
  22929. */
  22930. static CreateSphere(options: {
  22931. segments?: number;
  22932. diameter?: number;
  22933. diameterX?: number;
  22934. diameterY?: number;
  22935. diameterZ?: number;
  22936. arc?: number;
  22937. slice?: number;
  22938. sideOrientation?: number;
  22939. frontUVs?: Vector4;
  22940. backUVs?: Vector4;
  22941. }): VertexData;
  22942. /**
  22943. * Creates the VertexData for a cylinder, cone or prism
  22944. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22945. * * height sets the height (y direction) of the cylinder, optional, default 2
  22946. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22947. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22948. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22949. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22950. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22951. * * 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
  22952. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22953. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22954. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22955. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22956. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22957. * * 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)
  22958. * * 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)
  22959. * @returns the VertexData of the cylinder, cone or prism
  22960. */
  22961. static CreateCylinder(options: {
  22962. height?: number;
  22963. diameterTop?: number;
  22964. diameterBottom?: number;
  22965. diameter?: number;
  22966. tessellation?: number;
  22967. subdivisions?: number;
  22968. arc?: number;
  22969. faceColors?: Color4[];
  22970. faceUV?: Vector4[];
  22971. hasRings?: boolean;
  22972. enclose?: boolean;
  22973. sideOrientation?: number;
  22974. frontUVs?: Vector4;
  22975. backUVs?: Vector4;
  22976. }): VertexData;
  22977. /**
  22978. * Creates the VertexData for a torus
  22979. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22980. * * diameter the diameter of the torus, optional default 1
  22981. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22982. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22983. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22984. * * 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)
  22985. * * 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)
  22986. * @returns the VertexData of the torus
  22987. */
  22988. static CreateTorus(options: {
  22989. diameter?: number;
  22990. thickness?: number;
  22991. tessellation?: number;
  22992. sideOrientation?: number;
  22993. frontUVs?: Vector4;
  22994. backUVs?: Vector4;
  22995. }): VertexData;
  22996. /**
  22997. * Creates the VertexData of the LineSystem
  22998. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22999. * - lines an array of lines, each line being an array of successive Vector3
  23000. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  23001. * @returns the VertexData of the LineSystem
  23002. */
  23003. static CreateLineSystem(options: {
  23004. lines: Vector3[][];
  23005. colors?: Nullable<Color4[][]>;
  23006. }): VertexData;
  23007. /**
  23008. * Create the VertexData for a DashedLines
  23009. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  23010. * - points an array successive Vector3
  23011. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  23012. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  23013. * - dashNb the intended total number of dashes, optional, default 200
  23014. * @returns the VertexData for the DashedLines
  23015. */
  23016. static CreateDashedLines(options: {
  23017. points: Vector3[];
  23018. dashSize?: number;
  23019. gapSize?: number;
  23020. dashNb?: number;
  23021. }): VertexData;
  23022. /**
  23023. * Creates the VertexData for a Ground
  23024. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23025. * - width the width (x direction) of the ground, optional, default 1
  23026. * - height the height (z direction) of the ground, optional, default 1
  23027. * - subdivisions the number of subdivisions per side, optional, default 1
  23028. * @returns the VertexData of the Ground
  23029. */
  23030. static CreateGround(options: {
  23031. width?: number;
  23032. height?: number;
  23033. subdivisions?: number;
  23034. subdivisionsX?: number;
  23035. subdivisionsY?: number;
  23036. }): VertexData;
  23037. /**
  23038. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  23039. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23040. * * xmin the ground minimum X coordinate, optional, default -1
  23041. * * zmin the ground minimum Z coordinate, optional, default -1
  23042. * * xmax the ground maximum X coordinate, optional, default 1
  23043. * * zmax the ground maximum Z coordinate, optional, default 1
  23044. * * 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}
  23045. * * 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}
  23046. * @returns the VertexData of the TiledGround
  23047. */
  23048. static CreateTiledGround(options: {
  23049. xmin: number;
  23050. zmin: number;
  23051. xmax: number;
  23052. zmax: number;
  23053. subdivisions?: {
  23054. w: number;
  23055. h: number;
  23056. };
  23057. precision?: {
  23058. w: number;
  23059. h: number;
  23060. };
  23061. }): VertexData;
  23062. /**
  23063. * Creates the VertexData of the Ground designed from a heightmap
  23064. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  23065. * * width the width (x direction) of the ground
  23066. * * height the height (z direction) of the ground
  23067. * * subdivisions the number of subdivisions per side
  23068. * * minHeight the minimum altitude on the ground, optional, default 0
  23069. * * maxHeight the maximum altitude on the ground, optional default 1
  23070. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  23071. * * buffer the array holding the image color data
  23072. * * bufferWidth the width of image
  23073. * * bufferHeight the height of image
  23074. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  23075. * @returns the VertexData of the Ground designed from a heightmap
  23076. */
  23077. static CreateGroundFromHeightMap(options: {
  23078. width: number;
  23079. height: number;
  23080. subdivisions: number;
  23081. minHeight: number;
  23082. maxHeight: number;
  23083. colorFilter: Color3;
  23084. buffer: Uint8Array;
  23085. bufferWidth: number;
  23086. bufferHeight: number;
  23087. alphaFilter: number;
  23088. }): VertexData;
  23089. /**
  23090. * Creates the VertexData for a Plane
  23091. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  23092. * * size sets the width and height of the plane to the value of size, optional default 1
  23093. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  23094. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  23095. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23096. * * 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)
  23097. * * 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)
  23098. * @returns the VertexData of the box
  23099. */
  23100. static CreatePlane(options: {
  23101. size?: number;
  23102. width?: number;
  23103. height?: number;
  23104. sideOrientation?: number;
  23105. frontUVs?: Vector4;
  23106. backUVs?: Vector4;
  23107. }): VertexData;
  23108. /**
  23109. * Creates the VertexData of the Disc or regular Polygon
  23110. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  23111. * * radius the radius of the disc, optional default 0.5
  23112. * * tessellation the number of polygon sides, optional, default 64
  23113. * * 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
  23114. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23115. * * 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)
  23116. * * 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)
  23117. * @returns the VertexData of the box
  23118. */
  23119. static CreateDisc(options: {
  23120. radius?: number;
  23121. tessellation?: number;
  23122. arc?: number;
  23123. sideOrientation?: number;
  23124. frontUVs?: Vector4;
  23125. backUVs?: Vector4;
  23126. }): VertexData;
  23127. /**
  23128. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  23129. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  23130. * @param polygon a mesh built from polygonTriangulation.build()
  23131. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23132. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23133. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23134. * @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)
  23135. * @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)
  23136. * @returns the VertexData of the Polygon
  23137. */
  23138. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  23139. /**
  23140. * Creates the VertexData of the IcoSphere
  23141. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  23142. * * radius the radius of the IcoSphere, optional default 1
  23143. * * radiusX allows stretching in the x direction, optional, default radius
  23144. * * radiusY allows stretching in the y direction, optional, default radius
  23145. * * radiusZ allows stretching in the z direction, optional, default radius
  23146. * * flat when true creates a flat shaded mesh, optional, default true
  23147. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23148. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23149. * * 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)
  23150. * * 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)
  23151. * @returns the VertexData of the IcoSphere
  23152. */
  23153. static CreateIcoSphere(options: {
  23154. radius?: number;
  23155. radiusX?: number;
  23156. radiusY?: number;
  23157. radiusZ?: number;
  23158. flat?: boolean;
  23159. subdivisions?: number;
  23160. sideOrientation?: number;
  23161. frontUVs?: Vector4;
  23162. backUVs?: Vector4;
  23163. }): VertexData;
  23164. /**
  23165. * Creates the VertexData for a Polyhedron
  23166. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  23167. * * type provided types are:
  23168. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  23169. * * 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)
  23170. * * size the size of the IcoSphere, optional default 1
  23171. * * sizeX allows stretching in the x direction, optional, default size
  23172. * * sizeY allows stretching in the y direction, optional, default size
  23173. * * sizeZ allows stretching in the z direction, optional, default size
  23174. * * 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
  23175. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23176. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23177. * * flat when true creates a flat shaded mesh, optional, default true
  23178. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23179. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23180. * * 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)
  23181. * * 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)
  23182. * @returns the VertexData of the Polyhedron
  23183. */
  23184. static CreatePolyhedron(options: {
  23185. type?: number;
  23186. size?: number;
  23187. sizeX?: number;
  23188. sizeY?: number;
  23189. sizeZ?: number;
  23190. custom?: any;
  23191. faceUV?: Vector4[];
  23192. faceColors?: Color4[];
  23193. flat?: boolean;
  23194. sideOrientation?: number;
  23195. frontUVs?: Vector4;
  23196. backUVs?: Vector4;
  23197. }): VertexData;
  23198. /**
  23199. * Creates the VertexData for a TorusKnot
  23200. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  23201. * * radius the radius of the torus knot, optional, default 2
  23202. * * tube the thickness of the tube, optional, default 0.5
  23203. * * radialSegments the number of sides on each tube segments, optional, default 32
  23204. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  23205. * * p the number of windings around the z axis, optional, default 2
  23206. * * q the number of windings around the x axis, optional, default 3
  23207. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23208. * * 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)
  23209. * * 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)
  23210. * @returns the VertexData of the Torus Knot
  23211. */
  23212. static CreateTorusKnot(options: {
  23213. radius?: number;
  23214. tube?: number;
  23215. radialSegments?: number;
  23216. tubularSegments?: number;
  23217. p?: number;
  23218. q?: number;
  23219. sideOrientation?: number;
  23220. frontUVs?: Vector4;
  23221. backUVs?: Vector4;
  23222. }): VertexData;
  23223. /**
  23224. * Compute normals for given positions and indices
  23225. * @param positions an array of vertex positions, [...., x, y, z, ......]
  23226. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  23227. * @param normals an array of vertex normals, [...., x, y, z, ......]
  23228. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  23229. * * facetNormals : optional array of facet normals (vector3)
  23230. * * facetPositions : optional array of facet positions (vector3)
  23231. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  23232. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  23233. * * bInfo : optional bounding info, required for facetPartitioning computation
  23234. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  23235. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  23236. * * useRightHandedSystem: optional boolean to for right handed system computation
  23237. * * depthSort : optional boolean to enable the facet depth sort computation
  23238. * * distanceTo : optional Vector3 to compute the facet depth from this location
  23239. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  23240. */
  23241. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  23242. facetNormals?: any;
  23243. facetPositions?: any;
  23244. facetPartitioning?: any;
  23245. ratio?: number;
  23246. bInfo?: any;
  23247. bbSize?: Vector3;
  23248. subDiv?: any;
  23249. useRightHandedSystem?: boolean;
  23250. depthSort?: boolean;
  23251. distanceTo?: Vector3;
  23252. depthSortedFacets?: any;
  23253. }): void;
  23254. /** @hidden */
  23255. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  23256. /**
  23257. * Applies VertexData created from the imported parameters to the geometry
  23258. * @param parsedVertexData the parsed data from an imported file
  23259. * @param geometry the geometry to apply the VertexData to
  23260. */
  23261. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  23262. }
  23263. }
  23264. declare module "babylonjs/Meshes/Builders/discBuilder" {
  23265. import { Nullable } from "babylonjs/types";
  23266. import { Scene } from "babylonjs/scene";
  23267. import { Vector4 } from "babylonjs/Maths/math";
  23268. import { Mesh } from "babylonjs/Meshes/mesh";
  23269. /**
  23270. * Class containing static functions to help procedurally build meshes
  23271. */
  23272. export class DiscBuilder {
  23273. /**
  23274. * Creates a plane polygonal mesh. By default, this is a disc
  23275. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  23276. * * 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
  23277. * * 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
  23278. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23279. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  23280. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23281. * @param name defines the name of the mesh
  23282. * @param options defines the options used to create the mesh
  23283. * @param scene defines the hosting scene
  23284. * @returns the plane polygonal mesh
  23285. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  23286. */
  23287. static CreateDisc(name: string, options: {
  23288. radius?: number;
  23289. tessellation?: number;
  23290. arc?: number;
  23291. updatable?: boolean;
  23292. sideOrientation?: number;
  23293. frontUVs?: Vector4;
  23294. backUVs?: Vector4;
  23295. }, scene?: Nullable<Scene>): Mesh;
  23296. }
  23297. }
  23298. declare module "babylonjs/Particles/solidParticleSystem" {
  23299. import { Vector3 } from "babylonjs/Maths/math";
  23300. import { Mesh } from "babylonjs/Meshes/mesh";
  23301. import { Scene, IDisposable } from "babylonjs/scene";
  23302. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  23303. /**
  23304. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  23305. *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.
  23306. * The SPS is also a particle system. It provides some methods to manage the particles.
  23307. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  23308. *
  23309. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  23310. */
  23311. export class SolidParticleSystem implements IDisposable {
  23312. /**
  23313. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  23314. * Example : var p = SPS.particles[i];
  23315. */
  23316. particles: SolidParticle[];
  23317. /**
  23318. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  23319. */
  23320. nbParticles: number;
  23321. /**
  23322. * If the particles must ever face the camera (default false). Useful for planar particles.
  23323. */
  23324. billboard: boolean;
  23325. /**
  23326. * Recompute normals when adding a shape
  23327. */
  23328. recomputeNormals: boolean;
  23329. /**
  23330. * This a counter ofr your own usage. It's not set by any SPS functions.
  23331. */
  23332. counter: number;
  23333. /**
  23334. * The SPS name. This name is also given to the underlying mesh.
  23335. */
  23336. name: string;
  23337. /**
  23338. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  23339. */
  23340. mesh: Mesh;
  23341. /**
  23342. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  23343. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  23344. */
  23345. vars: any;
  23346. /**
  23347. * This array is populated when the SPS is set as 'pickable'.
  23348. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  23349. * Each element of this array is an object `{idx: int, faceId: int}`.
  23350. * `idx` is the picked particle index in the `SPS.particles` array
  23351. * `faceId` is the picked face index counted within this particle.
  23352. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  23353. */
  23354. pickedParticles: {
  23355. idx: number;
  23356. faceId: number;
  23357. }[];
  23358. /**
  23359. * This array is populated when `enableDepthSort` is set to true.
  23360. * Each element of this array is an instance of the class DepthSortedParticle.
  23361. */
  23362. depthSortedParticles: DepthSortedParticle[];
  23363. /**
  23364. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  23365. * @hidden
  23366. */
  23367. _bSphereOnly: boolean;
  23368. /**
  23369. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  23370. * @hidden
  23371. */
  23372. _bSphereRadiusFactor: number;
  23373. private _scene;
  23374. private _positions;
  23375. private _indices;
  23376. private _normals;
  23377. private _colors;
  23378. private _uvs;
  23379. private _indices32;
  23380. private _positions32;
  23381. private _normals32;
  23382. private _fixedNormal32;
  23383. private _colors32;
  23384. private _uvs32;
  23385. private _index;
  23386. private _updatable;
  23387. private _pickable;
  23388. private _isVisibilityBoxLocked;
  23389. private _alwaysVisible;
  23390. private _depthSort;
  23391. private _shapeCounter;
  23392. private _copy;
  23393. private _color;
  23394. private _computeParticleColor;
  23395. private _computeParticleTexture;
  23396. private _computeParticleRotation;
  23397. private _computeParticleVertex;
  23398. private _computeBoundingBox;
  23399. private _depthSortParticles;
  23400. private _camera;
  23401. private _mustUnrotateFixedNormals;
  23402. private _particlesIntersect;
  23403. private _needs32Bits;
  23404. /**
  23405. * Creates a SPS (Solid Particle System) object.
  23406. * @param name (String) is the SPS name, this will be the underlying mesh name.
  23407. * @param scene (Scene) is the scene in which the SPS is added.
  23408. * @param options defines the options of the sps e.g.
  23409. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  23410. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  23411. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  23412. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  23413. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  23414. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  23415. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  23416. */
  23417. constructor(name: string, scene: Scene, options?: {
  23418. updatable?: boolean;
  23419. isPickable?: boolean;
  23420. enableDepthSort?: boolean;
  23421. particleIntersection?: boolean;
  23422. boundingSphereOnly?: boolean;
  23423. bSphereRadiusFactor?: number;
  23424. });
  23425. /**
  23426. * Builds the SPS underlying mesh. Returns a standard Mesh.
  23427. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  23428. * @returns the created mesh
  23429. */
  23430. buildMesh(): Mesh;
  23431. /**
  23432. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  23433. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  23434. * Thus the particles generated from `digest()` have their property `position` set yet.
  23435. * @param mesh ( Mesh ) is the mesh to be digested
  23436. * @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
  23437. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  23438. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  23439. * @returns the current SPS
  23440. */
  23441. digest(mesh: Mesh, options?: {
  23442. facetNb?: number;
  23443. number?: number;
  23444. delta?: number;
  23445. }): SolidParticleSystem;
  23446. private _unrotateFixedNormals;
  23447. private _resetCopy;
  23448. private _meshBuilder;
  23449. private _posToShape;
  23450. private _uvsToShapeUV;
  23451. private _addParticle;
  23452. /**
  23453. * Adds some particles to the SPS from the model shape. Returns the shape id.
  23454. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  23455. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  23456. * @param nb (positive integer) the number of particles to be created from this model
  23457. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  23458. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  23459. * @returns the number of shapes in the system
  23460. */
  23461. addShape(mesh: Mesh, nb: number, options?: {
  23462. positionFunction?: any;
  23463. vertexFunction?: any;
  23464. }): number;
  23465. private _rebuildParticle;
  23466. /**
  23467. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  23468. * @returns the SPS.
  23469. */
  23470. rebuildMesh(): SolidParticleSystem;
  23471. /**
  23472. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  23473. * This method calls `updateParticle()` for each particle of the SPS.
  23474. * For an animated SPS, it is usually called within the render loop.
  23475. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  23476. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  23477. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  23478. * @returns the SPS.
  23479. */
  23480. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  23481. /**
  23482. * Disposes the SPS.
  23483. */
  23484. dispose(): void;
  23485. /**
  23486. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  23487. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23488. * @returns the SPS.
  23489. */
  23490. refreshVisibleSize(): SolidParticleSystem;
  23491. /**
  23492. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  23493. * @param size the size (float) of the visibility box
  23494. * note : this doesn't lock the SPS mesh bounding box.
  23495. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23496. */
  23497. setVisibilityBox(size: number): void;
  23498. /**
  23499. * Gets whether the SPS as always visible or not
  23500. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23501. */
  23502. /**
  23503. * Sets the SPS as always visible or not
  23504. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23505. */
  23506. isAlwaysVisible: boolean;
  23507. /**
  23508. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  23509. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23510. */
  23511. /**
  23512. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  23513. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23514. */
  23515. isVisibilityBoxLocked: boolean;
  23516. /**
  23517. * Tells to `setParticles()` to compute the particle rotations or not.
  23518. * Default value : true. The SPS is faster when it's set to false.
  23519. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  23520. */
  23521. /**
  23522. * Gets if `setParticles()` computes the particle rotations or not.
  23523. * Default value : true. The SPS is faster when it's set to false.
  23524. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  23525. */
  23526. computeParticleRotation: boolean;
  23527. /**
  23528. * Tells to `setParticles()` to compute the particle colors or not.
  23529. * Default value : true. The SPS is faster when it's set to false.
  23530. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  23531. */
  23532. /**
  23533. * Gets if `setParticles()` computes the particle colors or not.
  23534. * Default value : true. The SPS is faster when it's set to false.
  23535. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  23536. */
  23537. computeParticleColor: boolean;
  23538. /**
  23539. * Gets if `setParticles()` computes the particle textures or not.
  23540. * Default value : true. The SPS is faster when it's set to false.
  23541. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  23542. */
  23543. computeParticleTexture: boolean;
  23544. /**
  23545. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  23546. * Default value : false. The SPS is faster when it's set to false.
  23547. * Note : the particle custom vertex positions aren't stored values.
  23548. */
  23549. /**
  23550. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  23551. * Default value : false. The SPS is faster when it's set to false.
  23552. * Note : the particle custom vertex positions aren't stored values.
  23553. */
  23554. computeParticleVertex: boolean;
  23555. /**
  23556. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  23557. */
  23558. /**
  23559. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  23560. */
  23561. computeBoundingBox: boolean;
  23562. /**
  23563. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  23564. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  23565. * Default : `true`
  23566. */
  23567. /**
  23568. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  23569. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  23570. * Default : `true`
  23571. */
  23572. depthSortParticles: boolean;
  23573. /**
  23574. * This function does nothing. It may be overwritten to set all the particle first values.
  23575. * The SPS doesn't call this function, you may have to call it by your own.
  23576. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  23577. */
  23578. initParticles(): void;
  23579. /**
  23580. * This function does nothing. It may be overwritten to recycle a particle.
  23581. * The SPS doesn't call this function, you may have to call it by your own.
  23582. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  23583. * @param particle The particle to recycle
  23584. * @returns the recycled particle
  23585. */
  23586. recycleParticle(particle: SolidParticle): SolidParticle;
  23587. /**
  23588. * Updates a particle : this function should be overwritten by the user.
  23589. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  23590. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  23591. * @example : just set a particle position or velocity and recycle conditions
  23592. * @param particle The particle to update
  23593. * @returns the updated particle
  23594. */
  23595. updateParticle(particle: SolidParticle): SolidParticle;
  23596. /**
  23597. * Updates a vertex of a particle : it can be overwritten by the user.
  23598. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  23599. * @param particle the current particle
  23600. * @param vertex the current index of the current particle
  23601. * @param pt the index of the current vertex in the particle shape
  23602. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  23603. * @example : just set a vertex particle position
  23604. * @returns the updated vertex
  23605. */
  23606. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  23607. /**
  23608. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  23609. * This does nothing and may be overwritten by the user.
  23610. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23611. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23612. * @param update the boolean update value actually passed to setParticles()
  23613. */
  23614. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  23615. /**
  23616. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  23617. * This will be passed three parameters.
  23618. * This does nothing and may be overwritten by the user.
  23619. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23620. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23621. * @param update the boolean update value actually passed to setParticles()
  23622. */
  23623. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  23624. }
  23625. }
  23626. declare module "babylonjs/Particles/solidParticle" {
  23627. import { Nullable } from "babylonjs/types";
  23628. import { Color4, Vector3, Matrix, Quaternion, Vector4, Plane } from "babylonjs/Maths/math";
  23629. import { Mesh } from "babylonjs/Meshes/mesh";
  23630. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23631. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  23632. /**
  23633. * Represents one particle of a solid particle system.
  23634. */
  23635. export class SolidParticle {
  23636. /**
  23637. * particle global index
  23638. */
  23639. idx: number;
  23640. /**
  23641. * The color of the particle
  23642. */
  23643. color: Nullable<Color4>;
  23644. /**
  23645. * The world space position of the particle.
  23646. */
  23647. position: Vector3;
  23648. /**
  23649. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  23650. */
  23651. rotation: Vector3;
  23652. /**
  23653. * The world space rotation quaternion of the particle.
  23654. */
  23655. rotationQuaternion: Nullable<Quaternion>;
  23656. /**
  23657. * The scaling of the particle.
  23658. */
  23659. scaling: Vector3;
  23660. /**
  23661. * The uvs of the particle.
  23662. */
  23663. uvs: Vector4;
  23664. /**
  23665. * The current speed of the particle.
  23666. */
  23667. velocity: Vector3;
  23668. /**
  23669. * The pivot point in the particle local space.
  23670. */
  23671. pivot: Vector3;
  23672. /**
  23673. * Must the particle be translated from its pivot point in its local space ?
  23674. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  23675. * Default : false
  23676. */
  23677. translateFromPivot: boolean;
  23678. /**
  23679. * Is the particle active or not ?
  23680. */
  23681. alive: boolean;
  23682. /**
  23683. * Is the particle visible or not ?
  23684. */
  23685. isVisible: boolean;
  23686. /**
  23687. * Index of this particle in the global "positions" array (Internal use)
  23688. * @hidden
  23689. */
  23690. _pos: number;
  23691. /**
  23692. * @hidden Index of this particle in the global "indices" array (Internal use)
  23693. */
  23694. _ind: number;
  23695. /**
  23696. * @hidden ModelShape of this particle (Internal use)
  23697. */
  23698. _model: ModelShape;
  23699. /**
  23700. * ModelShape id of this particle
  23701. */
  23702. shapeId: number;
  23703. /**
  23704. * Index of the particle in its shape id (Internal use)
  23705. */
  23706. idxInShape: number;
  23707. /**
  23708. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  23709. */
  23710. _modelBoundingInfo: BoundingInfo;
  23711. /**
  23712. * @hidden Particle BoundingInfo object (Internal use)
  23713. */
  23714. _boundingInfo: BoundingInfo;
  23715. /**
  23716. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  23717. */
  23718. _sps: SolidParticleSystem;
  23719. /**
  23720. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  23721. */
  23722. _stillInvisible: boolean;
  23723. /**
  23724. * @hidden Last computed particle rotation matrix
  23725. */
  23726. _rotationMatrix: number[];
  23727. /**
  23728. * Parent particle Id, if any.
  23729. * Default null.
  23730. */
  23731. parentId: Nullable<number>;
  23732. /**
  23733. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  23734. * The possible values are :
  23735. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  23736. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  23737. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  23738. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  23739. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  23740. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  23741. * */
  23742. cullingStrategy: number;
  23743. /**
  23744. * @hidden Internal global position in the SPS.
  23745. */
  23746. _globalPosition: Vector3;
  23747. /**
  23748. * Creates a Solid Particle object.
  23749. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  23750. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  23751. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  23752. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  23753. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  23754. * @param shapeId (integer) is the model shape identifier in the SPS.
  23755. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  23756. * @param sps defines the sps it is associated to
  23757. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  23758. */
  23759. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  23760. /**
  23761. * Legacy support, changed scale to scaling
  23762. */
  23763. /**
  23764. * Legacy support, changed scale to scaling
  23765. */
  23766. scale: Vector3;
  23767. /**
  23768. * Legacy support, changed quaternion to rotationQuaternion
  23769. */
  23770. /**
  23771. * Legacy support, changed quaternion to rotationQuaternion
  23772. */
  23773. quaternion: Nullable<Quaternion>;
  23774. /**
  23775. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  23776. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  23777. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  23778. * @returns true if it intersects
  23779. */
  23780. intersectsMesh(target: Mesh | SolidParticle): boolean;
  23781. /**
  23782. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  23783. * A particle is in the frustum if its bounding box intersects the frustum
  23784. * @param frustumPlanes defines the frustum to test
  23785. * @returns true if the particle is in the frustum planes
  23786. */
  23787. isInFrustum(frustumPlanes: Plane[]): boolean;
  23788. /**
  23789. * get the rotation matrix of the particle
  23790. * @hidden
  23791. */
  23792. getRotationMatrix(m: Matrix): void;
  23793. }
  23794. /**
  23795. * Represents the shape of the model used by one particle of a solid particle system.
  23796. * SPS internal tool, don't use it manually.
  23797. */
  23798. export class ModelShape {
  23799. /**
  23800. * The shape id
  23801. * @hidden
  23802. */
  23803. shapeID: number;
  23804. /**
  23805. * flat array of model positions (internal use)
  23806. * @hidden
  23807. */
  23808. _shape: Vector3[];
  23809. /**
  23810. * flat array of model UVs (internal use)
  23811. * @hidden
  23812. */
  23813. _shapeUV: number[];
  23814. /**
  23815. * length of the shape in the model indices array (internal use)
  23816. * @hidden
  23817. */
  23818. _indicesLength: number;
  23819. /**
  23820. * Custom position function (internal use)
  23821. * @hidden
  23822. */
  23823. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  23824. /**
  23825. * Custom vertex function (internal use)
  23826. * @hidden
  23827. */
  23828. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  23829. /**
  23830. * 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.
  23831. * SPS internal tool, don't use it manually.
  23832. * @hidden
  23833. */
  23834. 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>);
  23835. }
  23836. /**
  23837. * Represents a Depth Sorted Particle in the solid particle system.
  23838. */
  23839. export class DepthSortedParticle {
  23840. /**
  23841. * Index of the particle in the "indices" array
  23842. */
  23843. ind: number;
  23844. /**
  23845. * Length of the particle shape in the "indices" array
  23846. */
  23847. indicesLength: number;
  23848. /**
  23849. * Squared distance from the particle to the camera
  23850. */
  23851. sqDistance: number;
  23852. }
  23853. }
  23854. declare module "babylonjs/Meshes/abstractMesh" {
  23855. import { Observable } from "babylonjs/Misc/observable";
  23856. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  23857. import { Camera } from "babylonjs/Cameras/camera";
  23858. import { Scene, IDisposable } from "babylonjs/scene";
  23859. import { Matrix, Vector3, Color3, Color4, Plane, Vector2 } from "babylonjs/Maths/math";
  23860. import { Node } from "babylonjs/node";
  23861. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  23862. import { TransformNode } from "babylonjs/Meshes/transformNode";
  23863. import { SubMesh } from "babylonjs/Meshes/subMesh";
  23864. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  23865. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23866. import { Material } from "babylonjs/Materials/material";
  23867. import { Light } from "babylonjs/Lights/light";
  23868. import { Skeleton } from "babylonjs/Bones/skeleton";
  23869. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  23870. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  23871. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  23872. import { Ray } from "babylonjs/Culling/ray";
  23873. import { Collider } from "babylonjs/Collisions/collider";
  23874. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  23875. /**
  23876. * Class used to store all common mesh properties
  23877. */
  23878. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  23879. /** No occlusion */
  23880. static OCCLUSION_TYPE_NONE: number;
  23881. /** Occlusion set to optimisitic */
  23882. static OCCLUSION_TYPE_OPTIMISTIC: number;
  23883. /** Occlusion set to strict */
  23884. static OCCLUSION_TYPE_STRICT: number;
  23885. /** Use an accurante occlusion algorithm */
  23886. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  23887. /** Use a conservative occlusion algorithm */
  23888. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  23889. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  23890. * Test order :
  23891. * Is the bounding sphere outside the frustum ?
  23892. * If not, are the bounding box vertices outside the frustum ?
  23893. * It not, then the cullable object is in the frustum.
  23894. */
  23895. static readonly CULLINGSTRATEGY_STANDARD: number;
  23896. /** Culling strategy : Bounding Sphere Only.
  23897. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  23898. * It's also less accurate than the standard because some not visible objects can still be selected.
  23899. * Test : is the bounding sphere outside the frustum ?
  23900. * If not, then the cullable object is in the frustum.
  23901. */
  23902. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  23903. /** Culling strategy : Optimistic Inclusion.
  23904. * This in an inclusion test first, then the standard exclusion test.
  23905. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  23906. * 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.
  23907. * Anyway, it's as accurate as the standard strategy.
  23908. * Test :
  23909. * Is the cullable object bounding sphere center in the frustum ?
  23910. * If not, apply the default culling strategy.
  23911. */
  23912. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  23913. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  23914. * This in an inclusion test first, then the bounding sphere only exclusion test.
  23915. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  23916. * 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.
  23917. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  23918. * Test :
  23919. * Is the cullable object bounding sphere center in the frustum ?
  23920. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  23921. */
  23922. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  23923. /**
  23924. * No billboard
  23925. */
  23926. static readonly BILLBOARDMODE_NONE: number;
  23927. /** Billboard on X axis */
  23928. static readonly BILLBOARDMODE_X: number;
  23929. /** Billboard on Y axis */
  23930. static readonly BILLBOARDMODE_Y: number;
  23931. /** Billboard on Z axis */
  23932. static readonly BILLBOARDMODE_Z: number;
  23933. /** Billboard on all axes */
  23934. static readonly BILLBOARDMODE_ALL: number;
  23935. private _facetData;
  23936. /**
  23937. * The culling strategy to use to check whether the mesh must be rendered or not.
  23938. * This value can be changed at any time and will be used on the next render mesh selection.
  23939. * The possible values are :
  23940. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  23941. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  23942. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  23943. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  23944. * Please read each static variable documentation to get details about the culling process.
  23945. * */
  23946. cullingStrategy: number;
  23947. /**
  23948. * Gets the number of facets in the mesh
  23949. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  23950. */
  23951. readonly facetNb: number;
  23952. /**
  23953. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  23954. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  23955. */
  23956. partitioningSubdivisions: number;
  23957. /**
  23958. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  23959. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  23960. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  23961. */
  23962. partitioningBBoxRatio: number;
  23963. /**
  23964. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  23965. * Works only for updatable meshes.
  23966. * Doesn't work with multi-materials
  23967. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  23968. */
  23969. mustDepthSortFacets: boolean;
  23970. /**
  23971. * The location (Vector3) where the facet depth sort must be computed from.
  23972. * By default, the active camera position.
  23973. * Used only when facet depth sort is enabled
  23974. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  23975. */
  23976. facetDepthSortFrom: Vector3;
  23977. /**
  23978. * gets a boolean indicating if facetData is enabled
  23979. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  23980. */
  23981. readonly isFacetDataEnabled: boolean;
  23982. /** @hidden */
  23983. _updateNonUniformScalingState(value: boolean): boolean;
  23984. /**
  23985. * An event triggered when this mesh collides with another one
  23986. */
  23987. onCollideObservable: Observable<AbstractMesh>;
  23988. private _onCollideObserver;
  23989. /** Set a function to call when this mesh collides with another one */
  23990. onCollide: () => void;
  23991. /**
  23992. * An event triggered when the collision's position changes
  23993. */
  23994. onCollisionPositionChangeObservable: Observable<Vector3>;
  23995. private _onCollisionPositionChangeObserver;
  23996. /** Set a function to call when the collision's position changes */
  23997. onCollisionPositionChange: () => void;
  23998. /**
  23999. * An event triggered when material is changed
  24000. */
  24001. onMaterialChangedObservable: Observable<AbstractMesh>;
  24002. /**
  24003. * Gets or sets the orientation for POV movement & rotation
  24004. */
  24005. definedFacingForward: boolean;
  24006. /** @hidden */
  24007. _occlusionQuery: Nullable<WebGLQuery>;
  24008. private _visibility;
  24009. /**
  24010. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  24011. */
  24012. /**
  24013. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  24014. */
  24015. visibility: number;
  24016. /** Gets or sets the alpha index used to sort transparent meshes
  24017. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  24018. */
  24019. alphaIndex: number;
  24020. /**
  24021. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  24022. */
  24023. isVisible: boolean;
  24024. /**
  24025. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  24026. */
  24027. isPickable: boolean;
  24028. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  24029. showSubMeshesBoundingBox: boolean;
  24030. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  24031. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  24032. */
  24033. isBlocker: boolean;
  24034. /**
  24035. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  24036. */
  24037. enablePointerMoveEvents: boolean;
  24038. /**
  24039. * Specifies the rendering group id for this mesh (0 by default)
  24040. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  24041. */
  24042. renderingGroupId: number;
  24043. private _material;
  24044. /** Gets or sets current material */
  24045. material: Nullable<Material>;
  24046. private _receiveShadows;
  24047. /**
  24048. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  24049. * @see http://doc.babylonjs.com/babylon101/shadows
  24050. */
  24051. receiveShadows: boolean;
  24052. /** Defines color to use when rendering outline */
  24053. outlineColor: Color3;
  24054. /** Define width to use when rendering outline */
  24055. outlineWidth: number;
  24056. /** Defines color to use when rendering overlay */
  24057. overlayColor: Color3;
  24058. /** Defines alpha to use when rendering overlay */
  24059. overlayAlpha: number;
  24060. private _hasVertexAlpha;
  24061. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  24062. hasVertexAlpha: boolean;
  24063. private _useVertexColors;
  24064. /** 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) */
  24065. useVertexColors: boolean;
  24066. private _computeBonesUsingShaders;
  24067. /**
  24068. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  24069. */
  24070. computeBonesUsingShaders: boolean;
  24071. private _numBoneInfluencers;
  24072. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  24073. numBoneInfluencers: number;
  24074. private _applyFog;
  24075. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  24076. applyFog: boolean;
  24077. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  24078. useOctreeForRenderingSelection: boolean;
  24079. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  24080. useOctreeForPicking: boolean;
  24081. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  24082. useOctreeForCollisions: boolean;
  24083. private _layerMask;
  24084. /**
  24085. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  24086. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  24087. */
  24088. layerMask: number;
  24089. /**
  24090. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  24091. */
  24092. alwaysSelectAsActiveMesh: boolean;
  24093. /**
  24094. * Gets or sets the current action manager
  24095. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  24096. */
  24097. actionManager: Nullable<AbstractActionManager>;
  24098. private _checkCollisions;
  24099. private _collisionMask;
  24100. private _collisionGroup;
  24101. /**
  24102. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  24103. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24104. */
  24105. ellipsoid: Vector3;
  24106. /**
  24107. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  24108. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24109. */
  24110. ellipsoidOffset: Vector3;
  24111. private _collider;
  24112. private _oldPositionForCollisions;
  24113. private _diffPositionForCollisions;
  24114. /**
  24115. * Gets or sets a collision mask used to mask collisions (default is -1).
  24116. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24117. */
  24118. collisionMask: number;
  24119. /**
  24120. * Gets or sets the current collision group mask (-1 by default).
  24121. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24122. */
  24123. collisionGroup: number;
  24124. /**
  24125. * Defines edge width used when edgesRenderer is enabled
  24126. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24127. */
  24128. edgesWidth: number;
  24129. /**
  24130. * Defines edge color used when edgesRenderer is enabled
  24131. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24132. */
  24133. edgesColor: Color4;
  24134. /** @hidden */
  24135. _edgesRenderer: Nullable<IEdgesRenderer>;
  24136. /** @hidden */
  24137. _masterMesh: Nullable<AbstractMesh>;
  24138. /** @hidden */
  24139. _boundingInfo: Nullable<BoundingInfo>;
  24140. /** @hidden */
  24141. _renderId: number;
  24142. /**
  24143. * Gets or sets the list of subMeshes
  24144. * @see http://doc.babylonjs.com/how_to/multi_materials
  24145. */
  24146. subMeshes: SubMesh[];
  24147. /** @hidden */
  24148. _intersectionsInProgress: AbstractMesh[];
  24149. /** @hidden */
  24150. _unIndexed: boolean;
  24151. /** @hidden */
  24152. _lightSources: Light[];
  24153. /** @hidden */
  24154. readonly _positions: Nullable<Vector3[]>;
  24155. /** @hidden */
  24156. _waitingActions: any;
  24157. /** @hidden */
  24158. _waitingFreezeWorldMatrix: Nullable<boolean>;
  24159. private _skeleton;
  24160. /** @hidden */
  24161. _bonesTransformMatrices: Nullable<Float32Array>;
  24162. /**
  24163. * Gets or sets a skeleton to apply skining transformations
  24164. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  24165. */
  24166. skeleton: Nullable<Skeleton>;
  24167. /**
  24168. * An event triggered when the mesh is rebuilt.
  24169. */
  24170. onRebuildObservable: Observable<AbstractMesh>;
  24171. /**
  24172. * Creates a new AbstractMesh
  24173. * @param name defines the name of the mesh
  24174. * @param scene defines the hosting scene
  24175. */
  24176. constructor(name: string, scene?: Nullable<Scene>);
  24177. /**
  24178. * Returns the string "AbstractMesh"
  24179. * @returns "AbstractMesh"
  24180. */
  24181. getClassName(): string;
  24182. /**
  24183. * Gets a string representation of the current mesh
  24184. * @param fullDetails defines a boolean indicating if full details must be included
  24185. * @returns a string representation of the current mesh
  24186. */
  24187. toString(fullDetails?: boolean): string;
  24188. /** @hidden */
  24189. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  24190. /** @hidden */
  24191. _rebuild(): void;
  24192. /** @hidden */
  24193. _resyncLightSources(): void;
  24194. /** @hidden */
  24195. _resyncLighSource(light: Light): void;
  24196. /** @hidden */
  24197. _unBindEffect(): void;
  24198. /** @hidden */
  24199. _removeLightSource(light: Light): void;
  24200. private _markSubMeshesAsDirty;
  24201. /** @hidden */
  24202. _markSubMeshesAsLightDirty(): void;
  24203. /** @hidden */
  24204. _markSubMeshesAsAttributesDirty(): void;
  24205. /** @hidden */
  24206. _markSubMeshesAsMiscDirty(): void;
  24207. /**
  24208. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  24209. */
  24210. scaling: Vector3;
  24211. /**
  24212. * Returns true if the mesh is blocked. Implemented by child classes
  24213. */
  24214. readonly isBlocked: boolean;
  24215. /**
  24216. * Returns the mesh itself by default. Implemented by child classes
  24217. * @param camera defines the camera to use to pick the right LOD level
  24218. * @returns the currentAbstractMesh
  24219. */
  24220. getLOD(camera: Camera): Nullable<AbstractMesh>;
  24221. /**
  24222. * Returns 0 by default. Implemented by child classes
  24223. * @returns an integer
  24224. */
  24225. getTotalVertices(): number;
  24226. /**
  24227. * Returns a positive integer : the total number of indices in this mesh geometry.
  24228. * @returns the numner of indices or zero if the mesh has no geometry.
  24229. */
  24230. getTotalIndices(): number;
  24231. /**
  24232. * Returns null by default. Implemented by child classes
  24233. * @returns null
  24234. */
  24235. getIndices(): Nullable<IndicesArray>;
  24236. /**
  24237. * Returns the array of the requested vertex data kind. Implemented by child classes
  24238. * @param kind defines the vertex data kind to use
  24239. * @returns null
  24240. */
  24241. getVerticesData(kind: string): Nullable<FloatArray>;
  24242. /**
  24243. * Sets the vertex data of the mesh geometry for the requested `kind`.
  24244. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  24245. * Note that a new underlying VertexBuffer object is created each call.
  24246. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  24247. * @param kind defines vertex data kind:
  24248. * * VertexBuffer.PositionKind
  24249. * * VertexBuffer.UVKind
  24250. * * VertexBuffer.UV2Kind
  24251. * * VertexBuffer.UV3Kind
  24252. * * VertexBuffer.UV4Kind
  24253. * * VertexBuffer.UV5Kind
  24254. * * VertexBuffer.UV6Kind
  24255. * * VertexBuffer.ColorKind
  24256. * * VertexBuffer.MatricesIndicesKind
  24257. * * VertexBuffer.MatricesIndicesExtraKind
  24258. * * VertexBuffer.MatricesWeightsKind
  24259. * * VertexBuffer.MatricesWeightsExtraKind
  24260. * @param data defines the data source
  24261. * @param updatable defines if the data must be flagged as updatable (or static)
  24262. * @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
  24263. * @returns the current mesh
  24264. */
  24265. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24266. /**
  24267. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  24268. * If the mesh has no geometry, it is simply returned as it is.
  24269. * @param kind defines vertex data kind:
  24270. * * VertexBuffer.PositionKind
  24271. * * VertexBuffer.UVKind
  24272. * * VertexBuffer.UV2Kind
  24273. * * VertexBuffer.UV3Kind
  24274. * * VertexBuffer.UV4Kind
  24275. * * VertexBuffer.UV5Kind
  24276. * * VertexBuffer.UV6Kind
  24277. * * VertexBuffer.ColorKind
  24278. * * VertexBuffer.MatricesIndicesKind
  24279. * * VertexBuffer.MatricesIndicesExtraKind
  24280. * * VertexBuffer.MatricesWeightsKind
  24281. * * VertexBuffer.MatricesWeightsExtraKind
  24282. * @param data defines the data source
  24283. * @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
  24284. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  24285. * @returns the current mesh
  24286. */
  24287. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24288. /**
  24289. * Sets the mesh indices,
  24290. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  24291. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  24292. * @param totalVertices Defines the total number of vertices
  24293. * @returns the current mesh
  24294. */
  24295. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  24296. /**
  24297. * Gets a boolean indicating if specific vertex data is present
  24298. * @param kind defines the vertex data kind to use
  24299. * @returns true is data kind is present
  24300. */
  24301. isVerticesDataPresent(kind: string): boolean;
  24302. /**
  24303. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  24304. * @returns a BoundingInfo
  24305. */
  24306. getBoundingInfo(): BoundingInfo;
  24307. /**
  24308. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  24309. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box
  24310. * @returns the current mesh
  24311. */
  24312. normalizeToUnitCube(includeDescendants?: boolean): AbstractMesh;
  24313. /**
  24314. * Overwrite the current bounding info
  24315. * @param boundingInfo defines the new bounding info
  24316. * @returns the current mesh
  24317. */
  24318. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  24319. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  24320. readonly useBones: boolean;
  24321. /** @hidden */
  24322. _preActivate(): void;
  24323. /** @hidden */
  24324. _preActivateForIntermediateRendering(renderId: number): void;
  24325. /** @hidden */
  24326. _activate(renderId: number): void;
  24327. /**
  24328. * Gets the current world matrix
  24329. * @returns a Matrix
  24330. */
  24331. getWorldMatrix(): Matrix;
  24332. /** @hidden */
  24333. _getWorldMatrixDeterminant(): number;
  24334. /**
  24335. * Perform relative position change from the point of view of behind the front of the mesh.
  24336. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24337. * Supports definition of mesh facing forward or backward
  24338. * @param amountRight defines the distance on the right axis
  24339. * @param amountUp defines the distance on the up axis
  24340. * @param amountForward defines the distance on the forward axis
  24341. * @returns the current mesh
  24342. */
  24343. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  24344. /**
  24345. * Calculate relative position change from the point of view of behind the front of the mesh.
  24346. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24347. * Supports definition of mesh facing forward or backward
  24348. * @param amountRight defines the distance on the right axis
  24349. * @param amountUp defines the distance on the up axis
  24350. * @param amountForward defines the distance on the forward axis
  24351. * @returns the new displacement vector
  24352. */
  24353. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  24354. /**
  24355. * Perform relative rotation change from the point of view of behind the front of the mesh.
  24356. * Supports definition of mesh facing forward or backward
  24357. * @param flipBack defines the flip
  24358. * @param twirlClockwise defines the twirl
  24359. * @param tiltRight defines the tilt
  24360. * @returns the current mesh
  24361. */
  24362. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  24363. /**
  24364. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  24365. * Supports definition of mesh facing forward or backward.
  24366. * @param flipBack defines the flip
  24367. * @param twirlClockwise defines the twirl
  24368. * @param tiltRight defines the tilt
  24369. * @returns the new rotation vector
  24370. */
  24371. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  24372. /**
  24373. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  24374. * @param includeDescendants Include bounding info from descendants as well (true by default)
  24375. * @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
  24376. * @returns the new bounding vectors
  24377. */
  24378. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  24379. min: Vector3;
  24380. max: Vector3;
  24381. };
  24382. /**
  24383. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24384. * This means the mesh underlying bounding box and sphere are recomputed.
  24385. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24386. * @returns the current mesh
  24387. */
  24388. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  24389. /** @hidden */
  24390. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  24391. /** @hidden */
  24392. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  24393. /** @hidden */
  24394. _updateBoundingInfo(): AbstractMesh;
  24395. /** @hidden */
  24396. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  24397. /** @hidden */
  24398. protected _afterComputeWorldMatrix(): void;
  24399. /**
  24400. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24401. * A mesh is in the frustum if its bounding box intersects the frustum
  24402. * @param frustumPlanes defines the frustum to test
  24403. * @returns true if the mesh is in the frustum planes
  24404. */
  24405. isInFrustum(frustumPlanes: Plane[]): boolean;
  24406. /**
  24407. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  24408. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  24409. * @param frustumPlanes defines the frustum to test
  24410. * @returns true if the mesh is completely in the frustum planes
  24411. */
  24412. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  24413. /**
  24414. * True if the mesh intersects another mesh or a SolidParticle object
  24415. * @param mesh defines a target mesh or SolidParticle to test
  24416. * @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)
  24417. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  24418. * @returns true if there is an intersection
  24419. */
  24420. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  24421. /**
  24422. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  24423. * @param point defines the point to test
  24424. * @returns true if there is an intersection
  24425. */
  24426. intersectsPoint(point: Vector3): boolean;
  24427. /**
  24428. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  24429. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24430. */
  24431. checkCollisions: boolean;
  24432. /**
  24433. * Gets Collider object used to compute collisions (not physics)
  24434. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24435. */
  24436. readonly collider: Collider;
  24437. /**
  24438. * Move the mesh using collision engine
  24439. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24440. * @param displacement defines the requested displacement vector
  24441. * @returns the current mesh
  24442. */
  24443. moveWithCollisions(displacement: Vector3): AbstractMesh;
  24444. private _onCollisionPositionChange;
  24445. /** @hidden */
  24446. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  24447. /** @hidden */
  24448. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  24449. /** @hidden */
  24450. _checkCollision(collider: Collider): AbstractMesh;
  24451. /** @hidden */
  24452. _generatePointsArray(): boolean;
  24453. /**
  24454. * Checks if the passed Ray intersects with the mesh
  24455. * @param ray defines the ray to use
  24456. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  24457. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  24458. * @returns the picking info
  24459. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  24460. */
  24461. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  24462. /**
  24463. * Clones the current mesh
  24464. * @param name defines the mesh name
  24465. * @param newParent defines the new mesh parent
  24466. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  24467. * @returns the new mesh
  24468. */
  24469. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  24470. /**
  24471. * Disposes all the submeshes of the current meshnp
  24472. * @returns the current mesh
  24473. */
  24474. releaseSubMeshes(): AbstractMesh;
  24475. /**
  24476. * Releases resources associated with this abstract mesh.
  24477. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24478. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24479. */
  24480. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24481. /**
  24482. * Adds the passed mesh as a child to the current mesh
  24483. * @param mesh defines the child mesh
  24484. * @returns the current mesh
  24485. */
  24486. addChild(mesh: AbstractMesh): AbstractMesh;
  24487. /**
  24488. * Removes the passed mesh from the current mesh children list
  24489. * @param mesh defines the child mesh
  24490. * @returns the current mesh
  24491. */
  24492. removeChild(mesh: AbstractMesh): AbstractMesh;
  24493. /** @hidden */
  24494. private _initFacetData;
  24495. /**
  24496. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  24497. * This method can be called within the render loop.
  24498. * 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
  24499. * @returns the current mesh
  24500. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24501. */
  24502. updateFacetData(): AbstractMesh;
  24503. /**
  24504. * Returns the facetLocalNormals array.
  24505. * The normals are expressed in the mesh local spac
  24506. * @returns an array of Vector3
  24507. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24508. */
  24509. getFacetLocalNormals(): Vector3[];
  24510. /**
  24511. * Returns the facetLocalPositions array.
  24512. * The facet positions are expressed in the mesh local space
  24513. * @returns an array of Vector3
  24514. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24515. */
  24516. getFacetLocalPositions(): Vector3[];
  24517. /**
  24518. * Returns the facetLocalPartioning array
  24519. * @returns an array of array of numbers
  24520. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24521. */
  24522. getFacetLocalPartitioning(): number[][];
  24523. /**
  24524. * Returns the i-th facet position in the world system.
  24525. * This method allocates a new Vector3 per call
  24526. * @param i defines the facet index
  24527. * @returns a new Vector3
  24528. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24529. */
  24530. getFacetPosition(i: number): Vector3;
  24531. /**
  24532. * Sets the reference Vector3 with the i-th facet position in the world system
  24533. * @param i defines the facet index
  24534. * @param ref defines the target vector
  24535. * @returns the current mesh
  24536. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24537. */
  24538. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  24539. /**
  24540. * Returns the i-th facet normal in the world system.
  24541. * This method allocates a new Vector3 per call
  24542. * @param i defines the facet index
  24543. * @returns a new Vector3
  24544. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24545. */
  24546. getFacetNormal(i: number): Vector3;
  24547. /**
  24548. * Sets the reference Vector3 with the i-th facet normal in the world system
  24549. * @param i defines the facet index
  24550. * @param ref defines the target vector
  24551. * @returns the current mesh
  24552. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24553. */
  24554. getFacetNormalToRef(i: number, ref: Vector3): this;
  24555. /**
  24556. * 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)
  24557. * @param x defines x coordinate
  24558. * @param y defines y coordinate
  24559. * @param z defines z coordinate
  24560. * @returns the array of facet indexes
  24561. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24562. */
  24563. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  24564. /**
  24565. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  24566. * @param projected sets as the (x,y,z) world projection on the facet
  24567. * @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
  24568. * @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
  24569. * @param x defines x coordinate
  24570. * @param y defines y coordinate
  24571. * @param z defines z coordinate
  24572. * @returns the face index if found (or null instead)
  24573. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24574. */
  24575. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  24576. /**
  24577. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  24578. * @param projected sets as the (x,y,z) local projection on the facet
  24579. * @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
  24580. * @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
  24581. * @param x defines x coordinate
  24582. * @param y defines y coordinate
  24583. * @param z defines z coordinate
  24584. * @returns the face index if found (or null instead)
  24585. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24586. */
  24587. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  24588. /**
  24589. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  24590. * @returns the parameters
  24591. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24592. */
  24593. getFacetDataParameters(): any;
  24594. /**
  24595. * Disables the feature FacetData and frees the related memory
  24596. * @returns the current mesh
  24597. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24598. */
  24599. disableFacetData(): AbstractMesh;
  24600. /**
  24601. * Updates the AbstractMesh indices array
  24602. * @param indices defines the data source
  24603. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  24604. * @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)
  24605. * @returns the current mesh
  24606. */
  24607. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  24608. /**
  24609. * Creates new normals data for the mesh
  24610. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  24611. * @returns the current mesh
  24612. */
  24613. createNormals(updatable: boolean): AbstractMesh;
  24614. /**
  24615. * Align the mesh with a normal
  24616. * @param normal defines the normal to use
  24617. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  24618. * @returns the current mesh
  24619. */
  24620. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  24621. /** @hidden */
  24622. _checkOcclusionQuery(): boolean;
  24623. }
  24624. }
  24625. declare module "babylonjs/Actions/actionEvent" {
  24626. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24627. import { Nullable } from "babylonjs/types";
  24628. import { Sprite } from "babylonjs/Sprites/sprite";
  24629. import { Scene } from "babylonjs/scene";
  24630. import { Vector2 } from "babylonjs/Maths/math";
  24631. /**
  24632. * Interface used to define ActionEvent
  24633. */
  24634. export interface IActionEvent {
  24635. /** The mesh or sprite that triggered the action */
  24636. source: any;
  24637. /** The X mouse cursor position at the time of the event */
  24638. pointerX: number;
  24639. /** The Y mouse cursor position at the time of the event */
  24640. pointerY: number;
  24641. /** The mesh that is currently pointed at (can be null) */
  24642. meshUnderPointer: Nullable<AbstractMesh>;
  24643. /** the original (browser) event that triggered the ActionEvent */
  24644. sourceEvent?: any;
  24645. /** additional data for the event */
  24646. additionalData?: any;
  24647. }
  24648. /**
  24649. * ActionEvent is the event being sent when an action is triggered.
  24650. */
  24651. export class ActionEvent implements IActionEvent {
  24652. /** The mesh or sprite that triggered the action */
  24653. source: any;
  24654. /** The X mouse cursor position at the time of the event */
  24655. pointerX: number;
  24656. /** The Y mouse cursor position at the time of the event */
  24657. pointerY: number;
  24658. /** The mesh that is currently pointed at (can be null) */
  24659. meshUnderPointer: Nullable<AbstractMesh>;
  24660. /** the original (browser) event that triggered the ActionEvent */
  24661. sourceEvent?: any;
  24662. /** additional data for the event */
  24663. additionalData?: any;
  24664. /**
  24665. * Creates a new ActionEvent
  24666. * @param source The mesh or sprite that triggered the action
  24667. * @param pointerX The X mouse cursor position at the time of the event
  24668. * @param pointerY The Y mouse cursor position at the time of the event
  24669. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  24670. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  24671. * @param additionalData additional data for the event
  24672. */
  24673. constructor(
  24674. /** The mesh or sprite that triggered the action */
  24675. source: any,
  24676. /** The X mouse cursor position at the time of the event */
  24677. pointerX: number,
  24678. /** The Y mouse cursor position at the time of the event */
  24679. pointerY: number,
  24680. /** The mesh that is currently pointed at (can be null) */
  24681. meshUnderPointer: Nullable<AbstractMesh>,
  24682. /** the original (browser) event that triggered the ActionEvent */
  24683. sourceEvent?: any,
  24684. /** additional data for the event */
  24685. additionalData?: any);
  24686. /**
  24687. * Helper function to auto-create an ActionEvent from a source mesh.
  24688. * @param source The source mesh that triggered the event
  24689. * @param evt The original (browser) event
  24690. * @param additionalData additional data for the event
  24691. * @returns the new ActionEvent
  24692. */
  24693. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  24694. /**
  24695. * Helper function to auto-create an ActionEvent from a source sprite
  24696. * @param source The source sprite that triggered the event
  24697. * @param scene Scene associated with the sprite
  24698. * @param evt The original (browser) event
  24699. * @param additionalData additional data for the event
  24700. * @returns the new ActionEvent
  24701. */
  24702. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  24703. /**
  24704. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  24705. * @param scene the scene where the event occurred
  24706. * @param evt The original (browser) event
  24707. * @returns the new ActionEvent
  24708. */
  24709. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  24710. /**
  24711. * Helper function to auto-create an ActionEvent from a primitive
  24712. * @param prim defines the target primitive
  24713. * @param pointerPos defines the pointer position
  24714. * @param evt The original (browser) event
  24715. * @param additionalData additional data for the event
  24716. * @returns the new ActionEvent
  24717. */
  24718. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  24719. }
  24720. }
  24721. declare module "babylonjs/Actions/abstractActionManager" {
  24722. import { IDisposable } from "babylonjs/scene";
  24723. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  24724. import { IAction } from "babylonjs/Actions/action";
  24725. import { Nullable } from "babylonjs/types";
  24726. /**
  24727. * Abstract class used to decouple action Manager from scene and meshes.
  24728. * Do not instantiate.
  24729. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  24730. */
  24731. export abstract class AbstractActionManager implements IDisposable {
  24732. /** Gets the list of active triggers */
  24733. static Triggers: {
  24734. [key: string]: number;
  24735. };
  24736. /** Gets the cursor to use when hovering items */
  24737. hoverCursor: string;
  24738. /** Gets the list of actions */
  24739. actions: IAction[];
  24740. /**
  24741. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  24742. */
  24743. isRecursive: boolean;
  24744. /**
  24745. * Releases all associated resources
  24746. */
  24747. abstract dispose(): void;
  24748. /**
  24749. * Does this action manager has pointer triggers
  24750. */
  24751. abstract readonly hasPointerTriggers: boolean;
  24752. /**
  24753. * Does this action manager has pick triggers
  24754. */
  24755. abstract readonly hasPickTriggers: boolean;
  24756. /**
  24757. * Process a specific trigger
  24758. * @param trigger defines the trigger to process
  24759. * @param evt defines the event details to be processed
  24760. */
  24761. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  24762. /**
  24763. * Does this action manager handles actions of any of the given triggers
  24764. * @param triggers defines the triggers to be tested
  24765. * @return a boolean indicating whether one (or more) of the triggers is handled
  24766. */
  24767. abstract hasSpecificTriggers(triggers: number[]): boolean;
  24768. /**
  24769. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  24770. * speed.
  24771. * @param triggerA defines the trigger to be tested
  24772. * @param triggerB defines the trigger to be tested
  24773. * @return a boolean indicating whether one (or more) of the triggers is handled
  24774. */
  24775. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  24776. /**
  24777. * Does this action manager handles actions of a given trigger
  24778. * @param trigger defines the trigger to be tested
  24779. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  24780. * @return whether the trigger is handled
  24781. */
  24782. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  24783. /**
  24784. * Serialize this manager to a JSON object
  24785. * @param name defines the property name to store this manager
  24786. * @returns a JSON representation of this manager
  24787. */
  24788. abstract serialize(name: string): any;
  24789. /**
  24790. * Registers an action to this action manager
  24791. * @param action defines the action to be registered
  24792. * @return the action amended (prepared) after registration
  24793. */
  24794. abstract registerAction(action: IAction): Nullable<IAction>;
  24795. /**
  24796. * Unregisters an action to this action manager
  24797. * @param action defines the action to be unregistered
  24798. * @return a boolean indicating whether the action has been unregistered
  24799. */
  24800. abstract unregisterAction(action: IAction): Boolean;
  24801. /**
  24802. * Does exist one action manager with at least one trigger
  24803. **/
  24804. static readonly HasTriggers: boolean;
  24805. /**
  24806. * Does exist one action manager with at least one pick trigger
  24807. **/
  24808. static readonly HasPickTriggers: boolean;
  24809. /**
  24810. * Does exist one action manager that handles actions of a given trigger
  24811. * @param trigger defines the trigger to be tested
  24812. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  24813. **/
  24814. static HasSpecificTrigger(trigger: number): boolean;
  24815. }
  24816. }
  24817. declare module "babylonjs/node" {
  24818. import { Scene } from "babylonjs/scene";
  24819. import { Nullable } from "babylonjs/types";
  24820. import { Matrix } from "babylonjs/Maths/math";
  24821. import { Engine } from "babylonjs/Engines/engine";
  24822. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  24823. import { Observable } from "babylonjs/Misc/observable";
  24824. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  24825. import { Animatable } from "babylonjs/Animations/animatable";
  24826. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  24827. import { Animation } from "babylonjs/Animations/animation";
  24828. import { AnimationRange } from "babylonjs/Animations/animationRange";
  24829. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24830. /**
  24831. * Defines how a node can be built from a string name.
  24832. */
  24833. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  24834. /**
  24835. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  24836. */
  24837. export class Node implements IBehaviorAware<Node> {
  24838. /** @hidden */
  24839. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  24840. private static _NodeConstructors;
  24841. /**
  24842. * Add a new node constructor
  24843. * @param type defines the type name of the node to construct
  24844. * @param constructorFunc defines the constructor function
  24845. */
  24846. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  24847. /**
  24848. * Returns a node constructor based on type name
  24849. * @param type defines the type name
  24850. * @param name defines the new node name
  24851. * @param scene defines the hosting scene
  24852. * @param options defines optional options to transmit to constructors
  24853. * @returns the new constructor or null
  24854. */
  24855. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  24856. /**
  24857. * Gets or sets the name of the node
  24858. */
  24859. name: string;
  24860. /**
  24861. * Gets or sets the id of the node
  24862. */
  24863. id: string;
  24864. /**
  24865. * Gets or sets the unique id of the node
  24866. */
  24867. uniqueId: number;
  24868. /**
  24869. * Gets or sets a string used to store user defined state for the node
  24870. */
  24871. state: string;
  24872. /**
  24873. * Gets or sets an object used to store user defined information for the node
  24874. */
  24875. metadata: any;
  24876. /**
  24877. * For internal use only. Please do not use.
  24878. */
  24879. reservedDataStore: any;
  24880. /**
  24881. * Gets or sets a boolean used to define if the node must be serialized
  24882. */
  24883. doNotSerialize: boolean;
  24884. /** @hidden */
  24885. _isDisposed: boolean;
  24886. /**
  24887. * Gets a list of Animations associated with the node
  24888. */
  24889. animations: import("babylonjs/Animations/animation").Animation[];
  24890. protected _ranges: {
  24891. [name: string]: Nullable<AnimationRange>;
  24892. };
  24893. /**
  24894. * Callback raised when the node is ready to be used
  24895. */
  24896. onReady: (node: Node) => void;
  24897. private _isEnabled;
  24898. private _isParentEnabled;
  24899. private _isReady;
  24900. /** @hidden */
  24901. _currentRenderId: number;
  24902. private _parentRenderId;
  24903. protected _childRenderId: number;
  24904. /** @hidden */
  24905. _waitingParentId: Nullable<string>;
  24906. /** @hidden */
  24907. _scene: Scene;
  24908. /** @hidden */
  24909. _cache: any;
  24910. private _parentNode;
  24911. private _children;
  24912. /** @hidden */
  24913. _worldMatrix: Matrix;
  24914. /** @hidden */
  24915. _worldMatrixDeterminant: number;
  24916. /** @hidden */
  24917. private _sceneRootNodesIndex;
  24918. /**
  24919. * Gets a boolean indicating if the node has been disposed
  24920. * @returns true if the node was disposed
  24921. */
  24922. isDisposed(): boolean;
  24923. /**
  24924. * Gets or sets the parent of the node
  24925. */
  24926. parent: Nullable<Node>;
  24927. private addToSceneRootNodes;
  24928. private removeFromSceneRootNodes;
  24929. private _animationPropertiesOverride;
  24930. /**
  24931. * Gets or sets the animation properties override
  24932. */
  24933. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  24934. /**
  24935. * Gets a string idenfifying the name of the class
  24936. * @returns "Node" string
  24937. */
  24938. getClassName(): string;
  24939. /** @hidden */
  24940. readonly _isNode: boolean;
  24941. /**
  24942. * An event triggered when the mesh is disposed
  24943. */
  24944. onDisposeObservable: Observable<Node>;
  24945. private _onDisposeObserver;
  24946. /**
  24947. * Sets a callback that will be raised when the node will be disposed
  24948. */
  24949. onDispose: () => void;
  24950. /**
  24951. * Creates a new Node
  24952. * @param name the name and id to be given to this node
  24953. * @param scene the scene this node will be added to
  24954. * @param addToRootNodes the node will be added to scene.rootNodes
  24955. */
  24956. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  24957. /**
  24958. * Gets the scene of the node
  24959. * @returns a scene
  24960. */
  24961. getScene(): Scene;
  24962. /**
  24963. * Gets the engine of the node
  24964. * @returns a Engine
  24965. */
  24966. getEngine(): Engine;
  24967. private _behaviors;
  24968. /**
  24969. * Attach a behavior to the node
  24970. * @see http://doc.babylonjs.com/features/behaviour
  24971. * @param behavior defines the behavior to attach
  24972. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  24973. * @returns the current Node
  24974. */
  24975. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  24976. /**
  24977. * Remove an attached behavior
  24978. * @see http://doc.babylonjs.com/features/behaviour
  24979. * @param behavior defines the behavior to attach
  24980. * @returns the current Node
  24981. */
  24982. removeBehavior(behavior: Behavior<Node>): Node;
  24983. /**
  24984. * Gets the list of attached behaviors
  24985. * @see http://doc.babylonjs.com/features/behaviour
  24986. */
  24987. readonly behaviors: Behavior<Node>[];
  24988. /**
  24989. * Gets an attached behavior by name
  24990. * @param name defines the name of the behavior to look for
  24991. * @see http://doc.babylonjs.com/features/behaviour
  24992. * @returns null if behavior was not found else the requested behavior
  24993. */
  24994. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  24995. /**
  24996. * Returns the latest update of the World matrix
  24997. * @returns a Matrix
  24998. */
  24999. getWorldMatrix(): Matrix;
  25000. /** @hidden */
  25001. _getWorldMatrixDeterminant(): number;
  25002. /**
  25003. * Returns directly the latest state of the mesh World matrix.
  25004. * A Matrix is returned.
  25005. */
  25006. readonly worldMatrixFromCache: Matrix;
  25007. /** @hidden */
  25008. _initCache(): void;
  25009. /** @hidden */
  25010. updateCache(force?: boolean): void;
  25011. /** @hidden */
  25012. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  25013. /** @hidden */
  25014. _updateCache(ignoreParentClass?: boolean): void;
  25015. /** @hidden */
  25016. _isSynchronized(): boolean;
  25017. /** @hidden */
  25018. _markSyncedWithParent(): void;
  25019. /** @hidden */
  25020. isSynchronizedWithParent(): boolean;
  25021. /** @hidden */
  25022. isSynchronized(): boolean;
  25023. /**
  25024. * Is this node ready to be used/rendered
  25025. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  25026. * @return true if the node is ready
  25027. */
  25028. isReady(completeCheck?: boolean): boolean;
  25029. /**
  25030. * Is this node enabled?
  25031. * 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
  25032. * @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
  25033. * @return whether this node (and its parent) is enabled
  25034. */
  25035. isEnabled(checkAncestors?: boolean): boolean;
  25036. /** @hidden */
  25037. protected _syncParentEnabledState(): void;
  25038. /**
  25039. * Set the enabled state of this node
  25040. * @param value defines the new enabled state
  25041. */
  25042. setEnabled(value: boolean): void;
  25043. /**
  25044. * Is this node a descendant of the given node?
  25045. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  25046. * @param ancestor defines the parent node to inspect
  25047. * @returns a boolean indicating if this node is a descendant of the given node
  25048. */
  25049. isDescendantOf(ancestor: Node): boolean;
  25050. /** @hidden */
  25051. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  25052. /**
  25053. * Will return all nodes that have this node as ascendant
  25054. * @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
  25055. * @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
  25056. * @return all children nodes of all types
  25057. */
  25058. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  25059. /**
  25060. * Get all child-meshes of this node
  25061. * @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)
  25062. * @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
  25063. * @returns an array of AbstractMesh
  25064. */
  25065. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  25066. /**
  25067. * Get all direct children of this node
  25068. * @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
  25069. * @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)
  25070. * @returns an array of Node
  25071. */
  25072. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  25073. /** @hidden */
  25074. _setReady(state: boolean): void;
  25075. /**
  25076. * Get an animation by name
  25077. * @param name defines the name of the animation to look for
  25078. * @returns null if not found else the requested animation
  25079. */
  25080. getAnimationByName(name: string): Nullable<Animation>;
  25081. /**
  25082. * Creates an animation range for this node
  25083. * @param name defines the name of the range
  25084. * @param from defines the starting key
  25085. * @param to defines the end key
  25086. */
  25087. createAnimationRange(name: string, from: number, to: number): void;
  25088. /**
  25089. * Delete a specific animation range
  25090. * @param name defines the name of the range to delete
  25091. * @param deleteFrames defines if animation frames from the range must be deleted as well
  25092. */
  25093. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  25094. /**
  25095. * Get an animation range by name
  25096. * @param name defines the name of the animation range to look for
  25097. * @returns null if not found else the requested animation range
  25098. */
  25099. getAnimationRange(name: string): Nullable<AnimationRange>;
  25100. /**
  25101. * Gets the list of all animation ranges defined on this node
  25102. * @returns an array
  25103. */
  25104. getAnimationRanges(): Nullable<AnimationRange>[];
  25105. /**
  25106. * Will start the animation sequence
  25107. * @param name defines the range frames for animation sequence
  25108. * @param loop defines if the animation should loop (false by default)
  25109. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  25110. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  25111. * @returns the object created for this animation. If range does not exist, it will return null
  25112. */
  25113. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  25114. /**
  25115. * Serialize animation ranges into a JSON compatible object
  25116. * @returns serialization object
  25117. */
  25118. serializeAnimationRanges(): any;
  25119. /**
  25120. * Computes the world matrix of the node
  25121. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  25122. * @returns the world matrix
  25123. */
  25124. computeWorldMatrix(force?: boolean): Matrix;
  25125. /**
  25126. * Releases resources associated with this node.
  25127. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25128. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25129. */
  25130. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25131. /**
  25132. * Parse animation range data from a serialization object and store them into a given node
  25133. * @param node defines where to store the animation ranges
  25134. * @param parsedNode defines the serialization object to read data from
  25135. * @param scene defines the hosting scene
  25136. */
  25137. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  25138. }
  25139. }
  25140. declare module "babylonjs/Animations/animation" {
  25141. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  25142. import { Vector3, Quaternion, Vector2, Color3, Size, Matrix } from "babylonjs/Maths/math";
  25143. import { Nullable } from "babylonjs/types";
  25144. import { Scene } from "babylonjs/scene";
  25145. import { IAnimatable } from "babylonjs/Misc/tools";
  25146. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  25147. import { AnimationRange } from "babylonjs/Animations/animationRange";
  25148. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  25149. import { Node } from "babylonjs/node";
  25150. import { Animatable } from "babylonjs/Animations/animatable";
  25151. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  25152. /**
  25153. * Class used to store any kind of animation
  25154. */
  25155. export class Animation {
  25156. /**Name of the animation */
  25157. name: string;
  25158. /**Property to animate */
  25159. targetProperty: string;
  25160. /**The frames per second of the animation */
  25161. framePerSecond: number;
  25162. /**The data type of the animation */
  25163. dataType: number;
  25164. /**The loop mode of the animation */
  25165. loopMode?: number | undefined;
  25166. /**Specifies if blending should be enabled */
  25167. enableBlending?: boolean | undefined;
  25168. /**
  25169. * Use matrix interpolation instead of using direct key value when animating matrices
  25170. */
  25171. static AllowMatricesInterpolation: boolean;
  25172. /**
  25173. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  25174. */
  25175. static AllowMatrixDecomposeForInterpolation: boolean;
  25176. /**
  25177. * Stores the key frames of the animation
  25178. */
  25179. private _keys;
  25180. /**
  25181. * Stores the easing function of the animation
  25182. */
  25183. private _easingFunction;
  25184. /**
  25185. * @hidden Internal use only
  25186. */
  25187. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  25188. /**
  25189. * The set of event that will be linked to this animation
  25190. */
  25191. private _events;
  25192. /**
  25193. * Stores an array of target property paths
  25194. */
  25195. targetPropertyPath: string[];
  25196. /**
  25197. * Stores the blending speed of the animation
  25198. */
  25199. blendingSpeed: number;
  25200. /**
  25201. * Stores the animation ranges for the animation
  25202. */
  25203. private _ranges;
  25204. /**
  25205. * @hidden Internal use
  25206. */
  25207. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  25208. /**
  25209. * Sets up an animation
  25210. * @param property The property to animate
  25211. * @param animationType The animation type to apply
  25212. * @param framePerSecond The frames per second of the animation
  25213. * @param easingFunction The easing function used in the animation
  25214. * @returns The created animation
  25215. */
  25216. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  25217. /**
  25218. * Create and start an animation on a node
  25219. * @param name defines the name of the global animation that will be run on all nodes
  25220. * @param node defines the root node where the animation will take place
  25221. * @param targetProperty defines property to animate
  25222. * @param framePerSecond defines the number of frame per second yo use
  25223. * @param totalFrame defines the number of frames in total
  25224. * @param from defines the initial value
  25225. * @param to defines the final value
  25226. * @param loopMode defines which loop mode you want to use (off by default)
  25227. * @param easingFunction defines the easing function to use (linear by default)
  25228. * @param onAnimationEnd defines the callback to call when animation end
  25229. * @returns the animatable created for this animation
  25230. */
  25231. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  25232. /**
  25233. * Create and start an animation on a node and its descendants
  25234. * @param name defines the name of the global animation that will be run on all nodes
  25235. * @param node defines the root node where the animation will take place
  25236. * @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
  25237. * @param targetProperty defines property to animate
  25238. * @param framePerSecond defines the number of frame per second to use
  25239. * @param totalFrame defines the number of frames in total
  25240. * @param from defines the initial value
  25241. * @param to defines the final value
  25242. * @param loopMode defines which loop mode you want to use (off by default)
  25243. * @param easingFunction defines the easing function to use (linear by default)
  25244. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  25245. * @returns the list of animatables created for all nodes
  25246. * @example https://www.babylonjs-playground.com/#MH0VLI
  25247. */
  25248. 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[]>;
  25249. /**
  25250. * Creates a new animation, merges it with the existing animations and starts it
  25251. * @param name Name of the animation
  25252. * @param node Node which contains the scene that begins the animations
  25253. * @param targetProperty Specifies which property to animate
  25254. * @param framePerSecond The frames per second of the animation
  25255. * @param totalFrame The total number of frames
  25256. * @param from The frame at the beginning of the animation
  25257. * @param to The frame at the end of the animation
  25258. * @param loopMode Specifies the loop mode of the animation
  25259. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  25260. * @param onAnimationEnd Callback to run once the animation is complete
  25261. * @returns Nullable animation
  25262. */
  25263. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  25264. /**
  25265. * Transition property of an host to the target Value
  25266. * @param property The property to transition
  25267. * @param targetValue The target Value of the property
  25268. * @param host The object where the property to animate belongs
  25269. * @param scene Scene used to run the animation
  25270. * @param frameRate Framerate (in frame/s) to use
  25271. * @param transition The transition type we want to use
  25272. * @param duration The duration of the animation, in milliseconds
  25273. * @param onAnimationEnd Callback trigger at the end of the animation
  25274. * @returns Nullable animation
  25275. */
  25276. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  25277. /**
  25278. * Return the array of runtime animations currently using this animation
  25279. */
  25280. readonly runtimeAnimations: RuntimeAnimation[];
  25281. /**
  25282. * Specifies if any of the runtime animations are currently running
  25283. */
  25284. readonly hasRunningRuntimeAnimations: boolean;
  25285. /**
  25286. * Initializes the animation
  25287. * @param name Name of the animation
  25288. * @param targetProperty Property to animate
  25289. * @param framePerSecond The frames per second of the animation
  25290. * @param dataType The data type of the animation
  25291. * @param loopMode The loop mode of the animation
  25292. * @param enableBlending Specifies if blending should be enabled
  25293. */
  25294. constructor(
  25295. /**Name of the animation */
  25296. name: string,
  25297. /**Property to animate */
  25298. targetProperty: string,
  25299. /**The frames per second of the animation */
  25300. framePerSecond: number,
  25301. /**The data type of the animation */
  25302. dataType: number,
  25303. /**The loop mode of the animation */
  25304. loopMode?: number | undefined,
  25305. /**Specifies if blending should be enabled */
  25306. enableBlending?: boolean | undefined);
  25307. /**
  25308. * Converts the animation to a string
  25309. * @param fullDetails support for multiple levels of logging within scene loading
  25310. * @returns String form of the animation
  25311. */
  25312. toString(fullDetails?: boolean): string;
  25313. /**
  25314. * Add an event to this animation
  25315. * @param event Event to add
  25316. */
  25317. addEvent(event: AnimationEvent): void;
  25318. /**
  25319. * Remove all events found at the given frame
  25320. * @param frame The frame to remove events from
  25321. */
  25322. removeEvents(frame: number): void;
  25323. /**
  25324. * Retrieves all the events from the animation
  25325. * @returns Events from the animation
  25326. */
  25327. getEvents(): AnimationEvent[];
  25328. /**
  25329. * Creates an animation range
  25330. * @param name Name of the animation range
  25331. * @param from Starting frame of the animation range
  25332. * @param to Ending frame of the animation
  25333. */
  25334. createRange(name: string, from: number, to: number): void;
  25335. /**
  25336. * Deletes an animation range by name
  25337. * @param name Name of the animation range to delete
  25338. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  25339. */
  25340. deleteRange(name: string, deleteFrames?: boolean): void;
  25341. /**
  25342. * Gets the animation range by name, or null if not defined
  25343. * @param name Name of the animation range
  25344. * @returns Nullable animation range
  25345. */
  25346. getRange(name: string): Nullable<AnimationRange>;
  25347. /**
  25348. * Gets the key frames from the animation
  25349. * @returns The key frames of the animation
  25350. */
  25351. getKeys(): Array<IAnimationKey>;
  25352. /**
  25353. * Gets the highest frame rate of the animation
  25354. * @returns Highest frame rate of the animation
  25355. */
  25356. getHighestFrame(): number;
  25357. /**
  25358. * Gets the easing function of the animation
  25359. * @returns Easing function of the animation
  25360. */
  25361. getEasingFunction(): IEasingFunction;
  25362. /**
  25363. * Sets the easing function of the animation
  25364. * @param easingFunction A custom mathematical formula for animation
  25365. */
  25366. setEasingFunction(easingFunction: EasingFunction): void;
  25367. /**
  25368. * Interpolates a scalar linearly
  25369. * @param startValue Start value of the animation curve
  25370. * @param endValue End value of the animation curve
  25371. * @param gradient Scalar amount to interpolate
  25372. * @returns Interpolated scalar value
  25373. */
  25374. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  25375. /**
  25376. * Interpolates a scalar cubically
  25377. * @param startValue Start value of the animation curve
  25378. * @param outTangent End tangent of the animation
  25379. * @param endValue End value of the animation curve
  25380. * @param inTangent Start tangent of the animation curve
  25381. * @param gradient Scalar amount to interpolate
  25382. * @returns Interpolated scalar value
  25383. */
  25384. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  25385. /**
  25386. * Interpolates a quaternion using a spherical linear interpolation
  25387. * @param startValue Start value of the animation curve
  25388. * @param endValue End value of the animation curve
  25389. * @param gradient Scalar amount to interpolate
  25390. * @returns Interpolated quaternion value
  25391. */
  25392. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  25393. /**
  25394. * Interpolates a quaternion cubically
  25395. * @param startValue Start value of the animation curve
  25396. * @param outTangent End tangent of the animation curve
  25397. * @param endValue End value of the animation curve
  25398. * @param inTangent Start tangent of the animation curve
  25399. * @param gradient Scalar amount to interpolate
  25400. * @returns Interpolated quaternion value
  25401. */
  25402. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  25403. /**
  25404. * Interpolates a Vector3 linearl
  25405. * @param startValue Start value of the animation curve
  25406. * @param endValue End value of the animation curve
  25407. * @param gradient Scalar amount to interpolate
  25408. * @returns Interpolated scalar value
  25409. */
  25410. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  25411. /**
  25412. * Interpolates a Vector3 cubically
  25413. * @param startValue Start value of the animation curve
  25414. * @param outTangent End tangent of the animation
  25415. * @param endValue End value of the animation curve
  25416. * @param inTangent Start tangent of the animation curve
  25417. * @param gradient Scalar amount to interpolate
  25418. * @returns InterpolatedVector3 value
  25419. */
  25420. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  25421. /**
  25422. * Interpolates a Vector2 linearly
  25423. * @param startValue Start value of the animation curve
  25424. * @param endValue End value of the animation curve
  25425. * @param gradient Scalar amount to interpolate
  25426. * @returns Interpolated Vector2 value
  25427. */
  25428. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  25429. /**
  25430. * Interpolates a Vector2 cubically
  25431. * @param startValue Start value of the animation curve
  25432. * @param outTangent End tangent of the animation
  25433. * @param endValue End value of the animation curve
  25434. * @param inTangent Start tangent of the animation curve
  25435. * @param gradient Scalar amount to interpolate
  25436. * @returns Interpolated Vector2 value
  25437. */
  25438. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  25439. /**
  25440. * Interpolates a size linearly
  25441. * @param startValue Start value of the animation curve
  25442. * @param endValue End value of the animation curve
  25443. * @param gradient Scalar amount to interpolate
  25444. * @returns Interpolated Size value
  25445. */
  25446. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  25447. /**
  25448. * Interpolates a Color3 linearly
  25449. * @param startValue Start value of the animation curve
  25450. * @param endValue End value of the animation curve
  25451. * @param gradient Scalar amount to interpolate
  25452. * @returns Interpolated Color3 value
  25453. */
  25454. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  25455. /**
  25456. * @hidden Internal use only
  25457. */
  25458. _getKeyValue(value: any): any;
  25459. /**
  25460. * @hidden Internal use only
  25461. */
  25462. _interpolate(currentFrame: number, repeatCount: number, workValue?: any, loopMode?: number, offsetValue?: any, highLimitValue?: any): any;
  25463. /**
  25464. * Defines the function to use to interpolate matrices
  25465. * @param startValue defines the start matrix
  25466. * @param endValue defines the end matrix
  25467. * @param gradient defines the gradient between both matrices
  25468. * @param result defines an optional target matrix where to store the interpolation
  25469. * @returns the interpolated matrix
  25470. */
  25471. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  25472. /**
  25473. * Makes a copy of the animation
  25474. * @returns Cloned animation
  25475. */
  25476. clone(): Animation;
  25477. /**
  25478. * Sets the key frames of the animation
  25479. * @param values The animation key frames to set
  25480. */
  25481. setKeys(values: Array<IAnimationKey>): void;
  25482. /**
  25483. * Serializes the animation to an object
  25484. * @returns Serialized object
  25485. */
  25486. serialize(): any;
  25487. /**
  25488. * Float animation type
  25489. */
  25490. private static _ANIMATIONTYPE_FLOAT;
  25491. /**
  25492. * Vector3 animation type
  25493. */
  25494. private static _ANIMATIONTYPE_VECTOR3;
  25495. /**
  25496. * Quaternion animation type
  25497. */
  25498. private static _ANIMATIONTYPE_QUATERNION;
  25499. /**
  25500. * Matrix animation type
  25501. */
  25502. private static _ANIMATIONTYPE_MATRIX;
  25503. /**
  25504. * Color3 animation type
  25505. */
  25506. private static _ANIMATIONTYPE_COLOR3;
  25507. /**
  25508. * Vector2 animation type
  25509. */
  25510. private static _ANIMATIONTYPE_VECTOR2;
  25511. /**
  25512. * Size animation type
  25513. */
  25514. private static _ANIMATIONTYPE_SIZE;
  25515. /**
  25516. * Relative Loop Mode
  25517. */
  25518. private static _ANIMATIONLOOPMODE_RELATIVE;
  25519. /**
  25520. * Cycle Loop Mode
  25521. */
  25522. private static _ANIMATIONLOOPMODE_CYCLE;
  25523. /**
  25524. * Constant Loop Mode
  25525. */
  25526. private static _ANIMATIONLOOPMODE_CONSTANT;
  25527. /**
  25528. * Get the float animation type
  25529. */
  25530. static readonly ANIMATIONTYPE_FLOAT: number;
  25531. /**
  25532. * Get the Vector3 animation type
  25533. */
  25534. static readonly ANIMATIONTYPE_VECTOR3: number;
  25535. /**
  25536. * Get the Vector2 animation type
  25537. */
  25538. static readonly ANIMATIONTYPE_VECTOR2: number;
  25539. /**
  25540. * Get the Size animation type
  25541. */
  25542. static readonly ANIMATIONTYPE_SIZE: number;
  25543. /**
  25544. * Get the Quaternion animation type
  25545. */
  25546. static readonly ANIMATIONTYPE_QUATERNION: number;
  25547. /**
  25548. * Get the Matrix animation type
  25549. */
  25550. static readonly ANIMATIONTYPE_MATRIX: number;
  25551. /**
  25552. * Get the Color3 animation type
  25553. */
  25554. static readonly ANIMATIONTYPE_COLOR3: number;
  25555. /**
  25556. * Get the Relative Loop Mode
  25557. */
  25558. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  25559. /**
  25560. * Get the Cycle Loop Mode
  25561. */
  25562. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  25563. /**
  25564. * Get the Constant Loop Mode
  25565. */
  25566. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  25567. /** @hidden */
  25568. static _UniversalLerp(left: any, right: any, amount: number): any;
  25569. /**
  25570. * Parses an animation object and creates an animation
  25571. * @param parsedAnimation Parsed animation object
  25572. * @returns Animation object
  25573. */
  25574. static Parse(parsedAnimation: any): Animation;
  25575. /**
  25576. * Appends the serialized animations from the source animations
  25577. * @param source Source containing the animations
  25578. * @param destination Target to store the animations
  25579. */
  25580. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  25581. }
  25582. }
  25583. declare module "babylonjs/Materials/Textures/baseTexture" {
  25584. import { Observable } from "babylonjs/Misc/observable";
  25585. import { IAnimatable } from "babylonjs/Misc/tools";
  25586. import { Nullable } from "babylonjs/types";
  25587. import { Scene } from "babylonjs/scene";
  25588. import { Matrix, ISize } from "babylonjs/Maths/math";
  25589. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  25590. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  25591. /**
  25592. * Base class of all the textures in babylon.
  25593. * It groups all the common properties the materials, post process, lights... might need
  25594. * in order to make a correct use of the texture.
  25595. */
  25596. export class BaseTexture implements IAnimatable {
  25597. /**
  25598. * Default anisotropic filtering level for the application.
  25599. * It is set to 4 as a good tradeoff between perf and quality.
  25600. */
  25601. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  25602. /**
  25603. * Gets or sets the unique id of the texture
  25604. */
  25605. uniqueId: number;
  25606. /**
  25607. * Define the name of the texture.
  25608. */
  25609. name: string;
  25610. /**
  25611. * Gets or sets an object used to store user defined information.
  25612. */
  25613. metadata: any;
  25614. /**
  25615. * For internal use only. Please do not use.
  25616. */
  25617. reservedDataStore: any;
  25618. private _hasAlpha;
  25619. /**
  25620. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  25621. */
  25622. hasAlpha: boolean;
  25623. /**
  25624. * Defines if the alpha value should be determined via the rgb values.
  25625. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  25626. */
  25627. getAlphaFromRGB: boolean;
  25628. /**
  25629. * Intensity or strength of the texture.
  25630. * It is commonly used by materials to fine tune the intensity of the texture
  25631. */
  25632. level: number;
  25633. /**
  25634. * Define the UV chanel to use starting from 0 and defaulting to 0.
  25635. * This is part of the texture as textures usually maps to one uv set.
  25636. */
  25637. coordinatesIndex: number;
  25638. private _coordinatesMode;
  25639. /**
  25640. * How a texture is mapped.
  25641. *
  25642. * | Value | Type | Description |
  25643. * | ----- | ----------------------------------- | ----------- |
  25644. * | 0 | EXPLICIT_MODE | |
  25645. * | 1 | SPHERICAL_MODE | |
  25646. * | 2 | PLANAR_MODE | |
  25647. * | 3 | CUBIC_MODE | |
  25648. * | 4 | PROJECTION_MODE | |
  25649. * | 5 | SKYBOX_MODE | |
  25650. * | 6 | INVCUBIC_MODE | |
  25651. * | 7 | EQUIRECTANGULAR_MODE | |
  25652. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  25653. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  25654. */
  25655. coordinatesMode: number;
  25656. /**
  25657. * | Value | Type | Description |
  25658. * | ----- | ------------------ | ----------- |
  25659. * | 0 | CLAMP_ADDRESSMODE | |
  25660. * | 1 | WRAP_ADDRESSMODE | |
  25661. * | 2 | MIRROR_ADDRESSMODE | |
  25662. */
  25663. wrapU: number;
  25664. /**
  25665. * | Value | Type | Description |
  25666. * | ----- | ------------------ | ----------- |
  25667. * | 0 | CLAMP_ADDRESSMODE | |
  25668. * | 1 | WRAP_ADDRESSMODE | |
  25669. * | 2 | MIRROR_ADDRESSMODE | |
  25670. */
  25671. wrapV: number;
  25672. /**
  25673. * | Value | Type | Description |
  25674. * | ----- | ------------------ | ----------- |
  25675. * | 0 | CLAMP_ADDRESSMODE | |
  25676. * | 1 | WRAP_ADDRESSMODE | |
  25677. * | 2 | MIRROR_ADDRESSMODE | |
  25678. */
  25679. wrapR: number;
  25680. /**
  25681. * With compliant hardware and browser (supporting anisotropic filtering)
  25682. * this defines the level of anisotropic filtering in the texture.
  25683. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  25684. */
  25685. anisotropicFilteringLevel: number;
  25686. /**
  25687. * Define if the texture is a cube texture or if false a 2d texture.
  25688. */
  25689. isCube: boolean;
  25690. /**
  25691. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  25692. */
  25693. is3D: boolean;
  25694. /**
  25695. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  25696. * HDR texture are usually stored in linear space.
  25697. * This only impacts the PBR and Background materials
  25698. */
  25699. gammaSpace: boolean;
  25700. /**
  25701. * Gets whether or not the texture contains RGBD data.
  25702. */
  25703. readonly isRGBD: boolean;
  25704. /**
  25705. * Is Z inverted in the texture (useful in a cube texture).
  25706. */
  25707. invertZ: boolean;
  25708. /**
  25709. * Are mip maps generated for this texture or not.
  25710. */
  25711. readonly noMipmap: boolean;
  25712. /**
  25713. * @hidden
  25714. */
  25715. lodLevelInAlpha: boolean;
  25716. /**
  25717. * With prefiltered texture, defined the offset used during the prefiltering steps.
  25718. */
  25719. lodGenerationOffset: number;
  25720. /**
  25721. * With prefiltered texture, defined the scale used during the prefiltering steps.
  25722. */
  25723. lodGenerationScale: number;
  25724. /**
  25725. * Define if the texture is a render target.
  25726. */
  25727. isRenderTarget: boolean;
  25728. /**
  25729. * Define the unique id of the texture in the scene.
  25730. */
  25731. readonly uid: string;
  25732. /**
  25733. * Return a string representation of the texture.
  25734. * @returns the texture as a string
  25735. */
  25736. toString(): string;
  25737. /**
  25738. * Get the class name of the texture.
  25739. * @returns "BaseTexture"
  25740. */
  25741. getClassName(): string;
  25742. /**
  25743. * Define the list of animation attached to the texture.
  25744. */
  25745. animations: import("babylonjs/Animations/animation").Animation[];
  25746. /**
  25747. * An event triggered when the texture is disposed.
  25748. */
  25749. onDisposeObservable: Observable<BaseTexture>;
  25750. private _onDisposeObserver;
  25751. /**
  25752. * Callback triggered when the texture has been disposed.
  25753. * Kept for back compatibility, you can use the onDisposeObservable instead.
  25754. */
  25755. onDispose: () => void;
  25756. /**
  25757. * Define the current state of the loading sequence when in delayed load mode.
  25758. */
  25759. delayLoadState: number;
  25760. private _scene;
  25761. /** @hidden */
  25762. _texture: Nullable<InternalTexture>;
  25763. private _uid;
  25764. /**
  25765. * Define if the texture is preventinga material to render or not.
  25766. * If not and the texture is not ready, the engine will use a default black texture instead.
  25767. */
  25768. readonly isBlocking: boolean;
  25769. /**
  25770. * Instantiates a new BaseTexture.
  25771. * Base class of all the textures in babylon.
  25772. * It groups all the common properties the materials, post process, lights... might need
  25773. * in order to make a correct use of the texture.
  25774. * @param scene Define the scene the texture blongs to
  25775. */
  25776. constructor(scene: Nullable<Scene>);
  25777. /**
  25778. * Get the scene the texture belongs to.
  25779. * @returns the scene or null if undefined
  25780. */
  25781. getScene(): Nullable<Scene>;
  25782. /**
  25783. * Get the texture transform matrix used to offset tile the texture for istance.
  25784. * @returns the transformation matrix
  25785. */
  25786. getTextureMatrix(): Matrix;
  25787. /**
  25788. * Get the texture reflection matrix used to rotate/transform the reflection.
  25789. * @returns the reflection matrix
  25790. */
  25791. getReflectionTextureMatrix(): Matrix;
  25792. /**
  25793. * Get the underlying lower level texture from Babylon.
  25794. * @returns the insternal texture
  25795. */
  25796. getInternalTexture(): Nullable<InternalTexture>;
  25797. /**
  25798. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  25799. * @returns true if ready or not blocking
  25800. */
  25801. isReadyOrNotBlocking(): boolean;
  25802. /**
  25803. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  25804. * @returns true if fully ready
  25805. */
  25806. isReady(): boolean;
  25807. private _cachedSize;
  25808. /**
  25809. * Get the size of the texture.
  25810. * @returns the texture size.
  25811. */
  25812. getSize(): ISize;
  25813. /**
  25814. * Get the base size of the texture.
  25815. * It can be different from the size if the texture has been resized for POT for instance
  25816. * @returns the base size
  25817. */
  25818. getBaseSize(): ISize;
  25819. /**
  25820. * Update the sampling mode of the texture.
  25821. * Default is Trilinear mode.
  25822. *
  25823. * | Value | Type | Description |
  25824. * | ----- | ------------------ | ----------- |
  25825. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  25826. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  25827. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  25828. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  25829. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  25830. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  25831. * | 7 | NEAREST_LINEAR | |
  25832. * | 8 | NEAREST_NEAREST | |
  25833. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  25834. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  25835. * | 11 | LINEAR_LINEAR | |
  25836. * | 12 | LINEAR_NEAREST | |
  25837. *
  25838. * > _mag_: magnification filter (close to the viewer)
  25839. * > _min_: minification filter (far from the viewer)
  25840. * > _mip_: filter used between mip map levels
  25841. *@param samplingMode Define the new sampling mode of the texture
  25842. */
  25843. updateSamplingMode(samplingMode: number): void;
  25844. /**
  25845. * Scales the texture if is `canRescale()`
  25846. * @param ratio the resize factor we want to use to rescale
  25847. */
  25848. scale(ratio: number): void;
  25849. /**
  25850. * Get if the texture can rescale.
  25851. */
  25852. readonly canRescale: boolean;
  25853. /** @hidden */
  25854. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  25855. /** @hidden */
  25856. _rebuild(): void;
  25857. /**
  25858. * Triggers the load sequence in delayed load mode.
  25859. */
  25860. delayLoad(): void;
  25861. /**
  25862. * Clones the texture.
  25863. * @returns the cloned texture
  25864. */
  25865. clone(): Nullable<BaseTexture>;
  25866. /**
  25867. * Get the texture underlying type (INT, FLOAT...)
  25868. */
  25869. readonly textureType: number;
  25870. /**
  25871. * Get the texture underlying format (RGB, RGBA...)
  25872. */
  25873. readonly textureFormat: number;
  25874. /**
  25875. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  25876. * This will returns an RGBA array buffer containing either in values (0-255) or
  25877. * float values (0-1) depending of the underlying buffer type.
  25878. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  25879. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  25880. * @param buffer defines a user defined buffer to fill with data (can be null)
  25881. * @returns The Array buffer containing the pixels data.
  25882. */
  25883. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  25884. /**
  25885. * Release and destroy the underlying lower level texture aka internalTexture.
  25886. */
  25887. releaseInternalTexture(): void;
  25888. /**
  25889. * Get the polynomial representation of the texture data.
  25890. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  25891. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  25892. */
  25893. sphericalPolynomial: Nullable<SphericalPolynomial>;
  25894. /** @hidden */
  25895. readonly _lodTextureHigh: Nullable<BaseTexture>;
  25896. /** @hidden */
  25897. readonly _lodTextureMid: Nullable<BaseTexture>;
  25898. /** @hidden */
  25899. readonly _lodTextureLow: Nullable<BaseTexture>;
  25900. /**
  25901. * Dispose the texture and release its associated resources.
  25902. */
  25903. dispose(): void;
  25904. /**
  25905. * Serialize the texture into a JSON representation that can be parsed later on.
  25906. * @returns the JSON representation of the texture
  25907. */
  25908. serialize(): any;
  25909. /**
  25910. * Helper function to be called back once a list of texture contains only ready textures.
  25911. * @param textures Define the list of textures to wait for
  25912. * @param callback Define the callback triggered once the entire list will be ready
  25913. */
  25914. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  25915. }
  25916. }
  25917. declare module "babylonjs/Materials/uniformBuffer" {
  25918. import { Nullable, FloatArray } from "babylonjs/types";
  25919. import { Matrix, Vector3, Color3, Vector4 } from "babylonjs/Maths/math";
  25920. import { Engine } from "babylonjs/Engines/engine";
  25921. import { Effect } from "babylonjs/Materials/effect";
  25922. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  25923. /**
  25924. * Uniform buffer objects.
  25925. *
  25926. * Handles blocks of uniform on the GPU.
  25927. *
  25928. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  25929. *
  25930. * For more information, please refer to :
  25931. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  25932. */
  25933. export class UniformBuffer {
  25934. private _engine;
  25935. private _buffer;
  25936. private _data;
  25937. private _bufferData;
  25938. private _dynamic?;
  25939. private _uniformLocations;
  25940. private _uniformSizes;
  25941. private _uniformLocationPointer;
  25942. private _needSync;
  25943. private _noUBO;
  25944. private _currentEffect;
  25945. private static _MAX_UNIFORM_SIZE;
  25946. private static _tempBuffer;
  25947. /**
  25948. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  25949. * This is dynamic to allow compat with webgl 1 and 2.
  25950. * You will need to pass the name of the uniform as well as the value.
  25951. */
  25952. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  25953. /**
  25954. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  25955. * This is dynamic to allow compat with webgl 1 and 2.
  25956. * You will need to pass the name of the uniform as well as the value.
  25957. */
  25958. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  25959. /**
  25960. * Lambda to Update a single float in a uniform buffer.
  25961. * This is dynamic to allow compat with webgl 1 and 2.
  25962. * You will need to pass the name of the uniform as well as the value.
  25963. */
  25964. updateFloat: (name: string, x: number) => void;
  25965. /**
  25966. * Lambda to Update a vec2 of float in a uniform buffer.
  25967. * This is dynamic to allow compat with webgl 1 and 2.
  25968. * You will need to pass the name of the uniform as well as the value.
  25969. */
  25970. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  25971. /**
  25972. * Lambda to Update a vec3 of float in a uniform buffer.
  25973. * This is dynamic to allow compat with webgl 1 and 2.
  25974. * You will need to pass the name of the uniform as well as the value.
  25975. */
  25976. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  25977. /**
  25978. * Lambda to Update a vec4 of float in a uniform buffer.
  25979. * This is dynamic to allow compat with webgl 1 and 2.
  25980. * You will need to pass the name of the uniform as well as the value.
  25981. */
  25982. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  25983. /**
  25984. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  25985. * This is dynamic to allow compat with webgl 1 and 2.
  25986. * You will need to pass the name of the uniform as well as the value.
  25987. */
  25988. updateMatrix: (name: string, mat: Matrix) => void;
  25989. /**
  25990. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  25991. * This is dynamic to allow compat with webgl 1 and 2.
  25992. * You will need to pass the name of the uniform as well as the value.
  25993. */
  25994. updateVector3: (name: string, vector: Vector3) => void;
  25995. /**
  25996. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  25997. * This is dynamic to allow compat with webgl 1 and 2.
  25998. * You will need to pass the name of the uniform as well as the value.
  25999. */
  26000. updateVector4: (name: string, vector: Vector4) => void;
  26001. /**
  26002. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  26003. * This is dynamic to allow compat with webgl 1 and 2.
  26004. * You will need to pass the name of the uniform as well as the value.
  26005. */
  26006. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  26007. /**
  26008. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  26009. * This is dynamic to allow compat with webgl 1 and 2.
  26010. * You will need to pass the name of the uniform as well as the value.
  26011. */
  26012. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  26013. /**
  26014. * Instantiates a new Uniform buffer objects.
  26015. *
  26016. * Handles blocks of uniform on the GPU.
  26017. *
  26018. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  26019. *
  26020. * For more information, please refer to :
  26021. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  26022. * @param engine Define the engine the buffer is associated with
  26023. * @param data Define the data contained in the buffer
  26024. * @param dynamic Define if the buffer is updatable
  26025. */
  26026. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  26027. /**
  26028. * Indicates if the buffer is using the WebGL2 UBO implementation,
  26029. * or just falling back on setUniformXXX calls.
  26030. */
  26031. readonly useUbo: boolean;
  26032. /**
  26033. * Indicates if the WebGL underlying uniform buffer is in sync
  26034. * with the javascript cache data.
  26035. */
  26036. readonly isSync: boolean;
  26037. /**
  26038. * Indicates if the WebGL underlying uniform buffer is dynamic.
  26039. * Also, a dynamic UniformBuffer will disable cache verification and always
  26040. * update the underlying WebGL uniform buffer to the GPU.
  26041. * @returns if Dynamic, otherwise false
  26042. */
  26043. isDynamic(): boolean;
  26044. /**
  26045. * The data cache on JS side.
  26046. * @returns the underlying data as a float array
  26047. */
  26048. getData(): Float32Array;
  26049. /**
  26050. * The underlying WebGL Uniform buffer.
  26051. * @returns the webgl buffer
  26052. */
  26053. getBuffer(): Nullable<WebGLBuffer>;
  26054. /**
  26055. * std140 layout specifies how to align data within an UBO structure.
  26056. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  26057. * for specs.
  26058. */
  26059. private _fillAlignment;
  26060. /**
  26061. * Adds an uniform in the buffer.
  26062. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  26063. * for the layout to be correct !
  26064. * @param name Name of the uniform, as used in the uniform block in the shader.
  26065. * @param size Data size, or data directly.
  26066. */
  26067. addUniform(name: string, size: number | number[]): void;
  26068. /**
  26069. * Adds a Matrix 4x4 to the uniform buffer.
  26070. * @param name Name of the uniform, as used in the uniform block in the shader.
  26071. * @param mat A 4x4 matrix.
  26072. */
  26073. addMatrix(name: string, mat: Matrix): void;
  26074. /**
  26075. * Adds a vec2 to the uniform buffer.
  26076. * @param name Name of the uniform, as used in the uniform block in the shader.
  26077. * @param x Define the x component value of the vec2
  26078. * @param y Define the y component value of the vec2
  26079. */
  26080. addFloat2(name: string, x: number, y: number): void;
  26081. /**
  26082. * Adds a vec3 to the uniform buffer.
  26083. * @param name Name of the uniform, as used in the uniform block in the shader.
  26084. * @param x Define the x component value of the vec3
  26085. * @param y Define the y component value of the vec3
  26086. * @param z Define the z component value of the vec3
  26087. */
  26088. addFloat3(name: string, x: number, y: number, z: number): void;
  26089. /**
  26090. * Adds a vec3 to the uniform buffer.
  26091. * @param name Name of the uniform, as used in the uniform block in the shader.
  26092. * @param color Define the vec3 from a Color
  26093. */
  26094. addColor3(name: string, color: Color3): void;
  26095. /**
  26096. * Adds a vec4 to the uniform buffer.
  26097. * @param name Name of the uniform, as used in the uniform block in the shader.
  26098. * @param color Define the rgb components from a Color
  26099. * @param alpha Define the a component of the vec4
  26100. */
  26101. addColor4(name: string, color: Color3, alpha: number): void;
  26102. /**
  26103. * Adds a vec3 to the uniform buffer.
  26104. * @param name Name of the uniform, as used in the uniform block in the shader.
  26105. * @param vector Define the vec3 components from a Vector
  26106. */
  26107. addVector3(name: string, vector: Vector3): void;
  26108. /**
  26109. * Adds a Matrix 3x3 to the uniform buffer.
  26110. * @param name Name of the uniform, as used in the uniform block in the shader.
  26111. */
  26112. addMatrix3x3(name: string): void;
  26113. /**
  26114. * Adds a Matrix 2x2 to the uniform buffer.
  26115. * @param name Name of the uniform, as used in the uniform block in the shader.
  26116. */
  26117. addMatrix2x2(name: string): void;
  26118. /**
  26119. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  26120. */
  26121. create(): void;
  26122. /** @hidden */
  26123. _rebuild(): void;
  26124. /**
  26125. * Updates the WebGL Uniform Buffer on the GPU.
  26126. * If the `dynamic` flag is set to true, no cache comparison is done.
  26127. * Otherwise, the buffer will be updated only if the cache differs.
  26128. */
  26129. update(): void;
  26130. /**
  26131. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  26132. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  26133. * @param data Define the flattened data
  26134. * @param size Define the size of the data.
  26135. */
  26136. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  26137. private _updateMatrix3x3ForUniform;
  26138. private _updateMatrix3x3ForEffect;
  26139. private _updateMatrix2x2ForEffect;
  26140. private _updateMatrix2x2ForUniform;
  26141. private _updateFloatForEffect;
  26142. private _updateFloatForUniform;
  26143. private _updateFloat2ForEffect;
  26144. private _updateFloat2ForUniform;
  26145. private _updateFloat3ForEffect;
  26146. private _updateFloat3ForUniform;
  26147. private _updateFloat4ForEffect;
  26148. private _updateFloat4ForUniform;
  26149. private _updateMatrixForEffect;
  26150. private _updateMatrixForUniform;
  26151. private _updateVector3ForEffect;
  26152. private _updateVector3ForUniform;
  26153. private _updateVector4ForEffect;
  26154. private _updateVector4ForUniform;
  26155. private _updateColor3ForEffect;
  26156. private _updateColor3ForUniform;
  26157. private _updateColor4ForEffect;
  26158. private _updateColor4ForUniform;
  26159. /**
  26160. * Sets a sampler uniform on the effect.
  26161. * @param name Define the name of the sampler.
  26162. * @param texture Define the texture to set in the sampler
  26163. */
  26164. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  26165. /**
  26166. * Directly updates the value of the uniform in the cache AND on the GPU.
  26167. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  26168. * @param data Define the flattened data
  26169. */
  26170. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  26171. /**
  26172. * Binds this uniform buffer to an effect.
  26173. * @param effect Define the effect to bind the buffer to
  26174. * @param name Name of the uniform block in the shader.
  26175. */
  26176. bindToEffect(effect: Effect, name: string): void;
  26177. /**
  26178. * Disposes the uniform buffer.
  26179. */
  26180. dispose(): void;
  26181. }
  26182. }
  26183. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  26184. import { Nullable } from "babylonjs/types";
  26185. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  26186. /**
  26187. * This represents the required contract to create a new type of texture loader.
  26188. */
  26189. export interface IInternalTextureLoader {
  26190. /**
  26191. * Defines wether the loader supports cascade loading the different faces.
  26192. */
  26193. supportCascades: boolean;
  26194. /**
  26195. * This returns if the loader support the current file information.
  26196. * @param extension defines the file extension of the file being loaded
  26197. * @param textureFormatInUse defines the current compressed format in use iun the engine
  26198. * @param fallback defines the fallback internal texture if any
  26199. * @param isBase64 defines whether the texture is encoded as a base64
  26200. * @param isBuffer defines whether the texture data are stored as a buffer
  26201. * @returns true if the loader can load the specified file
  26202. */
  26203. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  26204. /**
  26205. * Transform the url before loading if required.
  26206. * @param rootUrl the url of the texture
  26207. * @param textureFormatInUse defines the current compressed format in use iun the engine
  26208. * @returns the transformed texture
  26209. */
  26210. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  26211. /**
  26212. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  26213. * @param rootUrl the url of the texture
  26214. * @param textureFormatInUse defines the current compressed format in use iun the engine
  26215. * @returns the fallback texture
  26216. */
  26217. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  26218. /**
  26219. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  26220. * @param data contains the texture data
  26221. * @param texture defines the BabylonJS internal texture
  26222. * @param createPolynomials will be true if polynomials have been requested
  26223. * @param onLoad defines the callback to trigger once the texture is ready
  26224. * @param onError defines the callback to trigger in case of error
  26225. */
  26226. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  26227. /**
  26228. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  26229. * @param data contains the texture data
  26230. * @param texture defines the BabylonJS internal texture
  26231. * @param callback defines the method to call once ready to upload
  26232. */
  26233. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  26234. }
  26235. }
  26236. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  26237. import { Scene } from "babylonjs/scene";
  26238. import { Engine } from "babylonjs/Engines/engine";
  26239. import { Texture } from "babylonjs/Materials/Textures/texture";
  26240. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  26241. /**
  26242. * Creation options of the multi render target texture.
  26243. */
  26244. export interface IMultiRenderTargetOptions {
  26245. /**
  26246. * Define if the texture needs to create mip maps after render.
  26247. */
  26248. generateMipMaps?: boolean;
  26249. /**
  26250. * Define the types of all the draw buffers we want to create
  26251. */
  26252. types?: number[];
  26253. /**
  26254. * Define the sampling modes of all the draw buffers we want to create
  26255. */
  26256. samplingModes?: number[];
  26257. /**
  26258. * Define if a depth buffer is required
  26259. */
  26260. generateDepthBuffer?: boolean;
  26261. /**
  26262. * Define if a stencil buffer is required
  26263. */
  26264. generateStencilBuffer?: boolean;
  26265. /**
  26266. * Define if a depth texture is required instead of a depth buffer
  26267. */
  26268. generateDepthTexture?: boolean;
  26269. /**
  26270. * Define the number of desired draw buffers
  26271. */
  26272. textureCount?: number;
  26273. /**
  26274. * Define if aspect ratio should be adapted to the texture or stay the scene one
  26275. */
  26276. doNotChangeAspectRatio?: boolean;
  26277. /**
  26278. * Define the default type of the buffers we are creating
  26279. */
  26280. defaultType?: number;
  26281. }
  26282. /**
  26283. * A multi render target, like a render target provides the ability to render to a texture.
  26284. * Unlike the render target, it can render to several draw buffers in one draw.
  26285. * This is specially interesting in deferred rendering or for any effects requiring more than
  26286. * just one color from a single pass.
  26287. */
  26288. export class MultiRenderTarget extends RenderTargetTexture {
  26289. private _internalTextures;
  26290. private _textures;
  26291. private _multiRenderTargetOptions;
  26292. /**
  26293. * Get if draw buffers are currently supported by the used hardware and browser.
  26294. */
  26295. readonly isSupported: boolean;
  26296. /**
  26297. * Get the list of textures generated by the multi render target.
  26298. */
  26299. readonly textures: Texture[];
  26300. /**
  26301. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  26302. */
  26303. readonly depthTexture: Texture;
  26304. /**
  26305. * Set the wrapping mode on U of all the textures we are rendering to.
  26306. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  26307. */
  26308. wrapU: number;
  26309. /**
  26310. * Set the wrapping mode on V of all the textures we are rendering to.
  26311. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  26312. */
  26313. wrapV: number;
  26314. /**
  26315. * Instantiate a new multi render target texture.
  26316. * A multi render target, like a render target provides the ability to render to a texture.
  26317. * Unlike the render target, it can render to several draw buffers in one draw.
  26318. * This is specially interesting in deferred rendering or for any effects requiring more than
  26319. * just one color from a single pass.
  26320. * @param name Define the name of the texture
  26321. * @param size Define the size of the buffers to render to
  26322. * @param count Define the number of target we are rendering into
  26323. * @param scene Define the scene the texture belongs to
  26324. * @param options Define the options used to create the multi render target
  26325. */
  26326. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  26327. /** @hidden */
  26328. _rebuild(): void;
  26329. private _createInternalTextures;
  26330. private _createTextures;
  26331. /**
  26332. * Define the number of samples used if MSAA is enabled.
  26333. */
  26334. samples: number;
  26335. /**
  26336. * Resize all the textures in the multi render target.
  26337. * Be carrefull as it will recreate all the data in the new texture.
  26338. * @param size Define the new size
  26339. */
  26340. resize(size: any): void;
  26341. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  26342. /**
  26343. * Dispose the render targets and their associated resources
  26344. */
  26345. dispose(): void;
  26346. /**
  26347. * Release all the underlying texture used as draw buffers.
  26348. */
  26349. releaseInternalTextures(): void;
  26350. }
  26351. }
  26352. declare module "babylonjs/Audio/analyser" {
  26353. import { Scene } from "babylonjs/scene";
  26354. /**
  26355. * Class used to work with sound analyzer using fast fourier transform (FFT)
  26356. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26357. */
  26358. export class Analyser {
  26359. /**
  26360. * Gets or sets the smoothing
  26361. * @ignorenaming
  26362. */
  26363. SMOOTHING: number;
  26364. /**
  26365. * Gets or sets the FFT table size
  26366. * @ignorenaming
  26367. */
  26368. FFT_SIZE: number;
  26369. /**
  26370. * Gets or sets the bar graph amplitude
  26371. * @ignorenaming
  26372. */
  26373. BARGRAPHAMPLITUDE: number;
  26374. /**
  26375. * Gets or sets the position of the debug canvas
  26376. * @ignorenaming
  26377. */
  26378. DEBUGCANVASPOS: {
  26379. x: number;
  26380. y: number;
  26381. };
  26382. /**
  26383. * Gets or sets the debug canvas size
  26384. * @ignorenaming
  26385. */
  26386. DEBUGCANVASSIZE: {
  26387. width: number;
  26388. height: number;
  26389. };
  26390. private _byteFreqs;
  26391. private _byteTime;
  26392. private _floatFreqs;
  26393. private _webAudioAnalyser;
  26394. private _debugCanvas;
  26395. private _debugCanvasContext;
  26396. private _scene;
  26397. private _registerFunc;
  26398. private _audioEngine;
  26399. /**
  26400. * Creates a new analyser
  26401. * @param scene defines hosting scene
  26402. */
  26403. constructor(scene: Scene);
  26404. /**
  26405. * Get the number of data values you will have to play with for the visualization
  26406. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  26407. * @returns a number
  26408. */
  26409. getFrequencyBinCount(): number;
  26410. /**
  26411. * Gets the current frequency data as a byte array
  26412. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  26413. * @returns a Uint8Array
  26414. */
  26415. getByteFrequencyData(): Uint8Array;
  26416. /**
  26417. * Gets the current waveform as a byte array
  26418. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  26419. * @returns a Uint8Array
  26420. */
  26421. getByteTimeDomainData(): Uint8Array;
  26422. /**
  26423. * Gets the current frequency data as a float array
  26424. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  26425. * @returns a Float32Array
  26426. */
  26427. getFloatFrequencyData(): Float32Array;
  26428. /**
  26429. * Renders the debug canvas
  26430. */
  26431. drawDebugCanvas(): void;
  26432. /**
  26433. * Stops rendering the debug canvas and removes it
  26434. */
  26435. stopDebugCanvas(): void;
  26436. /**
  26437. * Connects two audio nodes
  26438. * @param inputAudioNode defines first node to connect
  26439. * @param outputAudioNode defines second node to connect
  26440. */
  26441. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  26442. /**
  26443. * Releases all associated resources
  26444. */
  26445. dispose(): void;
  26446. }
  26447. }
  26448. declare module "babylonjs/Audio/audioEngine" {
  26449. import { IDisposable } from "babylonjs/scene";
  26450. import { Analyser } from "babylonjs/Audio/analyser";
  26451. import { Nullable } from "babylonjs/types";
  26452. import { Observable } from "babylonjs/Misc/observable";
  26453. /**
  26454. * This represents an audio engine and it is responsible
  26455. * to play, synchronize and analyse sounds throughout the application.
  26456. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26457. */
  26458. export interface IAudioEngine extends IDisposable {
  26459. /**
  26460. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  26461. */
  26462. readonly canUseWebAudio: boolean;
  26463. /**
  26464. * Gets the current AudioContext if available.
  26465. */
  26466. readonly audioContext: Nullable<AudioContext>;
  26467. /**
  26468. * The master gain node defines the global audio volume of your audio engine.
  26469. */
  26470. readonly masterGain: GainNode;
  26471. /**
  26472. * Gets whether or not mp3 are supported by your browser.
  26473. */
  26474. readonly isMP3supported: boolean;
  26475. /**
  26476. * Gets whether or not ogg are supported by your browser.
  26477. */
  26478. readonly isOGGsupported: boolean;
  26479. /**
  26480. * Defines if Babylon should emit a warning if WebAudio is not supported.
  26481. * @ignoreNaming
  26482. */
  26483. WarnedWebAudioUnsupported: boolean;
  26484. /**
  26485. * Defines if the audio engine relies on a custom unlocked button.
  26486. * In this case, the embedded button will not be displayed.
  26487. */
  26488. useCustomUnlockedButton: boolean;
  26489. /**
  26490. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  26491. */
  26492. readonly unlocked: boolean;
  26493. /**
  26494. * Event raised when audio has been unlocked on the browser.
  26495. */
  26496. onAudioUnlockedObservable: Observable<AudioEngine>;
  26497. /**
  26498. * Event raised when audio has been locked on the browser.
  26499. */
  26500. onAudioLockedObservable: Observable<AudioEngine>;
  26501. /**
  26502. * Flags the audio engine in Locked state.
  26503. * This happens due to new browser policies preventing audio to autoplay.
  26504. */
  26505. lock(): void;
  26506. /**
  26507. * Unlocks the audio engine once a user action has been done on the dom.
  26508. * This is helpful to resume play once browser policies have been satisfied.
  26509. */
  26510. unlock(): void;
  26511. }
  26512. /**
  26513. * This represents the default audio engine used in babylon.
  26514. * It is responsible to play, synchronize and analyse sounds throughout the application.
  26515. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26516. */
  26517. export class AudioEngine implements IAudioEngine {
  26518. private _audioContext;
  26519. private _audioContextInitialized;
  26520. private _muteButton;
  26521. private _hostElement;
  26522. /**
  26523. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  26524. */
  26525. canUseWebAudio: boolean;
  26526. /**
  26527. * The master gain node defines the global audio volume of your audio engine.
  26528. */
  26529. masterGain: GainNode;
  26530. /**
  26531. * Defines if Babylon should emit a warning if WebAudio is not supported.
  26532. * @ignoreNaming
  26533. */
  26534. WarnedWebAudioUnsupported: boolean;
  26535. /**
  26536. * Gets whether or not mp3 are supported by your browser.
  26537. */
  26538. isMP3supported: boolean;
  26539. /**
  26540. * Gets whether or not ogg are supported by your browser.
  26541. */
  26542. isOGGsupported: boolean;
  26543. /**
  26544. * Gets whether audio has been unlocked on the device.
  26545. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  26546. * a user interaction has happened.
  26547. */
  26548. unlocked: boolean;
  26549. /**
  26550. * Defines if the audio engine relies on a custom unlocked button.
  26551. * In this case, the embedded button will not be displayed.
  26552. */
  26553. useCustomUnlockedButton: boolean;
  26554. /**
  26555. * Event raised when audio has been unlocked on the browser.
  26556. */
  26557. onAudioUnlockedObservable: Observable<AudioEngine>;
  26558. /**
  26559. * Event raised when audio has been locked on the browser.
  26560. */
  26561. onAudioLockedObservable: Observable<AudioEngine>;
  26562. /**
  26563. * Gets the current AudioContext if available.
  26564. */
  26565. readonly audioContext: Nullable<AudioContext>;
  26566. private _connectedAnalyser;
  26567. /**
  26568. * Instantiates a new audio engine.
  26569. *
  26570. * There should be only one per page as some browsers restrict the number
  26571. * of audio contexts you can create.
  26572. * @param hostElement defines the host element where to display the mute icon if necessary
  26573. */
  26574. constructor(hostElement?: Nullable<HTMLElement>);
  26575. /**
  26576. * Flags the audio engine in Locked state.
  26577. * This happens due to new browser policies preventing audio to autoplay.
  26578. */
  26579. lock(): void;
  26580. /**
  26581. * Unlocks the audio engine once a user action has been done on the dom.
  26582. * This is helpful to resume play once browser policies have been satisfied.
  26583. */
  26584. unlock(): void;
  26585. private _resumeAudioContext;
  26586. private _initializeAudioContext;
  26587. private _tryToRun;
  26588. private _triggerRunningState;
  26589. private _triggerSuspendedState;
  26590. private _displayMuteButton;
  26591. private _moveButtonToTopLeft;
  26592. private _onResize;
  26593. private _hideMuteButton;
  26594. /**
  26595. * Destroy and release the resources associated with the audio ccontext.
  26596. */
  26597. dispose(): void;
  26598. /**
  26599. * Gets the global volume sets on the master gain.
  26600. * @returns the global volume if set or -1 otherwise
  26601. */
  26602. getGlobalVolume(): number;
  26603. /**
  26604. * Sets the global volume of your experience (sets on the master gain).
  26605. * @param newVolume Defines the new global volume of the application
  26606. */
  26607. setGlobalVolume(newVolume: number): void;
  26608. /**
  26609. * Connect the audio engine to an audio analyser allowing some amazing
  26610. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  26611. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  26612. * @param analyser The analyser to connect to the engine
  26613. */
  26614. connectToAnalyser(analyser: Analyser): void;
  26615. }
  26616. }
  26617. declare module "babylonjs/Loading/loadingScreen" {
  26618. /**
  26619. * Interface used to present a loading screen while loading a scene
  26620. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  26621. */
  26622. export interface ILoadingScreen {
  26623. /**
  26624. * Function called to display the loading screen
  26625. */
  26626. displayLoadingUI: () => void;
  26627. /**
  26628. * Function called to hide the loading screen
  26629. */
  26630. hideLoadingUI: () => void;
  26631. /**
  26632. * Gets or sets the color to use for the background
  26633. */
  26634. loadingUIBackgroundColor: string;
  26635. /**
  26636. * Gets or sets the text to display while loading
  26637. */
  26638. loadingUIText: string;
  26639. }
  26640. /**
  26641. * Class used for the default loading screen
  26642. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  26643. */
  26644. export class DefaultLoadingScreen implements ILoadingScreen {
  26645. private _renderingCanvas;
  26646. private _loadingText;
  26647. private _loadingDivBackgroundColor;
  26648. private _loadingDiv;
  26649. private _loadingTextDiv;
  26650. /**
  26651. * Creates a new default loading screen
  26652. * @param _renderingCanvas defines the canvas used to render the scene
  26653. * @param _loadingText defines the default text to display
  26654. * @param _loadingDivBackgroundColor defines the default background color
  26655. */
  26656. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  26657. /**
  26658. * Function called to display the loading screen
  26659. */
  26660. displayLoadingUI(): void;
  26661. /**
  26662. * Function called to hide the loading screen
  26663. */
  26664. hideLoadingUI(): void;
  26665. /**
  26666. * Gets or sets the text to display while loading
  26667. */
  26668. loadingUIText: string;
  26669. /**
  26670. * Gets or sets the color to use for the background
  26671. */
  26672. loadingUIBackgroundColor: string;
  26673. private _resizeLoadingUI;
  26674. }
  26675. }
  26676. declare module "babylonjs/Materials/Textures/videoTexture" {
  26677. import { Observable } from "babylonjs/Misc/observable";
  26678. import { Nullable } from "babylonjs/types";
  26679. import { Scene } from "babylonjs/scene";
  26680. import { Texture } from "babylonjs/Materials/Textures/texture";
  26681. /**
  26682. * Settings for finer control over video usage
  26683. */
  26684. export interface VideoTextureSettings {
  26685. /**
  26686. * Applies `autoplay` to video, if specified
  26687. */
  26688. autoPlay?: boolean;
  26689. /**
  26690. * Applies `loop` to video, if specified
  26691. */
  26692. loop?: boolean;
  26693. /**
  26694. * Automatically updates internal texture from video at every frame in the render loop
  26695. */
  26696. autoUpdateTexture: boolean;
  26697. /**
  26698. * Image src displayed during the video loading or until the user interacts with the video.
  26699. */
  26700. poster?: string;
  26701. }
  26702. /**
  26703. * If you want to display a video in your scene, this is the special texture for that.
  26704. * This special texture works similar to other textures, with the exception of a few parameters.
  26705. * @see https://doc.babylonjs.com/how_to/video_texture
  26706. */
  26707. export class VideoTexture extends Texture {
  26708. /**
  26709. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  26710. */
  26711. readonly autoUpdateTexture: boolean;
  26712. /**
  26713. * The video instance used by the texture internally
  26714. */
  26715. readonly video: HTMLVideoElement;
  26716. private _onUserActionRequestedObservable;
  26717. /**
  26718. * Event triggerd when a dom action is required by the user to play the video.
  26719. * This happens due to recent changes in browser policies preventing video to auto start.
  26720. */
  26721. readonly onUserActionRequestedObservable: Observable<Texture>;
  26722. private _generateMipMaps;
  26723. private _engine;
  26724. private _stillImageCaptured;
  26725. private _displayingPosterTexture;
  26726. private _settings;
  26727. private _createInternalTextureOnEvent;
  26728. /**
  26729. * Creates a video texture.
  26730. * If you want to display a video in your scene, this is the special texture for that.
  26731. * This special texture works similar to other textures, with the exception of a few parameters.
  26732. * @see https://doc.babylonjs.com/how_to/video_texture
  26733. * @param name optional name, will detect from video source, if not defined
  26734. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  26735. * @param scene is obviously the current scene.
  26736. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  26737. * @param invertY is false by default but can be used to invert video on Y axis
  26738. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  26739. * @param settings allows finer control over video usage
  26740. */
  26741. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  26742. private _getName;
  26743. private _getVideo;
  26744. private _createInternalTexture;
  26745. private reset;
  26746. /**
  26747. * @hidden Internal method to initiate `update`.
  26748. */
  26749. _rebuild(): void;
  26750. /**
  26751. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  26752. */
  26753. update(): void;
  26754. /**
  26755. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  26756. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  26757. */
  26758. updateTexture(isVisible: boolean): void;
  26759. protected _updateInternalTexture: () => void;
  26760. /**
  26761. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  26762. * @param url New url.
  26763. */
  26764. updateURL(url: string): void;
  26765. /**
  26766. * Dispose the texture and release its associated resources.
  26767. */
  26768. dispose(): void;
  26769. /**
  26770. * Creates a video texture straight from a stream.
  26771. * @param scene Define the scene the texture should be created in
  26772. * @param stream Define the stream the texture should be created from
  26773. * @returns The created video texture as a promise
  26774. */
  26775. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  26776. /**
  26777. * Creates a video texture straight from your WebCam video feed.
  26778. * @param scene Define the scene the texture should be created in
  26779. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  26780. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  26781. * @returns The created video texture as a promise
  26782. */
  26783. static CreateFromWebCamAsync(scene: Scene, constraints: {
  26784. minWidth: number;
  26785. maxWidth: number;
  26786. minHeight: number;
  26787. maxHeight: number;
  26788. deviceId: string;
  26789. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  26790. /**
  26791. * Creates a video texture straight from your WebCam video feed.
  26792. * @param scene Define the scene the texture should be created in
  26793. * @param onReady Define a callback to triggered once the texture will be ready
  26794. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  26795. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  26796. */
  26797. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  26798. minWidth: number;
  26799. maxWidth: number;
  26800. minHeight: number;
  26801. maxHeight: number;
  26802. deviceId: string;
  26803. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  26804. }
  26805. }
  26806. declare module "babylonjs/Engines/engine" {
  26807. import { Observable } from "babylonjs/Misc/observable";
  26808. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  26809. import { ICustomAnimationFrameRequester, PerfCounter, IFileRequest } from "babylonjs/Misc/tools";
  26810. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  26811. import { Camera } from "babylonjs/Cameras/camera";
  26812. import { Scene } from "babylonjs/scene";
  26813. import { Matrix, Color3, Color4, Viewport } from "babylonjs/Maths/math";
  26814. import { IDisplayChangedEventArgs } from "babylonjs/Engines/engine";
  26815. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  26816. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  26817. import { Effect, EffectCreationOptions, EffectFallbacks } from "babylonjs/Materials/effect";
  26818. import { Material } from "babylonjs/Materials/material";
  26819. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  26820. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  26821. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  26822. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  26823. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  26824. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  26825. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  26826. import { _DepthCullingState, _StencilState, _AlphaState } from "babylonjs/States/index";
  26827. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  26828. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  26829. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  26830. /**
  26831. * Interface for attribute information associated with buffer instanciation
  26832. */
  26833. export class InstancingAttributeInfo {
  26834. /**
  26835. * Index/offset of the attribute in the vertex shader
  26836. */
  26837. index: number;
  26838. /**
  26839. * size of the attribute, 1, 2, 3 or 4
  26840. */
  26841. attributeSize: number;
  26842. /**
  26843. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  26844. * default is FLOAT
  26845. */
  26846. attribyteType: number;
  26847. /**
  26848. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  26849. */
  26850. normalized: boolean;
  26851. /**
  26852. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  26853. */
  26854. offset: number;
  26855. /**
  26856. * Name of the GLSL attribute, for debugging purpose only
  26857. */
  26858. attributeName: string;
  26859. }
  26860. /**
  26861. * Define options used to create a depth texture
  26862. */
  26863. export class DepthTextureCreationOptions {
  26864. /** Specifies whether or not a stencil should be allocated in the texture */
  26865. generateStencil?: boolean;
  26866. /** Specifies whether or not bilinear filtering is enable on the texture */
  26867. bilinearFiltering?: boolean;
  26868. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  26869. comparisonFunction?: number;
  26870. /** Specifies if the created texture is a cube texture */
  26871. isCube?: boolean;
  26872. }
  26873. /**
  26874. * Class used to describe the capabilities of the engine relatively to the current browser
  26875. */
  26876. export class EngineCapabilities {
  26877. /** Maximum textures units per fragment shader */
  26878. maxTexturesImageUnits: number;
  26879. /** Maximum texture units per vertex shader */
  26880. maxVertexTextureImageUnits: number;
  26881. /** Maximum textures units in the entire pipeline */
  26882. maxCombinedTexturesImageUnits: number;
  26883. /** Maximum texture size */
  26884. maxTextureSize: number;
  26885. /** Maximum cube texture size */
  26886. maxCubemapTextureSize: number;
  26887. /** Maximum render texture size */
  26888. maxRenderTextureSize: number;
  26889. /** Maximum number of vertex attributes */
  26890. maxVertexAttribs: number;
  26891. /** Maximum number of varyings */
  26892. maxVaryingVectors: number;
  26893. /** Maximum number of uniforms per vertex shader */
  26894. maxVertexUniformVectors: number;
  26895. /** Maximum number of uniforms per fragment shader */
  26896. maxFragmentUniformVectors: number;
  26897. /** Defines if standard derivates (dx/dy) are supported */
  26898. standardDerivatives: boolean;
  26899. /** Defines if s3tc texture compression is supported */
  26900. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  26901. /** Defines if pvrtc texture compression is supported */
  26902. pvrtc: any;
  26903. /** Defines if etc1 texture compression is supported */
  26904. etc1: any;
  26905. /** Defines if etc2 texture compression is supported */
  26906. etc2: any;
  26907. /** Defines if astc texture compression is supported */
  26908. astc: any;
  26909. /** Defines if float textures are supported */
  26910. textureFloat: boolean;
  26911. /** Defines if vertex array objects are supported */
  26912. vertexArrayObject: boolean;
  26913. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  26914. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  26915. /** Gets the maximum level of anisotropy supported */
  26916. maxAnisotropy: number;
  26917. /** Defines if instancing is supported */
  26918. instancedArrays: boolean;
  26919. /** Defines if 32 bits indices are supported */
  26920. uintIndices: boolean;
  26921. /** Defines if high precision shaders are supported */
  26922. highPrecisionShaderSupported: boolean;
  26923. /** Defines if depth reading in the fragment shader is supported */
  26924. fragmentDepthSupported: boolean;
  26925. /** Defines if float texture linear filtering is supported*/
  26926. textureFloatLinearFiltering: boolean;
  26927. /** Defines if rendering to float textures is supported */
  26928. textureFloatRender: boolean;
  26929. /** Defines if half float textures are supported*/
  26930. textureHalfFloat: boolean;
  26931. /** Defines if half float texture linear filtering is supported*/
  26932. textureHalfFloatLinearFiltering: boolean;
  26933. /** Defines if rendering to half float textures is supported */
  26934. textureHalfFloatRender: boolean;
  26935. /** Defines if textureLOD shader command is supported */
  26936. textureLOD: boolean;
  26937. /** Defines if draw buffers extension is supported */
  26938. drawBuffersExtension: boolean;
  26939. /** Defines if depth textures are supported */
  26940. depthTextureExtension: boolean;
  26941. /** Defines if float color buffer are supported */
  26942. colorBufferFloat: boolean;
  26943. /** Gets disjoint timer query extension (null if not supported) */
  26944. timerQuery: EXT_disjoint_timer_query;
  26945. /** Defines if timestamp can be used with timer query */
  26946. canUseTimestampForTimerQuery: boolean;
  26947. /** Function used to let the system compiles shaders in background */
  26948. parallelShaderCompile: {
  26949. MAX_SHADER_COMPILER_THREADS_KHR: number;
  26950. maxShaderCompilerThreadsKHR: (thread: number) => void;
  26951. COMPLETION_STATUS_KHR: number;
  26952. };
  26953. }
  26954. /** Interface defining initialization parameters for Engine class */
  26955. export interface EngineOptions extends WebGLContextAttributes {
  26956. /**
  26957. * Defines if the engine should no exceed a specified device ratio
  26958. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  26959. */
  26960. limitDeviceRatio?: number;
  26961. /**
  26962. * Defines if webvr should be enabled automatically
  26963. * @see http://doc.babylonjs.com/how_to/webvr_camera
  26964. */
  26965. autoEnableWebVR?: boolean;
  26966. /**
  26967. * Defines if webgl2 should be turned off even if supported
  26968. * @see http://doc.babylonjs.com/features/webgl2
  26969. */
  26970. disableWebGL2Support?: boolean;
  26971. /**
  26972. * Defines if webaudio should be initialized as well
  26973. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26974. */
  26975. audioEngine?: boolean;
  26976. /**
  26977. * Defines if animations should run using a deterministic lock step
  26978. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  26979. */
  26980. deterministicLockstep?: boolean;
  26981. /** Defines the maximum steps to use with deterministic lock step mode */
  26982. lockstepMaxSteps?: number;
  26983. /**
  26984. * Defines that engine should ignore context lost events
  26985. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  26986. */
  26987. doNotHandleContextLost?: boolean;
  26988. /**
  26989. * Defines that engine should ignore modifying touch action attribute and style
  26990. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  26991. */
  26992. doNotHandleTouchAction?: boolean;
  26993. }
  26994. /**
  26995. * Defines the interface used by display changed events
  26996. */
  26997. export interface IDisplayChangedEventArgs {
  26998. /** Gets the vrDisplay object (if any) */
  26999. vrDisplay: Nullable<any>;
  27000. /** Gets a boolean indicating if webVR is supported */
  27001. vrSupported: boolean;
  27002. }
  27003. /**
  27004. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  27005. */
  27006. export class Engine {
  27007. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  27008. static ExceptionList: ({
  27009. key: string;
  27010. capture: string;
  27011. captureConstraint: number;
  27012. targets: string[];
  27013. } | {
  27014. key: string;
  27015. capture: null;
  27016. captureConstraint: null;
  27017. targets: string[];
  27018. })[];
  27019. /** Gets the list of created engines */
  27020. static readonly Instances: Engine[];
  27021. /**
  27022. * Gets the latest created engine
  27023. */
  27024. static readonly LastCreatedEngine: Nullable<Engine>;
  27025. /**
  27026. * Gets the latest created scene
  27027. */
  27028. static readonly LastCreatedScene: Nullable<Scene>;
  27029. /**
  27030. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  27031. * @param flag defines which part of the materials must be marked as dirty
  27032. * @param predicate defines a predicate used to filter which materials should be affected
  27033. */
  27034. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  27035. /**
  27036. * Hidden
  27037. */
  27038. static _TextureLoaders: IInternalTextureLoader[];
  27039. /** Defines that alpha blending is disabled */
  27040. static readonly ALPHA_DISABLE: number;
  27041. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  27042. static readonly ALPHA_ADD: number;
  27043. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  27044. static readonly ALPHA_COMBINE: number;
  27045. /** Defines that alpha blending to DEST - SRC * DEST */
  27046. static readonly ALPHA_SUBTRACT: number;
  27047. /** Defines that alpha blending to SRC * DEST */
  27048. static readonly ALPHA_MULTIPLY: number;
  27049. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  27050. static readonly ALPHA_MAXIMIZED: number;
  27051. /** Defines that alpha blending to SRC + DEST */
  27052. static readonly ALPHA_ONEONE: number;
  27053. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  27054. static readonly ALPHA_PREMULTIPLIED: number;
  27055. /**
  27056. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  27057. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  27058. */
  27059. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  27060. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  27061. static readonly ALPHA_INTERPOLATE: number;
  27062. /**
  27063. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  27064. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  27065. */
  27066. static readonly ALPHA_SCREENMODE: number;
  27067. /** Defines that the ressource is not delayed*/
  27068. static readonly DELAYLOADSTATE_NONE: number;
  27069. /** Defines that the ressource was successfully delay loaded */
  27070. static readonly DELAYLOADSTATE_LOADED: number;
  27071. /** Defines that the ressource is currently delay loading */
  27072. static readonly DELAYLOADSTATE_LOADING: number;
  27073. /** Defines that the ressource is delayed and has not started loading */
  27074. static readonly DELAYLOADSTATE_NOTLOADED: number;
  27075. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  27076. static readonly NEVER: number;
  27077. /** 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 */
  27078. static readonly ALWAYS: number;
  27079. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  27080. static readonly LESS: number;
  27081. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  27082. static readonly EQUAL: number;
  27083. /** 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 */
  27084. static readonly LEQUAL: number;
  27085. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  27086. static readonly GREATER: number;
  27087. /** 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 */
  27088. static readonly GEQUAL: number;
  27089. /** 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 */
  27090. static readonly NOTEQUAL: number;
  27091. /** Passed to stencilOperation to specify that stencil value must be kept */
  27092. static readonly KEEP: number;
  27093. /** Passed to stencilOperation to specify that stencil value must be replaced */
  27094. static readonly REPLACE: number;
  27095. /** Passed to stencilOperation to specify that stencil value must be incremented */
  27096. static readonly INCR: number;
  27097. /** Passed to stencilOperation to specify that stencil value must be decremented */
  27098. static readonly DECR: number;
  27099. /** Passed to stencilOperation to specify that stencil value must be inverted */
  27100. static readonly INVERT: number;
  27101. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  27102. static readonly INCR_WRAP: number;
  27103. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  27104. static readonly DECR_WRAP: number;
  27105. /** Texture is not repeating outside of 0..1 UVs */
  27106. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  27107. /** Texture is repeating outside of 0..1 UVs */
  27108. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  27109. /** Texture is repeating and mirrored */
  27110. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  27111. /** ALPHA */
  27112. static readonly TEXTUREFORMAT_ALPHA: number;
  27113. /** LUMINANCE */
  27114. static readonly TEXTUREFORMAT_LUMINANCE: number;
  27115. /** LUMINANCE_ALPHA */
  27116. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  27117. /** RGB */
  27118. static readonly TEXTUREFORMAT_RGB: number;
  27119. /** RGBA */
  27120. static readonly TEXTUREFORMAT_RGBA: number;
  27121. /** RED */
  27122. static readonly TEXTUREFORMAT_RED: number;
  27123. /** RED (2nd reference) */
  27124. static readonly TEXTUREFORMAT_R: number;
  27125. /** RG */
  27126. static readonly TEXTUREFORMAT_RG: number;
  27127. /** RED_INTEGER */
  27128. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  27129. /** RED_INTEGER (2nd reference) */
  27130. static readonly TEXTUREFORMAT_R_INTEGER: number;
  27131. /** RG_INTEGER */
  27132. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  27133. /** RGB_INTEGER */
  27134. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  27135. /** RGBA_INTEGER */
  27136. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  27137. /** UNSIGNED_BYTE */
  27138. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  27139. /** UNSIGNED_BYTE (2nd reference) */
  27140. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  27141. /** FLOAT */
  27142. static readonly TEXTURETYPE_FLOAT: number;
  27143. /** HALF_FLOAT */
  27144. static readonly TEXTURETYPE_HALF_FLOAT: number;
  27145. /** BYTE */
  27146. static readonly TEXTURETYPE_BYTE: number;
  27147. /** SHORT */
  27148. static readonly TEXTURETYPE_SHORT: number;
  27149. /** UNSIGNED_SHORT */
  27150. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  27151. /** INT */
  27152. static readonly TEXTURETYPE_INT: number;
  27153. /** UNSIGNED_INT */
  27154. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  27155. /** UNSIGNED_SHORT_4_4_4_4 */
  27156. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  27157. /** UNSIGNED_SHORT_5_5_5_1 */
  27158. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  27159. /** UNSIGNED_SHORT_5_6_5 */
  27160. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  27161. /** UNSIGNED_INT_2_10_10_10_REV */
  27162. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  27163. /** UNSIGNED_INT_24_8 */
  27164. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  27165. /** UNSIGNED_INT_10F_11F_11F_REV */
  27166. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  27167. /** UNSIGNED_INT_5_9_9_9_REV */
  27168. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  27169. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  27170. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  27171. /** nearest is mag = nearest and min = nearest and mip = linear */
  27172. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  27173. /** Bilinear is mag = linear and min = linear and mip = nearest */
  27174. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  27175. /** Trilinear is mag = linear and min = linear and mip = linear */
  27176. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  27177. /** nearest is mag = nearest and min = nearest and mip = linear */
  27178. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  27179. /** Bilinear is mag = linear and min = linear and mip = nearest */
  27180. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  27181. /** Trilinear is mag = linear and min = linear and mip = linear */
  27182. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  27183. /** mag = nearest and min = nearest and mip = nearest */
  27184. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  27185. /** mag = nearest and min = linear and mip = nearest */
  27186. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  27187. /** mag = nearest and min = linear and mip = linear */
  27188. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  27189. /** mag = nearest and min = linear and mip = none */
  27190. static readonly TEXTURE_NEAREST_LINEAR: number;
  27191. /** mag = nearest and min = nearest and mip = none */
  27192. static readonly TEXTURE_NEAREST_NEAREST: number;
  27193. /** mag = linear and min = nearest and mip = nearest */
  27194. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  27195. /** mag = linear and min = nearest and mip = linear */
  27196. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  27197. /** mag = linear and min = linear and mip = none */
  27198. static readonly TEXTURE_LINEAR_LINEAR: number;
  27199. /** mag = linear and min = nearest and mip = none */
  27200. static readonly TEXTURE_LINEAR_NEAREST: number;
  27201. /** Explicit coordinates mode */
  27202. static readonly TEXTURE_EXPLICIT_MODE: number;
  27203. /** Spherical coordinates mode */
  27204. static readonly TEXTURE_SPHERICAL_MODE: number;
  27205. /** Planar coordinates mode */
  27206. static readonly TEXTURE_PLANAR_MODE: number;
  27207. /** Cubic coordinates mode */
  27208. static readonly TEXTURE_CUBIC_MODE: number;
  27209. /** Projection coordinates mode */
  27210. static readonly TEXTURE_PROJECTION_MODE: number;
  27211. /** Skybox coordinates mode */
  27212. static readonly TEXTURE_SKYBOX_MODE: number;
  27213. /** Inverse Cubic coordinates mode */
  27214. static readonly TEXTURE_INVCUBIC_MODE: number;
  27215. /** Equirectangular coordinates mode */
  27216. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  27217. /** Equirectangular Fixed coordinates mode */
  27218. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  27219. /** Equirectangular Fixed Mirrored coordinates mode */
  27220. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  27221. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  27222. static readonly SCALEMODE_FLOOR: number;
  27223. /** Defines that texture rescaling will look for the nearest power of 2 size */
  27224. static readonly SCALEMODE_NEAREST: number;
  27225. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  27226. static readonly SCALEMODE_CEILING: number;
  27227. /**
  27228. * Returns the current version of the framework
  27229. */
  27230. static readonly Version: string;
  27231. /**
  27232. * Returns a string describing the current engine
  27233. */
  27234. readonly description: string;
  27235. /**
  27236. * Gets or sets the epsilon value used by collision engine
  27237. */
  27238. static CollisionsEpsilon: number;
  27239. /**
  27240. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  27241. */
  27242. static ShadersRepository: string;
  27243. /**
  27244. * Method called to create the default loading screen.
  27245. * This can be overriden in your own app.
  27246. * @param canvas The rendering canvas element
  27247. * @returns The loading screen
  27248. */
  27249. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  27250. /**
  27251. * Method called to create the default rescale post process on each engine.
  27252. */
  27253. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  27254. /**
  27255. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  27256. */
  27257. forcePOTTextures: boolean;
  27258. /**
  27259. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  27260. */
  27261. isFullscreen: boolean;
  27262. /**
  27263. * Gets a boolean indicating if the pointer is currently locked
  27264. */
  27265. isPointerLock: boolean;
  27266. /**
  27267. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  27268. */
  27269. cullBackFaces: boolean;
  27270. /**
  27271. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  27272. */
  27273. renderEvenInBackground: boolean;
  27274. /**
  27275. * Gets or sets a boolean indicating that cache can be kept between frames
  27276. */
  27277. preventCacheWipeBetweenFrames: boolean;
  27278. /**
  27279. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  27280. **/
  27281. enableOfflineSupport: boolean;
  27282. /**
  27283. * 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)
  27284. **/
  27285. disableManifestCheck: boolean;
  27286. /**
  27287. * Gets the list of created scenes
  27288. */
  27289. scenes: Scene[];
  27290. /**
  27291. * Event raised when a new scene is created
  27292. */
  27293. onNewSceneAddedObservable: Observable<Scene>;
  27294. /**
  27295. * Gets the list of created postprocesses
  27296. */
  27297. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  27298. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  27299. validateShaderPrograms: boolean;
  27300. /**
  27301. * Observable event triggered each time the rendering canvas is resized
  27302. */
  27303. onResizeObservable: Observable<Engine>;
  27304. /**
  27305. * Observable event triggered each time the canvas loses focus
  27306. */
  27307. onCanvasBlurObservable: Observable<Engine>;
  27308. /**
  27309. * Observable event triggered each time the canvas gains focus
  27310. */
  27311. onCanvasFocusObservable: Observable<Engine>;
  27312. /**
  27313. * Observable event triggered each time the canvas receives pointerout event
  27314. */
  27315. onCanvasPointerOutObservable: Observable<PointerEvent>;
  27316. /**
  27317. * Observable event triggered before each texture is initialized
  27318. */
  27319. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  27320. private _vrDisplay;
  27321. private _vrSupported;
  27322. private _oldSize;
  27323. private _oldHardwareScaleFactor;
  27324. private _vrExclusivePointerMode;
  27325. private _webVRInitPromise;
  27326. /**
  27327. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  27328. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  27329. */
  27330. readonly isInVRExclusivePointerMode: boolean;
  27331. /**
  27332. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  27333. */
  27334. disableUniformBuffers: boolean;
  27335. /** @hidden */
  27336. _uniformBuffers: UniformBuffer[];
  27337. /**
  27338. * Gets a boolean indicating that the engine supports uniform buffers
  27339. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27340. */
  27341. readonly supportsUniformBuffers: boolean;
  27342. /**
  27343. * Observable raised when the engine begins a new frame
  27344. */
  27345. onBeginFrameObservable: Observable<Engine>;
  27346. /**
  27347. * If set, will be used to request the next animation frame for the render loop
  27348. */
  27349. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  27350. /**
  27351. * Observable raised when the engine ends the current frame
  27352. */
  27353. onEndFrameObservable: Observable<Engine>;
  27354. /**
  27355. * Observable raised when the engine is about to compile a shader
  27356. */
  27357. onBeforeShaderCompilationObservable: Observable<Engine>;
  27358. /**
  27359. * Observable raised when the engine has jsut compiled a shader
  27360. */
  27361. onAfterShaderCompilationObservable: Observable<Engine>;
  27362. /** @hidden */
  27363. _gl: WebGLRenderingContext;
  27364. private _renderingCanvas;
  27365. private _windowIsBackground;
  27366. private _webGLVersion;
  27367. /**
  27368. * Gets a boolean indicating that only power of 2 textures are supported
  27369. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  27370. */
  27371. readonly needPOTTextures: boolean;
  27372. /** @hidden */
  27373. _badOS: boolean;
  27374. /** @hidden */
  27375. _badDesktopOS: boolean;
  27376. /**
  27377. * Gets or sets a value indicating if we want to disable texture binding optimization.
  27378. * This could be required on some buggy drivers which wants to have textures bound in a progressive order.
  27379. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is
  27380. */
  27381. disableTextureBindingOptimization: boolean;
  27382. /**
  27383. * Gets the audio engine
  27384. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27385. * @ignorenaming
  27386. */
  27387. static audioEngine: IAudioEngine;
  27388. /**
  27389. * Default AudioEngine factory responsible of creating the Audio Engine.
  27390. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  27391. */
  27392. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  27393. /**
  27394. * Default offline support factory responsible of creating a tool used to store data locally.
  27395. * By default, this will create a Database object if the workload has been embedded.
  27396. */
  27397. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  27398. private _onFocus;
  27399. private _onBlur;
  27400. private _onCanvasPointerOut;
  27401. private _onCanvasBlur;
  27402. private _onCanvasFocus;
  27403. private _onFullscreenChange;
  27404. private _onPointerLockChange;
  27405. private _onVRDisplayPointerRestricted;
  27406. private _onVRDisplayPointerUnrestricted;
  27407. private _onVrDisplayConnect;
  27408. private _onVrDisplayDisconnect;
  27409. private _onVrDisplayPresentChange;
  27410. /**
  27411. * Observable signaled when VR display mode changes
  27412. */
  27413. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  27414. /**
  27415. * Observable signaled when VR request present is complete
  27416. */
  27417. onVRRequestPresentComplete: Observable<boolean>;
  27418. /**
  27419. * Observable signaled when VR request present starts
  27420. */
  27421. onVRRequestPresentStart: Observable<Engine>;
  27422. private _hardwareScalingLevel;
  27423. /** @hidden */
  27424. protected _caps: EngineCapabilities;
  27425. private _pointerLockRequested;
  27426. private _isStencilEnable;
  27427. private _colorWrite;
  27428. private _loadingScreen;
  27429. /** @hidden */
  27430. _drawCalls: PerfCounter;
  27431. /** @hidden */
  27432. _textureCollisions: PerfCounter;
  27433. private _glVersion;
  27434. private _glRenderer;
  27435. private _glVendor;
  27436. private _videoTextureSupported;
  27437. private _renderingQueueLaunched;
  27438. private _activeRenderLoops;
  27439. private _deterministicLockstep;
  27440. private _lockstepMaxSteps;
  27441. /**
  27442. * Observable signaled when a context lost event is raised
  27443. */
  27444. onContextLostObservable: Observable<Engine>;
  27445. /**
  27446. * Observable signaled when a context restored event is raised
  27447. */
  27448. onContextRestoredObservable: Observable<Engine>;
  27449. private _onContextLost;
  27450. private _onContextRestored;
  27451. private _contextWasLost;
  27452. private _doNotHandleContextLost;
  27453. /**
  27454. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  27455. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  27456. */
  27457. doNotHandleContextLost: boolean;
  27458. private _performanceMonitor;
  27459. private _fps;
  27460. private _deltaTime;
  27461. /**
  27462. * Turn this value on if you want to pause FPS computation when in background
  27463. */
  27464. disablePerformanceMonitorInBackground: boolean;
  27465. /**
  27466. * Gets the performance monitor attached to this engine
  27467. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  27468. */
  27469. readonly performanceMonitor: PerformanceMonitor;
  27470. /** @hidden */
  27471. protected _depthCullingState: _DepthCullingState;
  27472. /** @hidden */
  27473. protected _stencilState: _StencilState;
  27474. /** @hidden */
  27475. protected _alphaState: _AlphaState;
  27476. /** @hidden */
  27477. protected _alphaMode: number;
  27478. protected _internalTexturesCache: InternalTexture[];
  27479. /** @hidden */
  27480. protected _activeChannel: number;
  27481. private _currentTextureChannel;
  27482. /** @hidden */
  27483. protected _boundTexturesCache: {
  27484. [key: string]: Nullable<InternalTexture>;
  27485. };
  27486. /** @hidden */
  27487. protected _currentEffect: Nullable<Effect>;
  27488. /** @hidden */
  27489. protected _currentProgram: Nullable<WebGLProgram>;
  27490. private _compiledEffects;
  27491. private _vertexAttribArraysEnabled;
  27492. /** @hidden */
  27493. protected _cachedViewport: Nullable<Viewport>;
  27494. private _cachedVertexArrayObject;
  27495. /** @hidden */
  27496. protected _cachedVertexBuffers: any;
  27497. /** @hidden */
  27498. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  27499. /** @hidden */
  27500. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  27501. /** @hidden */
  27502. protected _currentRenderTarget: Nullable<InternalTexture>;
  27503. private _uintIndicesCurrentlySet;
  27504. private _currentBoundBuffer;
  27505. /** @hidden */
  27506. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  27507. private _currentBufferPointers;
  27508. private _currentInstanceLocations;
  27509. private _currentInstanceBuffers;
  27510. private _textureUnits;
  27511. private _firstBoundInternalTextureTracker;
  27512. private _lastBoundInternalTextureTracker;
  27513. private _workingCanvas;
  27514. private _workingContext;
  27515. private _rescalePostProcess;
  27516. private _dummyFramebuffer;
  27517. private _externalData;
  27518. private _bindedRenderFunction;
  27519. private _vaoRecordInProgress;
  27520. private _mustWipeVertexAttributes;
  27521. private _emptyTexture;
  27522. private _emptyCubeTexture;
  27523. private _emptyTexture3D;
  27524. /** @hidden */
  27525. _frameHandler: number;
  27526. private _nextFreeTextureSlots;
  27527. private _maxSimultaneousTextures;
  27528. private _activeRequests;
  27529. private _texturesSupported;
  27530. private _textureFormatInUse;
  27531. /**
  27532. * Gets the list of texture formats supported
  27533. */
  27534. readonly texturesSupported: Array<string>;
  27535. /**
  27536. * Gets the list of texture formats in use
  27537. */
  27538. readonly textureFormatInUse: Nullable<string>;
  27539. /**
  27540. * Gets the current viewport
  27541. */
  27542. readonly currentViewport: Nullable<Viewport>;
  27543. /**
  27544. * Gets the default empty texture
  27545. */
  27546. readonly emptyTexture: InternalTexture;
  27547. /**
  27548. * Gets the default empty 3D texture
  27549. */
  27550. readonly emptyTexture3D: InternalTexture;
  27551. /**
  27552. * Gets the default empty cube texture
  27553. */
  27554. readonly emptyCubeTexture: InternalTexture;
  27555. /**
  27556. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  27557. */
  27558. readonly premultipliedAlpha: boolean;
  27559. /**
  27560. * Creates a new engine
  27561. * @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
  27562. * @param antialias defines enable antialiasing (default: false)
  27563. * @param options defines further options to be sent to the getContext() function
  27564. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  27565. */
  27566. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  27567. private _disableTouchAction;
  27568. private _rebuildInternalTextures;
  27569. private _rebuildEffects;
  27570. /**
  27571. * Gets a boolean indicating if all created effects are ready
  27572. * @returns true if all effects are ready
  27573. */
  27574. areAllEffectsReady(): boolean;
  27575. private _rebuildBuffers;
  27576. private _initGLContext;
  27577. /**
  27578. * Gets version of the current webGL context
  27579. */
  27580. readonly webGLVersion: number;
  27581. /**
  27582. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  27583. */
  27584. readonly isStencilEnable: boolean;
  27585. private _prepareWorkingCanvas;
  27586. /**
  27587. * Reset the texture cache to empty state
  27588. */
  27589. resetTextureCache(): void;
  27590. /**
  27591. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  27592. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27593. * @returns true if engine is in deterministic lock step mode
  27594. */
  27595. isDeterministicLockStep(): boolean;
  27596. /**
  27597. * Gets the max steps when engine is running in deterministic lock step
  27598. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27599. * @returns the max steps
  27600. */
  27601. getLockstepMaxSteps(): number;
  27602. /**
  27603. * Gets an object containing information about the current webGL context
  27604. * @returns an object containing the vender, the renderer and the version of the current webGL context
  27605. */
  27606. getGlInfo(): {
  27607. vendor: string;
  27608. renderer: string;
  27609. version: string;
  27610. };
  27611. /**
  27612. * Gets current aspect ratio
  27613. * @param camera defines the camera to use to get the aspect ratio
  27614. * @param useScreen defines if screen size must be used (or the current render target if any)
  27615. * @returns a number defining the aspect ratio
  27616. */
  27617. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  27618. /**
  27619. * Gets current screen aspect ratio
  27620. * @returns a number defining the aspect ratio
  27621. */
  27622. getScreenAspectRatio(): number;
  27623. /**
  27624. * Gets the current render width
  27625. * @param useScreen defines if screen size must be used (or the current render target if any)
  27626. * @returns a number defining the current render width
  27627. */
  27628. getRenderWidth(useScreen?: boolean): number;
  27629. /**
  27630. * Gets the current render height
  27631. * @param useScreen defines if screen size must be used (or the current render target if any)
  27632. * @returns a number defining the current render height
  27633. */
  27634. getRenderHeight(useScreen?: boolean): number;
  27635. /**
  27636. * Gets the HTML canvas attached with the current webGL context
  27637. * @returns a HTML canvas
  27638. */
  27639. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  27640. /**
  27641. * Gets the client rect of the HTML canvas attached with the current webGL context
  27642. * @returns a client rectanglee
  27643. */
  27644. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  27645. /**
  27646. * Defines the hardware scaling level.
  27647. * By default the hardware scaling level is computed from the window device ratio.
  27648. * 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.
  27649. * @param level defines the level to use
  27650. */
  27651. setHardwareScalingLevel(level: number): void;
  27652. /**
  27653. * Gets the current hardware scaling level.
  27654. * By default the hardware scaling level is computed from the window device ratio.
  27655. * 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.
  27656. * @returns a number indicating the current hardware scaling level
  27657. */
  27658. getHardwareScalingLevel(): number;
  27659. /**
  27660. * Gets the list of loaded textures
  27661. * @returns an array containing all loaded textures
  27662. */
  27663. getLoadedTexturesCache(): InternalTexture[];
  27664. /**
  27665. * Gets the object containing all engine capabilities
  27666. * @returns the EngineCapabilities object
  27667. */
  27668. getCaps(): EngineCapabilities;
  27669. /**
  27670. * Gets the current depth function
  27671. * @returns a number defining the depth function
  27672. */
  27673. getDepthFunction(): Nullable<number>;
  27674. /**
  27675. * Sets the current depth function
  27676. * @param depthFunc defines the function to use
  27677. */
  27678. setDepthFunction(depthFunc: number): void;
  27679. /**
  27680. * Sets the current depth function to GREATER
  27681. */
  27682. setDepthFunctionToGreater(): void;
  27683. /**
  27684. * Sets the current depth function to GEQUAL
  27685. */
  27686. setDepthFunctionToGreaterOrEqual(): void;
  27687. /**
  27688. * Sets the current depth function to LESS
  27689. */
  27690. setDepthFunctionToLess(): void;
  27691. /**
  27692. * Sets the current depth function to LEQUAL
  27693. */
  27694. setDepthFunctionToLessOrEqual(): void;
  27695. /**
  27696. * Gets a boolean indicating if stencil buffer is enabled
  27697. * @returns the current stencil buffer state
  27698. */
  27699. getStencilBuffer(): boolean;
  27700. /**
  27701. * Enable or disable the stencil buffer
  27702. * @param enable defines if the stencil buffer must be enabled or disabled
  27703. */
  27704. setStencilBuffer(enable: boolean): void;
  27705. /**
  27706. * Gets the current stencil mask
  27707. * @returns a number defining the new stencil mask to use
  27708. */
  27709. getStencilMask(): number;
  27710. /**
  27711. * Sets the current stencil mask
  27712. * @param mask defines the new stencil mask to use
  27713. */
  27714. setStencilMask(mask: number): void;
  27715. /**
  27716. * Gets the current stencil function
  27717. * @returns a number defining the stencil function to use
  27718. */
  27719. getStencilFunction(): number;
  27720. /**
  27721. * Gets the current stencil reference value
  27722. * @returns a number defining the stencil reference value to use
  27723. */
  27724. getStencilFunctionReference(): number;
  27725. /**
  27726. * Gets the current stencil mask
  27727. * @returns a number defining the stencil mask to use
  27728. */
  27729. getStencilFunctionMask(): number;
  27730. /**
  27731. * Sets the current stencil function
  27732. * @param stencilFunc defines the new stencil function to use
  27733. */
  27734. setStencilFunction(stencilFunc: number): void;
  27735. /**
  27736. * Sets the current stencil reference
  27737. * @param reference defines the new stencil reference to use
  27738. */
  27739. setStencilFunctionReference(reference: number): void;
  27740. /**
  27741. * Sets the current stencil mask
  27742. * @param mask defines the new stencil mask to use
  27743. */
  27744. setStencilFunctionMask(mask: number): void;
  27745. /**
  27746. * Gets the current stencil operation when stencil fails
  27747. * @returns a number defining stencil operation to use when stencil fails
  27748. */
  27749. getStencilOperationFail(): number;
  27750. /**
  27751. * Gets the current stencil operation when depth fails
  27752. * @returns a number defining stencil operation to use when depth fails
  27753. */
  27754. getStencilOperationDepthFail(): number;
  27755. /**
  27756. * Gets the current stencil operation when stencil passes
  27757. * @returns a number defining stencil operation to use when stencil passes
  27758. */
  27759. getStencilOperationPass(): number;
  27760. /**
  27761. * Sets the stencil operation to use when stencil fails
  27762. * @param operation defines the stencil operation to use when stencil fails
  27763. */
  27764. setStencilOperationFail(operation: number): void;
  27765. /**
  27766. * Sets the stencil operation to use when depth fails
  27767. * @param operation defines the stencil operation to use when depth fails
  27768. */
  27769. setStencilOperationDepthFail(operation: number): void;
  27770. /**
  27771. * Sets the stencil operation to use when stencil passes
  27772. * @param operation defines the stencil operation to use when stencil passes
  27773. */
  27774. setStencilOperationPass(operation: number): void;
  27775. /**
  27776. * Sets a boolean indicating if the dithering state is enabled or disabled
  27777. * @param value defines the dithering state
  27778. */
  27779. setDitheringState(value: boolean): void;
  27780. /**
  27781. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  27782. * @param value defines the rasterizer state
  27783. */
  27784. setRasterizerState(value: boolean): void;
  27785. /**
  27786. * stop executing a render loop function and remove it from the execution array
  27787. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  27788. */
  27789. stopRenderLoop(renderFunction?: () => void): void;
  27790. /** @hidden */
  27791. _renderLoop(): void;
  27792. /**
  27793. * Register and execute a render loop. The engine can have more than one render function
  27794. * @param renderFunction defines the function to continuously execute
  27795. */
  27796. runRenderLoop(renderFunction: () => void): void;
  27797. /**
  27798. * Toggle full screen mode
  27799. * @param requestPointerLock defines if a pointer lock should be requested from the user
  27800. */
  27801. switchFullscreen(requestPointerLock: boolean): void;
  27802. /**
  27803. * Enters full screen mode
  27804. * @param requestPointerLock defines if a pointer lock should be requested from the user
  27805. */
  27806. enterFullscreen(requestPointerLock: boolean): void;
  27807. /**
  27808. * Exits full screen mode
  27809. */
  27810. exitFullscreen(): void;
  27811. /**
  27812. * Clear the current render buffer or the current render target (if any is set up)
  27813. * @param color defines the color to use
  27814. * @param backBuffer defines if the back buffer must be cleared
  27815. * @param depth defines if the depth buffer must be cleared
  27816. * @param stencil defines if the stencil buffer must be cleared
  27817. */
  27818. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  27819. /**
  27820. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  27821. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  27822. * @param y defines the y-coordinate of the corner of the clear rectangle
  27823. * @param width defines the width of the clear rectangle
  27824. * @param height defines the height of the clear rectangle
  27825. * @param clearColor defines the clear color
  27826. */
  27827. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  27828. /**
  27829. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  27830. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  27831. * @param y defines the y-coordinate of the corner of the clear rectangle
  27832. * @param width defines the width of the clear rectangle
  27833. * @param height defines the height of the clear rectangle
  27834. */
  27835. enableScissor(x: number, y: number, width: number, height: number): void;
  27836. /**
  27837. * Disable previously set scissor test rectangle
  27838. */
  27839. disableScissor(): void;
  27840. private _viewportCached;
  27841. /** @hidden */
  27842. _viewport(x: number, y: number, width: number, height: number): void;
  27843. /**
  27844. * Set the WebGL's viewport
  27845. * @param viewport defines the viewport element to be used
  27846. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  27847. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  27848. */
  27849. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  27850. /**
  27851. * Directly set the WebGL Viewport
  27852. * @param x defines the x coordinate of the viewport (in screen space)
  27853. * @param y defines the y coordinate of the viewport (in screen space)
  27854. * @param width defines the width of the viewport (in screen space)
  27855. * @param height defines the height of the viewport (in screen space)
  27856. * @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
  27857. */
  27858. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  27859. /**
  27860. * Begin a new frame
  27861. */
  27862. beginFrame(): void;
  27863. /**
  27864. * Enf the current frame
  27865. */
  27866. endFrame(): void;
  27867. /**
  27868. * Resize the view according to the canvas' size
  27869. */
  27870. resize(): void;
  27871. /**
  27872. * Force a specific size of the canvas
  27873. * @param width defines the new canvas' width
  27874. * @param height defines the new canvas' height
  27875. */
  27876. setSize(width: number, height: number): void;
  27877. /**
  27878. * Gets a boolean indicating if a webVR device was detected
  27879. * @returns true if a webVR device was detected
  27880. */
  27881. isVRDevicePresent(): boolean;
  27882. /**
  27883. * Gets the current webVR device
  27884. * @returns the current webVR device (or null)
  27885. */
  27886. getVRDevice(): any;
  27887. /**
  27888. * Initializes a webVR display and starts listening to display change events
  27889. * The onVRDisplayChangedObservable will be notified upon these changes
  27890. * @returns The onVRDisplayChangedObservable
  27891. */
  27892. initWebVR(): Observable<IDisplayChangedEventArgs>;
  27893. /**
  27894. * Initializes a webVR display and starts listening to display change events
  27895. * The onVRDisplayChangedObservable will be notified upon these changes
  27896. * @returns A promise containing a VRDisplay and if vr is supported
  27897. */
  27898. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  27899. /**
  27900. * Call this function to switch to webVR mode
  27901. * Will do nothing if webVR is not supported or if there is no webVR device
  27902. * @see http://doc.babylonjs.com/how_to/webvr_camera
  27903. */
  27904. enableVR(): void;
  27905. /**
  27906. * Call this function to leave webVR mode
  27907. * Will do nothing if webVR is not supported or if there is no webVR device
  27908. * @see http://doc.babylonjs.com/how_to/webvr_camera
  27909. */
  27910. disableVR(): void;
  27911. private _onVRFullScreenTriggered;
  27912. private _getVRDisplaysAsync;
  27913. /**
  27914. * Binds the frame buffer to the specified texture.
  27915. * @param texture The texture to render to or null for the default canvas
  27916. * @param faceIndex The face of the texture to render to in case of cube texture
  27917. * @param requiredWidth The width of the target to render to
  27918. * @param requiredHeight The height of the target to render to
  27919. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  27920. * @param depthStencilTexture The depth stencil texture to use to render
  27921. * @param lodLevel defines le lod level to bind to the frame buffer
  27922. */
  27923. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  27924. private bindUnboundFramebuffer;
  27925. /**
  27926. * Unbind the current render target texture from the webGL context
  27927. * @param texture defines the render target texture to unbind
  27928. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  27929. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  27930. */
  27931. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  27932. /**
  27933. * Unbind a list of render target textures from the webGL context
  27934. * This is used only when drawBuffer extension or webGL2 are active
  27935. * @param textures defines the render target textures to unbind
  27936. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  27937. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  27938. */
  27939. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  27940. /**
  27941. * Force the mipmap generation for the given render target texture
  27942. * @param texture defines the render target texture to use
  27943. */
  27944. generateMipMapsForCubemap(texture: InternalTexture): void;
  27945. /**
  27946. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  27947. */
  27948. flushFramebuffer(): void;
  27949. /**
  27950. * Unbind the current render target and bind the default framebuffer
  27951. */
  27952. restoreDefaultFramebuffer(): void;
  27953. /**
  27954. * Create an uniform buffer
  27955. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27956. * @param elements defines the content of the uniform buffer
  27957. * @returns the webGL uniform buffer
  27958. */
  27959. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  27960. /**
  27961. * Create a dynamic uniform buffer
  27962. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27963. * @param elements defines the content of the uniform buffer
  27964. * @returns the webGL uniform buffer
  27965. */
  27966. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  27967. /**
  27968. * Update an existing uniform buffer
  27969. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27970. * @param uniformBuffer defines the target uniform buffer
  27971. * @param elements defines the content to update
  27972. * @param offset defines the offset in the uniform buffer where update should start
  27973. * @param count defines the size of the data to update
  27974. */
  27975. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  27976. private _resetVertexBufferBinding;
  27977. /**
  27978. * Creates a vertex buffer
  27979. * @param data the data for the vertex buffer
  27980. * @returns the new WebGL static buffer
  27981. */
  27982. createVertexBuffer(data: DataArray): WebGLBuffer;
  27983. /**
  27984. * Creates a dynamic vertex buffer
  27985. * @param data the data for the dynamic vertex buffer
  27986. * @returns the new WebGL dynamic buffer
  27987. */
  27988. createDynamicVertexBuffer(data: DataArray): WebGLBuffer;
  27989. /**
  27990. * Update a dynamic index buffer
  27991. * @param indexBuffer defines the target index buffer
  27992. * @param indices defines the data to update
  27993. * @param offset defines the offset in the target index buffer where update should start
  27994. */
  27995. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  27996. /**
  27997. * Updates a dynamic vertex buffer.
  27998. * @param vertexBuffer the vertex buffer to update
  27999. * @param data the data used to update the vertex buffer
  28000. * @param byteOffset the byte offset of the data
  28001. * @param byteLength the byte length of the data
  28002. */
  28003. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  28004. private _resetIndexBufferBinding;
  28005. /**
  28006. * Creates a new index buffer
  28007. * @param indices defines the content of the index buffer
  28008. * @param updatable defines if the index buffer must be updatable
  28009. * @returns a new webGL buffer
  28010. */
  28011. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  28012. /**
  28013. * Bind a webGL buffer to the webGL context
  28014. * @param buffer defines the buffer to bind
  28015. */
  28016. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  28017. /**
  28018. * Bind an uniform buffer to the current webGL context
  28019. * @param buffer defines the buffer to bind
  28020. */
  28021. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  28022. /**
  28023. * Bind a buffer to the current webGL context at a given location
  28024. * @param buffer defines the buffer to bind
  28025. * @param location defines the index where to bind the buffer
  28026. */
  28027. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  28028. /**
  28029. * Bind a specific block at a given index in a specific shader program
  28030. * @param shaderProgram defines the shader program
  28031. * @param blockName defines the block name
  28032. * @param index defines the index where to bind the block
  28033. */
  28034. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  28035. private bindIndexBuffer;
  28036. private bindBuffer;
  28037. /**
  28038. * update the bound buffer with the given data
  28039. * @param data defines the data to update
  28040. */
  28041. updateArrayBuffer(data: Float32Array): void;
  28042. private _vertexAttribPointer;
  28043. private _bindIndexBufferWithCache;
  28044. private _bindVertexBuffersAttributes;
  28045. /**
  28046. * Records a vertex array object
  28047. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  28048. * @param vertexBuffers defines the list of vertex buffers to store
  28049. * @param indexBuffer defines the index buffer to store
  28050. * @param effect defines the effect to store
  28051. * @returns the new vertex array object
  28052. */
  28053. recordVertexArrayObject(vertexBuffers: {
  28054. [key: string]: VertexBuffer;
  28055. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  28056. /**
  28057. * Bind a specific vertex array object
  28058. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  28059. * @param vertexArrayObject defines the vertex array object to bind
  28060. * @param indexBuffer defines the index buffer to bind
  28061. */
  28062. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  28063. /**
  28064. * Bind webGl buffers directly to the webGL context
  28065. * @param vertexBuffer defines the vertex buffer to bind
  28066. * @param indexBuffer defines the index buffer to bind
  28067. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  28068. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  28069. * @param effect defines the effect associated with the vertex buffer
  28070. */
  28071. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  28072. private _unbindVertexArrayObject;
  28073. /**
  28074. * Bind a list of vertex buffers to the webGL context
  28075. * @param vertexBuffers defines the list of vertex buffers to bind
  28076. * @param indexBuffer defines the index buffer to bind
  28077. * @param effect defines the effect associated with the vertex buffers
  28078. */
  28079. bindBuffers(vertexBuffers: {
  28080. [key: string]: Nullable<VertexBuffer>;
  28081. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  28082. /**
  28083. * Unbind all instance attributes
  28084. */
  28085. unbindInstanceAttributes(): void;
  28086. /**
  28087. * Release and free the memory of a vertex array object
  28088. * @param vao defines the vertex array object to delete
  28089. */
  28090. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  28091. /** @hidden */
  28092. _releaseBuffer(buffer: WebGLBuffer): boolean;
  28093. /**
  28094. * Creates a webGL buffer to use with instanciation
  28095. * @param capacity defines the size of the buffer
  28096. * @returns the webGL buffer
  28097. */
  28098. createInstancesBuffer(capacity: number): WebGLBuffer;
  28099. /**
  28100. * Delete a webGL buffer used with instanciation
  28101. * @param buffer defines the webGL buffer to delete
  28102. */
  28103. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  28104. /**
  28105. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  28106. * @param instancesBuffer defines the webGL buffer to update and bind
  28107. * @param data defines the data to store in the buffer
  28108. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  28109. */
  28110. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  28111. /**
  28112. * Apply all cached states (depth, culling, stencil and alpha)
  28113. */
  28114. applyStates(): void;
  28115. /**
  28116. * Send a draw order
  28117. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  28118. * @param indexStart defines the starting index
  28119. * @param indexCount defines the number of index to draw
  28120. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28121. */
  28122. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  28123. /**
  28124. * Draw a list of points
  28125. * @param verticesStart defines the index of first vertex to draw
  28126. * @param verticesCount defines the count of vertices to draw
  28127. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28128. */
  28129. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28130. /**
  28131. * Draw a list of unindexed primitives
  28132. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  28133. * @param verticesStart defines the index of first vertex to draw
  28134. * @param verticesCount defines the count of vertices to draw
  28135. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28136. */
  28137. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28138. /**
  28139. * Draw a list of indexed primitives
  28140. * @param fillMode defines the primitive to use
  28141. * @param indexStart defines the starting index
  28142. * @param indexCount defines the number of index to draw
  28143. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28144. */
  28145. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  28146. /**
  28147. * Draw a list of unindexed primitives
  28148. * @param fillMode defines the primitive to use
  28149. * @param verticesStart defines the index of first vertex to draw
  28150. * @param verticesCount defines the count of vertices to draw
  28151. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28152. */
  28153. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28154. private _drawMode;
  28155. /** @hidden */
  28156. _releaseEffect(effect: Effect): void;
  28157. /** @hidden */
  28158. _deleteProgram(program: WebGLProgram): void;
  28159. /**
  28160. * Create a new effect (used to store vertex/fragment shaders)
  28161. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  28162. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  28163. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  28164. * @param samplers defines an array of string used to represent textures
  28165. * @param defines defines the string containing the defines to use to compile the shaders
  28166. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  28167. * @param onCompiled defines a function to call when the effect creation is successful
  28168. * @param onError defines a function to call when the effect creation has failed
  28169. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  28170. * @returns the new Effect
  28171. */
  28172. 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;
  28173. private _compileShader;
  28174. private _compileRawShader;
  28175. /**
  28176. * Directly creates a webGL program
  28177. * @param vertexCode defines the vertex shader code to use
  28178. * @param fragmentCode defines the fragment shader code to use
  28179. * @param context defines the webGL context to use (if not set, the current one will be used)
  28180. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  28181. * @returns the new webGL program
  28182. */
  28183. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  28184. /**
  28185. * Creates a webGL program
  28186. * @param vertexCode defines the vertex shader code to use
  28187. * @param fragmentCode defines the fragment shader code to use
  28188. * @param defines defines the string containing the defines to use to compile the shaders
  28189. * @param context defines the webGL context to use (if not set, the current one will be used)
  28190. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  28191. * @returns the new webGL program
  28192. */
  28193. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  28194. private _createShaderProgram;
  28195. private _finalizeProgram;
  28196. /** @hidden */
  28197. _isProgramCompiled(shaderProgram: WebGLProgram): boolean;
  28198. /** @hidden */
  28199. _executeWhenProgramIsCompiled(shaderProgram: WebGLProgram, action: () => void): void;
  28200. /**
  28201. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  28202. * @param shaderProgram defines the webGL program to use
  28203. * @param uniformsNames defines the list of uniform names
  28204. * @returns an array of webGL uniform locations
  28205. */
  28206. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  28207. /**
  28208. * Gets the lsit of active attributes for a given webGL program
  28209. * @param shaderProgram defines the webGL program to use
  28210. * @param attributesNames defines the list of attribute names to get
  28211. * @returns an array of indices indicating the offset of each attribute
  28212. */
  28213. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  28214. /**
  28215. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  28216. * @param effect defines the effect to activate
  28217. */
  28218. enableEffect(effect: Nullable<Effect>): void;
  28219. /**
  28220. * Set the value of an uniform to an array of int32
  28221. * @param uniform defines the webGL uniform location where to store the value
  28222. * @param array defines the array of int32 to store
  28223. */
  28224. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28225. /**
  28226. * Set the value of an uniform to an array of int32 (stored as vec2)
  28227. * @param uniform defines the webGL uniform location where to store the value
  28228. * @param array defines the array of int32 to store
  28229. */
  28230. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28231. /**
  28232. * Set the value of an uniform to an array of int32 (stored as vec3)
  28233. * @param uniform defines the webGL uniform location where to store the value
  28234. * @param array defines the array of int32 to store
  28235. */
  28236. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28237. /**
  28238. * Set the value of an uniform to an array of int32 (stored as vec4)
  28239. * @param uniform defines the webGL uniform location where to store the value
  28240. * @param array defines the array of int32 to store
  28241. */
  28242. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28243. /**
  28244. * Set the value of an uniform to an array of float32
  28245. * @param uniform defines the webGL uniform location where to store the value
  28246. * @param array defines the array of float32 to store
  28247. */
  28248. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28249. /**
  28250. * Set the value of an uniform to an array of float32 (stored as vec2)
  28251. * @param uniform defines the webGL uniform location where to store the value
  28252. * @param array defines the array of float32 to store
  28253. */
  28254. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28255. /**
  28256. * Set the value of an uniform to an array of float32 (stored as vec3)
  28257. * @param uniform defines the webGL uniform location where to store the value
  28258. * @param array defines the array of float32 to store
  28259. */
  28260. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28261. /**
  28262. * Set the value of an uniform to an array of float32 (stored as vec4)
  28263. * @param uniform defines the webGL uniform location where to store the value
  28264. * @param array defines the array of float32 to store
  28265. */
  28266. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28267. /**
  28268. * Set the value of an uniform to an array of number
  28269. * @param uniform defines the webGL uniform location where to store the value
  28270. * @param array defines the array of number to store
  28271. */
  28272. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28273. /**
  28274. * Set the value of an uniform to an array of number (stored as vec2)
  28275. * @param uniform defines the webGL uniform location where to store the value
  28276. * @param array defines the array of number to store
  28277. */
  28278. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28279. /**
  28280. * Set the value of an uniform to an array of number (stored as vec3)
  28281. * @param uniform defines the webGL uniform location where to store the value
  28282. * @param array defines the array of number to store
  28283. */
  28284. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28285. /**
  28286. * Set the value of an uniform to an array of number (stored as vec4)
  28287. * @param uniform defines the webGL uniform location where to store the value
  28288. * @param array defines the array of number to store
  28289. */
  28290. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28291. /**
  28292. * Set the value of an uniform to an array of float32 (stored as matrices)
  28293. * @param uniform defines the webGL uniform location where to store the value
  28294. * @param matrices defines the array of float32 to store
  28295. */
  28296. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  28297. /**
  28298. * Set the value of an uniform to a matrix
  28299. * @param uniform defines the webGL uniform location where to store the value
  28300. * @param matrix defines the matrix to store
  28301. */
  28302. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  28303. /**
  28304. * Set the value of an uniform to a matrix (3x3)
  28305. * @param uniform defines the webGL uniform location where to store the value
  28306. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  28307. */
  28308. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  28309. /**
  28310. * Set the value of an uniform to a matrix (2x2)
  28311. * @param uniform defines the webGL uniform location where to store the value
  28312. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  28313. */
  28314. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  28315. /**
  28316. * Set the value of an uniform to a number (int)
  28317. * @param uniform defines the webGL uniform location where to store the value
  28318. * @param value defines the int number to store
  28319. */
  28320. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  28321. /**
  28322. * Set the value of an uniform to a number (float)
  28323. * @param uniform defines the webGL uniform location where to store the value
  28324. * @param value defines the float number to store
  28325. */
  28326. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  28327. /**
  28328. * Set the value of an uniform to a vec2
  28329. * @param uniform defines the webGL uniform location where to store the value
  28330. * @param x defines the 1st component of the value
  28331. * @param y defines the 2nd component of the value
  28332. */
  28333. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  28334. /**
  28335. * Set the value of an uniform to a vec3
  28336. * @param uniform defines the webGL uniform location where to store the value
  28337. * @param x defines the 1st component of the value
  28338. * @param y defines the 2nd component of the value
  28339. * @param z defines the 3rd component of the value
  28340. */
  28341. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  28342. /**
  28343. * Set the value of an uniform to a boolean
  28344. * @param uniform defines the webGL uniform location where to store the value
  28345. * @param bool defines the boolean to store
  28346. */
  28347. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  28348. /**
  28349. * Set the value of an uniform to a vec4
  28350. * @param uniform defines the webGL uniform location where to store the value
  28351. * @param x defines the 1st component of the value
  28352. * @param y defines the 2nd component of the value
  28353. * @param z defines the 3rd component of the value
  28354. * @param w defines the 4th component of the value
  28355. */
  28356. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  28357. /**
  28358. * Set the value of an uniform to a Color3
  28359. * @param uniform defines the webGL uniform location where to store the value
  28360. * @param color3 defines the color to store
  28361. */
  28362. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  28363. /**
  28364. * Set the value of an uniform to a Color3 and an alpha value
  28365. * @param uniform defines the webGL uniform location where to store the value
  28366. * @param color3 defines the color to store
  28367. * @param alpha defines the alpha component to store
  28368. */
  28369. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  28370. /**
  28371. * Sets a Color4 on a uniform variable
  28372. * @param uniform defines the uniform location
  28373. * @param color4 defines the value to be set
  28374. */
  28375. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  28376. /**
  28377. * Set various states to the webGL context
  28378. * @param culling defines backface culling state
  28379. * @param zOffset defines the value to apply to zOffset (0 by default)
  28380. * @param force defines if states must be applied even if cache is up to date
  28381. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  28382. */
  28383. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  28384. /**
  28385. * Set the z offset to apply to current rendering
  28386. * @param value defines the offset to apply
  28387. */
  28388. setZOffset(value: number): void;
  28389. /**
  28390. * Gets the current value of the zOffset
  28391. * @returns the current zOffset state
  28392. */
  28393. getZOffset(): number;
  28394. /**
  28395. * Enable or disable depth buffering
  28396. * @param enable defines the state to set
  28397. */
  28398. setDepthBuffer(enable: boolean): void;
  28399. /**
  28400. * Gets a boolean indicating if depth writing is enabled
  28401. * @returns the current depth writing state
  28402. */
  28403. getDepthWrite(): boolean;
  28404. /**
  28405. * Enable or disable depth writing
  28406. * @param enable defines the state to set
  28407. */
  28408. setDepthWrite(enable: boolean): void;
  28409. /**
  28410. * Enable or disable color writing
  28411. * @param enable defines the state to set
  28412. */
  28413. setColorWrite(enable: boolean): void;
  28414. /**
  28415. * Gets a boolean indicating if color writing is enabled
  28416. * @returns the current color writing state
  28417. */
  28418. getColorWrite(): boolean;
  28419. /**
  28420. * Sets alpha constants used by some alpha blending modes
  28421. * @param r defines the red component
  28422. * @param g defines the green component
  28423. * @param b defines the blue component
  28424. * @param a defines the alpha component
  28425. */
  28426. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  28427. /**
  28428. * Sets the current alpha mode
  28429. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  28430. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  28431. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  28432. */
  28433. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  28434. /**
  28435. * Gets the current alpha mode
  28436. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  28437. * @returns the current alpha mode
  28438. */
  28439. getAlphaMode(): number;
  28440. /**
  28441. * Clears the list of texture accessible through engine.
  28442. * This can help preventing texture load conflict due to name collision.
  28443. */
  28444. clearInternalTexturesCache(): void;
  28445. /**
  28446. * Force the entire cache to be cleared
  28447. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  28448. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  28449. */
  28450. wipeCaches(bruteForce?: boolean): void;
  28451. /**
  28452. * Set the compressed texture format to use, based on the formats you have, and the formats
  28453. * supported by the hardware / browser.
  28454. *
  28455. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  28456. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  28457. * to API arguments needed to compressed textures. This puts the burden on the container
  28458. * generator to house the arcane code for determining these for current & future formats.
  28459. *
  28460. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  28461. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  28462. *
  28463. * Note: The result of this call is not taken into account when a texture is base64.
  28464. *
  28465. * @param formatsAvailable defines the list of those format families you have created
  28466. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  28467. *
  28468. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  28469. * @returns The extension selected.
  28470. */
  28471. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  28472. private _getSamplingParameters;
  28473. private _partialLoadImg;
  28474. private _cascadeLoadImgs;
  28475. /** @hidden */
  28476. _createTexture(): WebGLTexture;
  28477. /**
  28478. * Usually called from Texture.ts.
  28479. * Passed information to create a WebGLTexture
  28480. * @param urlArg defines a value which contains one of the following:
  28481. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  28482. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  28483. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  28484. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  28485. * @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)
  28486. * @param scene needed for loading to the correct scene
  28487. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  28488. * @param onLoad optional callback to be called upon successful completion
  28489. * @param onError optional callback to be called upon failure
  28490. * @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
  28491. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  28492. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  28493. * @param forcedExtension defines the extension to use to pick the right loader
  28494. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  28495. * @returns a InternalTexture for assignment back into BABYLON.Texture
  28496. */
  28497. 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;
  28498. private _rescaleTexture;
  28499. /**
  28500. * Update a raw texture
  28501. * @param texture defines the texture to update
  28502. * @param data defines the data to store in the texture
  28503. * @param format defines the format of the data
  28504. * @param invertY defines if data must be stored with Y axis inverted
  28505. * @param compression defines the compression used (null by default)
  28506. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  28507. */
  28508. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  28509. /**
  28510. * Creates a raw texture
  28511. * @param data defines the data to store in the texture
  28512. * @param width defines the width of the texture
  28513. * @param height defines the height of the texture
  28514. * @param format defines the format of the data
  28515. * @param generateMipMaps defines if the engine should generate the mip levels
  28516. * @param invertY defines if data must be stored with Y axis inverted
  28517. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  28518. * @param compression defines the compression used (null by default)
  28519. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  28520. * @returns the raw texture inside an InternalTexture
  28521. */
  28522. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  28523. private _unpackFlipYCached;
  28524. /**
  28525. * In case you are sharing the context with other applications, it might
  28526. * be interested to not cache the unpack flip y state to ensure a consistent
  28527. * value would be set.
  28528. */
  28529. enableUnpackFlipYCached: boolean;
  28530. /** @hidden */
  28531. _unpackFlipY(value: boolean): void;
  28532. /** @hidden */
  28533. _getUnpackAlignement(): number;
  28534. /**
  28535. * Creates a dynamic texture
  28536. * @param width defines the width of the texture
  28537. * @param height defines the height of the texture
  28538. * @param generateMipMaps defines if the engine should generate the mip levels
  28539. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  28540. * @returns the dynamic texture inside an InternalTexture
  28541. */
  28542. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  28543. /**
  28544. * Update the sampling mode of a given texture
  28545. * @param samplingMode defines the required sampling mode
  28546. * @param texture defines the texture to update
  28547. */
  28548. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  28549. /**
  28550. * Update the content of a dynamic texture
  28551. * @param texture defines the texture to update
  28552. * @param canvas defines the canvas containing the source
  28553. * @param invertY defines if data must be stored with Y axis inverted
  28554. * @param premulAlpha defines if alpha is stored as premultiplied
  28555. * @param format defines the format of the data
  28556. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  28557. */
  28558. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  28559. /**
  28560. * Update a video texture
  28561. * @param texture defines the texture to update
  28562. * @param video defines the video element to use
  28563. * @param invertY defines if data must be stored with Y axis inverted
  28564. */
  28565. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  28566. /**
  28567. * Updates a depth texture Comparison Mode and Function.
  28568. * If the comparison Function is equal to 0, the mode will be set to none.
  28569. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  28570. * @param texture The texture to set the comparison function for
  28571. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  28572. */
  28573. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  28574. private _setupDepthStencilTexture;
  28575. /**
  28576. * Creates a depth stencil texture.
  28577. * This is only available in WebGL 2 or with the depth texture extension available.
  28578. * @param size The size of face edge in the texture.
  28579. * @param options The options defining the texture.
  28580. * @returns The texture
  28581. */
  28582. createDepthStencilTexture(size: number | {
  28583. width: number;
  28584. height: number;
  28585. }, options: DepthTextureCreationOptions): InternalTexture;
  28586. /**
  28587. * Creates a depth stencil texture.
  28588. * This is only available in WebGL 2 or with the depth texture extension available.
  28589. * @param size The size of face edge in the texture.
  28590. * @param options The options defining the texture.
  28591. * @returns The texture
  28592. */
  28593. private _createDepthStencilTexture;
  28594. /**
  28595. * Creates a depth stencil cube texture.
  28596. * This is only available in WebGL 2.
  28597. * @param size The size of face edge in the cube texture.
  28598. * @param options The options defining the cube texture.
  28599. * @returns The cube texture
  28600. */
  28601. private _createDepthStencilCubeTexture;
  28602. /**
  28603. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  28604. * @param renderTarget The render target to set the frame buffer for
  28605. */
  28606. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  28607. /**
  28608. * Creates a new render target texture
  28609. * @param size defines the size of the texture
  28610. * @param options defines the options used to create the texture
  28611. * @returns a new render target texture stored in an InternalTexture
  28612. */
  28613. createRenderTargetTexture(size: number | {
  28614. width: number;
  28615. height: number;
  28616. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  28617. /**
  28618. * Create a multi render target texture
  28619. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  28620. * @param size defines the size of the texture
  28621. * @param options defines the creation options
  28622. * @returns the cube texture as an InternalTexture
  28623. */
  28624. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  28625. private _setupFramebufferDepthAttachments;
  28626. /**
  28627. * Updates the sample count of a render target texture
  28628. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  28629. * @param texture defines the texture to update
  28630. * @param samples defines the sample count to set
  28631. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  28632. */
  28633. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  28634. /**
  28635. * Update the sample count for a given multiple render target texture
  28636. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  28637. * @param textures defines the textures to update
  28638. * @param samples defines the sample count to set
  28639. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  28640. */
  28641. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  28642. /** @hidden */
  28643. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28644. /** @hidden */
  28645. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28646. /** @hidden */
  28647. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28648. /** @hidden */
  28649. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  28650. /**
  28651. * Creates a new render target cube texture
  28652. * @param size defines the size of the texture
  28653. * @param options defines the options used to create the texture
  28654. * @returns a new render target cube texture stored in an InternalTexture
  28655. */
  28656. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  28657. /**
  28658. * Creates a cube texture
  28659. * @param rootUrl defines the url where the files to load is located
  28660. * @param scene defines the current scene
  28661. * @param files defines the list of files to load (1 per face)
  28662. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  28663. * @param onLoad defines an optional callback raised when the texture is loaded
  28664. * @param onError defines an optional callback raised if there is an issue to load the texture
  28665. * @param format defines the format of the data
  28666. * @param forcedExtension defines the extension to use to pick the right loader
  28667. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  28668. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  28669. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  28670. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  28671. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  28672. * @returns the cube texture as an InternalTexture
  28673. */
  28674. 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;
  28675. /**
  28676. * @hidden
  28677. */
  28678. _setCubeMapTextureParams(loadMipmap: boolean): void;
  28679. /**
  28680. * Update a raw cube texture
  28681. * @param texture defines the texture to udpdate
  28682. * @param data defines the data to store
  28683. * @param format defines the data format
  28684. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  28685. * @param invertY defines if data must be stored with Y axis inverted
  28686. * @param compression defines the compression used (null by default)
  28687. * @param level defines which level of the texture to update
  28688. */
  28689. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  28690. /**
  28691. * Creates a new raw cube texture
  28692. * @param data defines the array of data to use to create each face
  28693. * @param size defines the size of the textures
  28694. * @param format defines the format of the data
  28695. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  28696. * @param generateMipMaps defines if the engine should generate the mip levels
  28697. * @param invertY defines if data must be stored with Y axis inverted
  28698. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  28699. * @param compression defines the compression used (null by default)
  28700. * @returns the cube texture as an InternalTexture
  28701. */
  28702. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  28703. /**
  28704. * Creates a new raw cube texture from a specified url
  28705. * @param url defines the url where the data is located
  28706. * @param scene defines the current scene
  28707. * @param size defines the size of the textures
  28708. * @param format defines the format of the data
  28709. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  28710. * @param noMipmap defines if the engine should avoid generating the mip levels
  28711. * @param callback defines a callback used to extract texture data from loaded data
  28712. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  28713. * @param onLoad defines a callback called when texture is loaded
  28714. * @param onError defines a callback called if there is an error
  28715. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  28716. * @param invertY defines if data must be stored with Y axis inverted
  28717. * @returns the cube texture as an InternalTexture
  28718. */
  28719. 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;
  28720. /**
  28721. * Update a raw 3D texture
  28722. * @param texture defines the texture to update
  28723. * @param data defines the data to store
  28724. * @param format defines the data format
  28725. * @param invertY defines if data must be stored with Y axis inverted
  28726. * @param compression defines the used compression (can be null)
  28727. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  28728. */
  28729. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  28730. /**
  28731. * Creates a new raw 3D texture
  28732. * @param data defines the data used to create the texture
  28733. * @param width defines the width of the texture
  28734. * @param height defines the height of the texture
  28735. * @param depth defines the depth of the texture
  28736. * @param format defines the format of the texture
  28737. * @param generateMipMaps defines if the engine must generate mip levels
  28738. * @param invertY defines if data must be stored with Y axis inverted
  28739. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  28740. * @param compression defines the compressed used (can be null)
  28741. * @param textureType defines the compressed used (can be null)
  28742. * @returns a new raw 3D texture (stored in an InternalTexture)
  28743. */
  28744. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  28745. private _prepareWebGLTextureContinuation;
  28746. private _prepareWebGLTexture;
  28747. private _convertRGBtoRGBATextureData;
  28748. /** @hidden */
  28749. _releaseFramebufferObjects(texture: InternalTexture): void;
  28750. /** @hidden */
  28751. _releaseTexture(texture: InternalTexture): void;
  28752. private setProgram;
  28753. private _boundUniforms;
  28754. /**
  28755. * Binds an effect to the webGL context
  28756. * @param effect defines the effect to bind
  28757. */
  28758. bindSamplers(effect: Effect): void;
  28759. private _moveBoundTextureOnTop;
  28760. private _getCorrectTextureChannel;
  28761. private _linkTrackers;
  28762. private _removeDesignatedSlot;
  28763. private _activateCurrentTexture;
  28764. /** @hidden */
  28765. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  28766. /** @hidden */
  28767. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  28768. /**
  28769. * Sets a texture to the webGL context from a postprocess
  28770. * @param channel defines the channel to use
  28771. * @param postProcess defines the source postprocess
  28772. */
  28773. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  28774. /**
  28775. * Binds the output of the passed in post process to the texture channel specified
  28776. * @param channel The channel the texture should be bound to
  28777. * @param postProcess The post process which's output should be bound
  28778. */
  28779. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  28780. /**
  28781. * Unbind all textures from the webGL context
  28782. */
  28783. unbindAllTextures(): void;
  28784. /**
  28785. * Sets a texture to the according uniform.
  28786. * @param channel The texture channel
  28787. * @param uniform The uniform to set
  28788. * @param texture The texture to apply
  28789. */
  28790. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  28791. /**
  28792. * Sets a depth stencil texture from a render target to the according uniform.
  28793. * @param channel The texture channel
  28794. * @param uniform The uniform to set
  28795. * @param texture The render target texture containing the depth stencil texture to apply
  28796. */
  28797. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  28798. private _bindSamplerUniformToChannel;
  28799. private _getTextureWrapMode;
  28800. private _setTexture;
  28801. /**
  28802. * Sets an array of texture to the webGL context
  28803. * @param channel defines the channel where the texture array must be set
  28804. * @param uniform defines the associated uniform location
  28805. * @param textures defines the array of textures to bind
  28806. */
  28807. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  28808. /** @hidden */
  28809. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  28810. private _setTextureParameterFloat;
  28811. private _setTextureParameterInteger;
  28812. /**
  28813. * Reads pixels from the current frame buffer. Please note that this function can be slow
  28814. * @param x defines the x coordinate of the rectangle where pixels must be read
  28815. * @param y defines the y coordinate of the rectangle where pixels must be read
  28816. * @param width defines the width of the rectangle where pixels must be read
  28817. * @param height defines the height of the rectangle where pixels must be read
  28818. * @returns a Uint8Array containing RGBA colors
  28819. */
  28820. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  28821. /**
  28822. * Add an externaly attached data from its key.
  28823. * This method call will fail and return false, if such key already exists.
  28824. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  28825. * @param key the unique key that identifies the data
  28826. * @param data the data object to associate to the key for this Engine instance
  28827. * @return true if no such key were already present and the data was added successfully, false otherwise
  28828. */
  28829. addExternalData<T>(key: string, data: T): boolean;
  28830. /**
  28831. * Get an externaly attached data from its key
  28832. * @param key the unique key that identifies the data
  28833. * @return the associated data, if present (can be null), or undefined if not present
  28834. */
  28835. getExternalData<T>(key: string): T;
  28836. /**
  28837. * Get an externaly attached data from its key, create it using a factory if it's not already present
  28838. * @param key the unique key that identifies the data
  28839. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  28840. * @return the associated data, can be null if the factory returned null.
  28841. */
  28842. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  28843. /**
  28844. * Remove an externaly attached data from the Engine instance
  28845. * @param key the unique key that identifies the data
  28846. * @return true if the data was successfully removed, false if it doesn't exist
  28847. */
  28848. removeExternalData(key: string): boolean;
  28849. /**
  28850. * Unbind all vertex attributes from the webGL context
  28851. */
  28852. unbindAllAttributes(): void;
  28853. /**
  28854. * 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
  28855. */
  28856. releaseEffects(): void;
  28857. /**
  28858. * Dispose and release all associated resources
  28859. */
  28860. dispose(): void;
  28861. /**
  28862. * Display the loading screen
  28863. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28864. */
  28865. displayLoadingUI(): void;
  28866. /**
  28867. * Hide the loading screen
  28868. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28869. */
  28870. hideLoadingUI(): void;
  28871. /**
  28872. * Gets the current loading screen object
  28873. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28874. */
  28875. /**
  28876. * Sets the current loading screen object
  28877. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28878. */
  28879. loadingScreen: ILoadingScreen;
  28880. /**
  28881. * Sets the current loading screen text
  28882. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28883. */
  28884. loadingUIText: string;
  28885. /**
  28886. * Sets the current loading screen background color
  28887. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28888. */
  28889. loadingUIBackgroundColor: string;
  28890. /**
  28891. * Attach a new callback raised when context lost event is fired
  28892. * @param callback defines the callback to call
  28893. */
  28894. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  28895. /**
  28896. * Attach a new callback raised when context restored event is fired
  28897. * @param callback defines the callback to call
  28898. */
  28899. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  28900. /**
  28901. * Gets the source code of the vertex shader associated with a specific webGL program
  28902. * @param program defines the program to use
  28903. * @returns a string containing the source code of the vertex shader associated with the program
  28904. */
  28905. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  28906. /**
  28907. * Gets the source code of the fragment shader associated with a specific webGL program
  28908. * @param program defines the program to use
  28909. * @returns a string containing the source code of the fragment shader associated with the program
  28910. */
  28911. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  28912. /**
  28913. * Get the current error code of the webGL context
  28914. * @returns the error code
  28915. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  28916. */
  28917. getError(): number;
  28918. /**
  28919. * Gets the current framerate
  28920. * @returns a number representing the framerate
  28921. */
  28922. getFps(): number;
  28923. /**
  28924. * Gets the time spent between current and previous frame
  28925. * @returns a number representing the delta time in ms
  28926. */
  28927. getDeltaTime(): number;
  28928. private _measureFps;
  28929. /** @hidden */
  28930. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  28931. private _canRenderToFloatFramebuffer;
  28932. private _canRenderToHalfFloatFramebuffer;
  28933. private _canRenderToFramebuffer;
  28934. /** @hidden */
  28935. _getWebGLTextureType(type: number): number;
  28936. private _getInternalFormat;
  28937. /** @hidden */
  28938. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  28939. /** @hidden */
  28940. _getRGBAMultiSampleBufferFormat(type: number): number;
  28941. /** @hidden */
  28942. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: XMLHttpRequest, exception?: any) => void): IFileRequest;
  28943. /** @hidden */
  28944. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  28945. private _partialLoadFile;
  28946. private _cascadeLoadFiles;
  28947. /**
  28948. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  28949. * @returns true if the engine can be created
  28950. * @ignorenaming
  28951. */
  28952. static isSupported(): boolean;
  28953. }
  28954. }
  28955. declare module "babylonjs/Materials/effect" {
  28956. import { Observable } from "babylonjs/Misc/observable";
  28957. import { Nullable } from "babylonjs/types";
  28958. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  28959. import { Engine } from "babylonjs/Engines/engine";
  28960. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  28961. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  28962. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  28963. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  28964. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28965. /**
  28966. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  28967. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  28968. */
  28969. export class EffectFallbacks {
  28970. private _defines;
  28971. private _currentRank;
  28972. private _maxRank;
  28973. private _mesh;
  28974. /**
  28975. * Removes the fallback from the bound mesh.
  28976. */
  28977. unBindMesh(): void;
  28978. /**
  28979. * Adds a fallback on the specified property.
  28980. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28981. * @param define The name of the define in the shader
  28982. */
  28983. addFallback(rank: number, define: string): void;
  28984. /**
  28985. * Sets the mesh to use CPU skinning when needing to fallback.
  28986. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28987. * @param mesh The mesh to use the fallbacks.
  28988. */
  28989. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  28990. /**
  28991. * Checks to see if more fallbacks are still availible.
  28992. */
  28993. readonly isMoreFallbacks: boolean;
  28994. /**
  28995. * Removes the defines that shoould be removed when falling back.
  28996. * @param currentDefines defines the current define statements for the shader.
  28997. * @param effect defines the current effect we try to compile
  28998. * @returns The resulting defines with defines of the current rank removed.
  28999. */
  29000. reduce(currentDefines: string, effect: Effect): string;
  29001. }
  29002. /**
  29003. * Options to be used when creating an effect.
  29004. */
  29005. export class EffectCreationOptions {
  29006. /**
  29007. * Atrributes that will be used in the shader.
  29008. */
  29009. attributes: string[];
  29010. /**
  29011. * Uniform varible names that will be set in the shader.
  29012. */
  29013. uniformsNames: string[];
  29014. /**
  29015. * Uniform buffer varible names that will be set in the shader.
  29016. */
  29017. uniformBuffersNames: string[];
  29018. /**
  29019. * Sampler texture variable names that will be set in the shader.
  29020. */
  29021. samplers: string[];
  29022. /**
  29023. * Define statements that will be set in the shader.
  29024. */
  29025. defines: any;
  29026. /**
  29027. * Possible fallbacks for this effect to improve performance when needed.
  29028. */
  29029. fallbacks: Nullable<EffectFallbacks>;
  29030. /**
  29031. * Callback that will be called when the shader is compiled.
  29032. */
  29033. onCompiled: Nullable<(effect: Effect) => void>;
  29034. /**
  29035. * Callback that will be called if an error occurs during shader compilation.
  29036. */
  29037. onError: Nullable<(effect: Effect, errors: string) => void>;
  29038. /**
  29039. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29040. */
  29041. indexParameters: any;
  29042. /**
  29043. * Max number of lights that can be used in the shader.
  29044. */
  29045. maxSimultaneousLights: number;
  29046. /**
  29047. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  29048. */
  29049. transformFeedbackVaryings: Nullable<string[]>;
  29050. }
  29051. /**
  29052. * Effect containing vertex and fragment shader that can be executed on an object.
  29053. */
  29054. export class Effect {
  29055. /**
  29056. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29057. */
  29058. static ShadersRepository: string;
  29059. /**
  29060. * Name of the effect.
  29061. */
  29062. name: any;
  29063. /**
  29064. * String container all the define statements that should be set on the shader.
  29065. */
  29066. defines: string;
  29067. /**
  29068. * Callback that will be called when the shader is compiled.
  29069. */
  29070. onCompiled: Nullable<(effect: Effect) => void>;
  29071. /**
  29072. * Callback that will be called if an error occurs during shader compilation.
  29073. */
  29074. onError: Nullable<(effect: Effect, errors: string) => void>;
  29075. /**
  29076. * Callback that will be called when effect is bound.
  29077. */
  29078. onBind: Nullable<(effect: Effect) => void>;
  29079. /**
  29080. * Unique ID of the effect.
  29081. */
  29082. uniqueId: number;
  29083. /**
  29084. * Observable that will be called when the shader is compiled.
  29085. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  29086. */
  29087. onCompileObservable: Observable<Effect>;
  29088. /**
  29089. * Observable that will be called if an error occurs during shader compilation.
  29090. */
  29091. onErrorObservable: Observable<Effect>;
  29092. /** @hidden */
  29093. _onBindObservable: Nullable<Observable<Effect>>;
  29094. /**
  29095. * Observable that will be called when effect is bound.
  29096. */
  29097. readonly onBindObservable: Observable<Effect>;
  29098. /** @hidden */
  29099. _bonesComputationForcedToCPU: boolean;
  29100. private static _uniqueIdSeed;
  29101. private _engine;
  29102. private _uniformBuffersNames;
  29103. private _uniformsNames;
  29104. private _samplers;
  29105. private _isReady;
  29106. private _compilationError;
  29107. private _attributesNames;
  29108. private _attributes;
  29109. private _uniforms;
  29110. /**
  29111. * Key for the effect.
  29112. * @hidden
  29113. */
  29114. _key: string;
  29115. private _indexParameters;
  29116. private _fallbacks;
  29117. private _vertexSourceCode;
  29118. private _fragmentSourceCode;
  29119. private _vertexSourceCodeOverride;
  29120. private _fragmentSourceCodeOverride;
  29121. private _transformFeedbackVaryings;
  29122. /**
  29123. * Compiled shader to webGL program.
  29124. * @hidden
  29125. */
  29126. _program: WebGLProgram;
  29127. private _valueCache;
  29128. private static _baseCache;
  29129. /**
  29130. * Instantiates an effect.
  29131. * An effect can be used to create/manage/execute vertex and fragment shaders.
  29132. * @param baseName Name of the effect.
  29133. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  29134. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  29135. * @param samplers List of sampler variables that will be passed to the shader.
  29136. * @param engine Engine to be used to render the effect
  29137. * @param defines Define statements to be added to the shader.
  29138. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  29139. * @param onCompiled Callback that will be called when the shader is compiled.
  29140. * @param onError Callback that will be called if an error occurs during shader compilation.
  29141. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29142. */
  29143. 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);
  29144. /**
  29145. * Unique key for this effect
  29146. */
  29147. readonly key: string;
  29148. /**
  29149. * If the effect has been compiled and prepared.
  29150. * @returns if the effect is compiled and prepared.
  29151. */
  29152. isReady(): boolean;
  29153. /**
  29154. * The engine the effect was initialized with.
  29155. * @returns the engine.
  29156. */
  29157. getEngine(): Engine;
  29158. /**
  29159. * The compiled webGL program for the effect
  29160. * @returns the webGL program.
  29161. */
  29162. getProgram(): WebGLProgram;
  29163. /**
  29164. * The set of names of attribute variables for the shader.
  29165. * @returns An array of attribute names.
  29166. */
  29167. getAttributesNames(): string[];
  29168. /**
  29169. * Returns the attribute at the given index.
  29170. * @param index The index of the attribute.
  29171. * @returns The location of the attribute.
  29172. */
  29173. getAttributeLocation(index: number): number;
  29174. /**
  29175. * Returns the attribute based on the name of the variable.
  29176. * @param name of the attribute to look up.
  29177. * @returns the attribute location.
  29178. */
  29179. getAttributeLocationByName(name: string): number;
  29180. /**
  29181. * The number of attributes.
  29182. * @returns the numnber of attributes.
  29183. */
  29184. getAttributesCount(): number;
  29185. /**
  29186. * Gets the index of a uniform variable.
  29187. * @param uniformName of the uniform to look up.
  29188. * @returns the index.
  29189. */
  29190. getUniformIndex(uniformName: string): number;
  29191. /**
  29192. * Returns the attribute based on the name of the variable.
  29193. * @param uniformName of the uniform to look up.
  29194. * @returns the location of the uniform.
  29195. */
  29196. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  29197. /**
  29198. * Returns an array of sampler variable names
  29199. * @returns The array of sampler variable neames.
  29200. */
  29201. getSamplers(): string[];
  29202. /**
  29203. * The error from the last compilation.
  29204. * @returns the error string.
  29205. */
  29206. getCompilationError(): string;
  29207. /**
  29208. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  29209. * @param func The callback to be used.
  29210. */
  29211. executeWhenCompiled(func: (effect: Effect) => void): void;
  29212. private _checkIsReady;
  29213. /** @hidden */
  29214. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  29215. /** @hidden */
  29216. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  29217. /** @hidden */
  29218. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  29219. private _processShaderConversion;
  29220. private _processIncludes;
  29221. private _processPrecision;
  29222. /**
  29223. * Recompiles the webGL program
  29224. * @param vertexSourceCode The source code for the vertex shader.
  29225. * @param fragmentSourceCode The source code for the fragment shader.
  29226. * @param onCompiled Callback called when completed.
  29227. * @param onError Callback called on error.
  29228. * @hidden
  29229. */
  29230. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  29231. /**
  29232. * Gets the uniform locations of the the specified variable names
  29233. * @param names THe names of the variables to lookup.
  29234. * @returns Array of locations in the same order as variable names.
  29235. */
  29236. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  29237. /**
  29238. * Prepares the effect
  29239. * @hidden
  29240. */
  29241. _prepareEffect(): void;
  29242. /**
  29243. * Checks if the effect is supported. (Must be called after compilation)
  29244. */
  29245. readonly isSupported: boolean;
  29246. /**
  29247. * Binds a texture to the engine to be used as output of the shader.
  29248. * @param channel Name of the output variable.
  29249. * @param texture Texture to bind.
  29250. * @hidden
  29251. */
  29252. _bindTexture(channel: string, texture: InternalTexture): void;
  29253. /**
  29254. * Sets a texture on the engine to be used in the shader.
  29255. * @param channel Name of the sampler variable.
  29256. * @param texture Texture to set.
  29257. */
  29258. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  29259. /**
  29260. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  29261. * @param channel Name of the sampler variable.
  29262. * @param texture Texture to set.
  29263. */
  29264. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  29265. /**
  29266. * Sets an array of textures on the engine to be used in the shader.
  29267. * @param channel Name of the variable.
  29268. * @param textures Textures to set.
  29269. */
  29270. setTextureArray(channel: string, textures: BaseTexture[]): void;
  29271. /**
  29272. * 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)
  29273. * @param channel Name of the sampler variable.
  29274. * @param postProcess Post process to get the input texture from.
  29275. */
  29276. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  29277. /**
  29278. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  29279. * 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)
  29280. * @param channel Name of the sampler variable.
  29281. * @param postProcess Post process to get the output texture from.
  29282. */
  29283. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  29284. /** @hidden */
  29285. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  29286. /** @hidden */
  29287. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  29288. /** @hidden */
  29289. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  29290. /** @hidden */
  29291. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  29292. /**
  29293. * Binds a buffer to a uniform.
  29294. * @param buffer Buffer to bind.
  29295. * @param name Name of the uniform variable to bind to.
  29296. */
  29297. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  29298. /**
  29299. * Binds block to a uniform.
  29300. * @param blockName Name of the block to bind.
  29301. * @param index Index to bind.
  29302. */
  29303. bindUniformBlock(blockName: string, index: number): void;
  29304. /**
  29305. * Sets an interger value on a uniform variable.
  29306. * @param uniformName Name of the variable.
  29307. * @param value Value to be set.
  29308. * @returns this effect.
  29309. */
  29310. setInt(uniformName: string, value: number): Effect;
  29311. /**
  29312. * Sets an int array on a uniform variable.
  29313. * @param uniformName Name of the variable.
  29314. * @param array array to be set.
  29315. * @returns this effect.
  29316. */
  29317. setIntArray(uniformName: string, array: Int32Array): Effect;
  29318. /**
  29319. * 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)
  29320. * @param uniformName Name of the variable.
  29321. * @param array array to be set.
  29322. * @returns this effect.
  29323. */
  29324. setIntArray2(uniformName: string, array: Int32Array): Effect;
  29325. /**
  29326. * 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)
  29327. * @param uniformName Name of the variable.
  29328. * @param array array to be set.
  29329. * @returns this effect.
  29330. */
  29331. setIntArray3(uniformName: string, array: Int32Array): Effect;
  29332. /**
  29333. * 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)
  29334. * @param uniformName Name of the variable.
  29335. * @param array array to be set.
  29336. * @returns this effect.
  29337. */
  29338. setIntArray4(uniformName: string, array: Int32Array): Effect;
  29339. /**
  29340. * Sets an float array on a uniform variable.
  29341. * @param uniformName Name of the variable.
  29342. * @param array array to be set.
  29343. * @returns this effect.
  29344. */
  29345. setFloatArray(uniformName: string, array: Float32Array): Effect;
  29346. /**
  29347. * 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)
  29348. * @param uniformName Name of the variable.
  29349. * @param array array to be set.
  29350. * @returns this effect.
  29351. */
  29352. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  29353. /**
  29354. * 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)
  29355. * @param uniformName Name of the variable.
  29356. * @param array array to be set.
  29357. * @returns this effect.
  29358. */
  29359. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  29360. /**
  29361. * 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)
  29362. * @param uniformName Name of the variable.
  29363. * @param array array to be set.
  29364. * @returns this effect.
  29365. */
  29366. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  29367. /**
  29368. * Sets an array on a uniform variable.
  29369. * @param uniformName Name of the variable.
  29370. * @param array array to be set.
  29371. * @returns this effect.
  29372. */
  29373. setArray(uniformName: string, array: number[]): Effect;
  29374. /**
  29375. * 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)
  29376. * @param uniformName Name of the variable.
  29377. * @param array array to be set.
  29378. * @returns this effect.
  29379. */
  29380. setArray2(uniformName: string, array: number[]): Effect;
  29381. /**
  29382. * 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)
  29383. * @param uniformName Name of the variable.
  29384. * @param array array to be set.
  29385. * @returns this effect.
  29386. */
  29387. setArray3(uniformName: string, array: number[]): Effect;
  29388. /**
  29389. * 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)
  29390. * @param uniformName Name of the variable.
  29391. * @param array array to be set.
  29392. * @returns this effect.
  29393. */
  29394. setArray4(uniformName: string, array: number[]): Effect;
  29395. /**
  29396. * Sets matrices on a uniform variable.
  29397. * @param uniformName Name of the variable.
  29398. * @param matrices matrices to be set.
  29399. * @returns this effect.
  29400. */
  29401. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  29402. /**
  29403. * Sets matrix on a uniform variable.
  29404. * @param uniformName Name of the variable.
  29405. * @param matrix matrix to be set.
  29406. * @returns this effect.
  29407. */
  29408. setMatrix(uniformName: string, matrix: Matrix): Effect;
  29409. /**
  29410. * 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)
  29411. * @param uniformName Name of the variable.
  29412. * @param matrix matrix to be set.
  29413. * @returns this effect.
  29414. */
  29415. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  29416. /**
  29417. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  29418. * @param uniformName Name of the variable.
  29419. * @param matrix matrix to be set.
  29420. * @returns this effect.
  29421. */
  29422. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  29423. /**
  29424. * Sets a float on a uniform variable.
  29425. * @param uniformName Name of the variable.
  29426. * @param value value to be set.
  29427. * @returns this effect.
  29428. */
  29429. setFloat(uniformName: string, value: number): Effect;
  29430. /**
  29431. * Sets a boolean on a uniform variable.
  29432. * @param uniformName Name of the variable.
  29433. * @param bool value to be set.
  29434. * @returns this effect.
  29435. */
  29436. setBool(uniformName: string, bool: boolean): Effect;
  29437. /**
  29438. * Sets a Vector2 on a uniform variable.
  29439. * @param uniformName Name of the variable.
  29440. * @param vector2 vector2 to be set.
  29441. * @returns this effect.
  29442. */
  29443. setVector2(uniformName: string, vector2: Vector2): Effect;
  29444. /**
  29445. * Sets a float2 on a uniform variable.
  29446. * @param uniformName Name of the variable.
  29447. * @param x First float in float2.
  29448. * @param y Second float in float2.
  29449. * @returns this effect.
  29450. */
  29451. setFloat2(uniformName: string, x: number, y: number): Effect;
  29452. /**
  29453. * Sets a Vector3 on a uniform variable.
  29454. * @param uniformName Name of the variable.
  29455. * @param vector3 Value to be set.
  29456. * @returns this effect.
  29457. */
  29458. setVector3(uniformName: string, vector3: Vector3): Effect;
  29459. /**
  29460. * Sets a float3 on a uniform variable.
  29461. * @param uniformName Name of the variable.
  29462. * @param x First float in float3.
  29463. * @param y Second float in float3.
  29464. * @param z Third float in float3.
  29465. * @returns this effect.
  29466. */
  29467. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  29468. /**
  29469. * Sets a Vector4 on a uniform variable.
  29470. * @param uniformName Name of the variable.
  29471. * @param vector4 Value to be set.
  29472. * @returns this effect.
  29473. */
  29474. setVector4(uniformName: string, vector4: Vector4): Effect;
  29475. /**
  29476. * Sets a float4 on a uniform variable.
  29477. * @param uniformName Name of the variable.
  29478. * @param x First float in float4.
  29479. * @param y Second float in float4.
  29480. * @param z Third float in float4.
  29481. * @param w Fourth float in float4.
  29482. * @returns this effect.
  29483. */
  29484. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  29485. /**
  29486. * Sets a Color3 on a uniform variable.
  29487. * @param uniformName Name of the variable.
  29488. * @param color3 Value to be set.
  29489. * @returns this effect.
  29490. */
  29491. setColor3(uniformName: string, color3: Color3): Effect;
  29492. /**
  29493. * Sets a Color4 on a uniform variable.
  29494. * @param uniformName Name of the variable.
  29495. * @param color3 Value to be set.
  29496. * @param alpha Alpha value to be set.
  29497. * @returns this effect.
  29498. */
  29499. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  29500. /**
  29501. * Sets a Color4 on a uniform variable
  29502. * @param uniformName defines the name of the variable
  29503. * @param color4 defines the value to be set
  29504. * @returns this effect.
  29505. */
  29506. setDirectColor4(uniformName: string, color4: Color4): Effect;
  29507. /**
  29508. * This function will add a new shader to the shader store
  29509. * @param name the name of the shader
  29510. * @param pixelShader optional pixel shader content
  29511. * @param vertexShader optional vertex shader content
  29512. */
  29513. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  29514. /**
  29515. * Store of each shader (The can be looked up using effect.key)
  29516. */
  29517. static ShadersStore: {
  29518. [key: string]: string;
  29519. };
  29520. /**
  29521. * Store of each included file for a shader (The can be looked up using effect.key)
  29522. */
  29523. static IncludesShadersStore: {
  29524. [key: string]: string;
  29525. };
  29526. /**
  29527. * Resets the cache of effects.
  29528. */
  29529. static ResetCache(): void;
  29530. }
  29531. }
  29532. declare module "babylonjs/Materials/colorCurves" {
  29533. import { Effect } from "babylonjs/Materials/effect";
  29534. /**
  29535. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  29536. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  29537. * 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;
  29538. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  29539. */
  29540. export class ColorCurves {
  29541. private _dirty;
  29542. private _tempColor;
  29543. private _globalCurve;
  29544. private _highlightsCurve;
  29545. private _midtonesCurve;
  29546. private _shadowsCurve;
  29547. private _positiveCurve;
  29548. private _negativeCurve;
  29549. private _globalHue;
  29550. private _globalDensity;
  29551. private _globalSaturation;
  29552. private _globalExposure;
  29553. /**
  29554. * Gets the global Hue value.
  29555. * 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).
  29556. */
  29557. /**
  29558. * Sets the global Hue value.
  29559. * 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).
  29560. */
  29561. globalHue: number;
  29562. /**
  29563. * Gets the global Density value.
  29564. * 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.
  29565. * Values less than zero provide a filter of opposite hue.
  29566. */
  29567. /**
  29568. * Sets the global Density value.
  29569. * 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.
  29570. * Values less than zero provide a filter of opposite hue.
  29571. */
  29572. globalDensity: number;
  29573. /**
  29574. * Gets the global Saturation value.
  29575. * 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.
  29576. */
  29577. /**
  29578. * Sets the global Saturation value.
  29579. * 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.
  29580. */
  29581. globalSaturation: number;
  29582. /**
  29583. * Gets the global Exposure value.
  29584. * 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.
  29585. */
  29586. /**
  29587. * Sets the global Exposure value.
  29588. * 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.
  29589. */
  29590. globalExposure: number;
  29591. private _highlightsHue;
  29592. private _highlightsDensity;
  29593. private _highlightsSaturation;
  29594. private _highlightsExposure;
  29595. /**
  29596. * Gets the highlights Hue value.
  29597. * 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).
  29598. */
  29599. /**
  29600. * Sets the highlights Hue value.
  29601. * 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).
  29602. */
  29603. highlightsHue: number;
  29604. /**
  29605. * Gets the highlights Density value.
  29606. * 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.
  29607. * Values less than zero provide a filter of opposite hue.
  29608. */
  29609. /**
  29610. * Sets the highlights Density value.
  29611. * 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.
  29612. * Values less than zero provide a filter of opposite hue.
  29613. */
  29614. highlightsDensity: number;
  29615. /**
  29616. * Gets the highlights Saturation value.
  29617. * 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.
  29618. */
  29619. /**
  29620. * Sets the highlights Saturation value.
  29621. * 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.
  29622. */
  29623. highlightsSaturation: number;
  29624. /**
  29625. * Gets the highlights Exposure value.
  29626. * 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.
  29627. */
  29628. /**
  29629. * Sets the highlights Exposure value.
  29630. * 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.
  29631. */
  29632. highlightsExposure: number;
  29633. private _midtonesHue;
  29634. private _midtonesDensity;
  29635. private _midtonesSaturation;
  29636. private _midtonesExposure;
  29637. /**
  29638. * Gets the midtones Hue value.
  29639. * 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).
  29640. */
  29641. /**
  29642. * Sets the midtones Hue value.
  29643. * 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).
  29644. */
  29645. midtonesHue: number;
  29646. /**
  29647. * Gets the midtones Density value.
  29648. * 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.
  29649. * Values less than zero provide a filter of opposite hue.
  29650. */
  29651. /**
  29652. * Sets the midtones Density value.
  29653. * 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.
  29654. * Values less than zero provide a filter of opposite hue.
  29655. */
  29656. midtonesDensity: number;
  29657. /**
  29658. * Gets the midtones Saturation value.
  29659. * 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.
  29660. */
  29661. /**
  29662. * Sets the midtones Saturation value.
  29663. * 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.
  29664. */
  29665. midtonesSaturation: number;
  29666. /**
  29667. * Gets the midtones Exposure value.
  29668. * 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.
  29669. */
  29670. /**
  29671. * Sets the midtones Exposure value.
  29672. * 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.
  29673. */
  29674. midtonesExposure: number;
  29675. private _shadowsHue;
  29676. private _shadowsDensity;
  29677. private _shadowsSaturation;
  29678. private _shadowsExposure;
  29679. /**
  29680. * Gets the shadows Hue value.
  29681. * 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).
  29682. */
  29683. /**
  29684. * Sets the shadows Hue value.
  29685. * 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).
  29686. */
  29687. shadowsHue: number;
  29688. /**
  29689. * Gets the shadows Density value.
  29690. * 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.
  29691. * Values less than zero provide a filter of opposite hue.
  29692. */
  29693. /**
  29694. * Sets the shadows Density value.
  29695. * 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.
  29696. * Values less than zero provide a filter of opposite hue.
  29697. */
  29698. shadowsDensity: number;
  29699. /**
  29700. * Gets the shadows Saturation value.
  29701. * 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.
  29702. */
  29703. /**
  29704. * Sets the shadows Saturation value.
  29705. * 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.
  29706. */
  29707. shadowsSaturation: number;
  29708. /**
  29709. * Gets the shadows Exposure value.
  29710. * 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.
  29711. */
  29712. /**
  29713. * Sets the shadows Exposure value.
  29714. * 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.
  29715. */
  29716. shadowsExposure: number;
  29717. /**
  29718. * Returns the class name
  29719. * @returns The class name
  29720. */
  29721. getClassName(): string;
  29722. /**
  29723. * Binds the color curves to the shader.
  29724. * @param colorCurves The color curve to bind
  29725. * @param effect The effect to bind to
  29726. * @param positiveUniform The positive uniform shader parameter
  29727. * @param neutralUniform The neutral uniform shader parameter
  29728. * @param negativeUniform The negative uniform shader parameter
  29729. */
  29730. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  29731. /**
  29732. * Prepare the list of uniforms associated with the ColorCurves effects.
  29733. * @param uniformsList The list of uniforms used in the effect
  29734. */
  29735. static PrepareUniforms(uniformsList: string[]): void;
  29736. /**
  29737. * Returns color grading data based on a hue, density, saturation and exposure value.
  29738. * @param filterHue The hue of the color filter.
  29739. * @param filterDensity The density of the color filter.
  29740. * @param saturation The saturation.
  29741. * @param exposure The exposure.
  29742. * @param result The result data container.
  29743. */
  29744. private getColorGradingDataToRef;
  29745. /**
  29746. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  29747. * @param value The input slider value in range [-100,100].
  29748. * @returns Adjusted value.
  29749. */
  29750. private static applyColorGradingSliderNonlinear;
  29751. /**
  29752. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  29753. * @param hue The hue (H) input.
  29754. * @param saturation The saturation (S) input.
  29755. * @param brightness The brightness (B) input.
  29756. * @result An RGBA color represented as Vector4.
  29757. */
  29758. private static fromHSBToRef;
  29759. /**
  29760. * Returns a value clamped between min and max
  29761. * @param value The value to clamp
  29762. * @param min The minimum of value
  29763. * @param max The maximum of value
  29764. * @returns The clamped value.
  29765. */
  29766. private static clamp;
  29767. /**
  29768. * Clones the current color curve instance.
  29769. * @return The cloned curves
  29770. */
  29771. clone(): ColorCurves;
  29772. /**
  29773. * Serializes the current color curve instance to a json representation.
  29774. * @return a JSON representation
  29775. */
  29776. serialize(): any;
  29777. /**
  29778. * Parses the color curve from a json representation.
  29779. * @param source the JSON source to parse
  29780. * @return The parsed curves
  29781. */
  29782. static Parse(source: any): ColorCurves;
  29783. }
  29784. }
  29785. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  29786. import { Observable } from "babylonjs/Misc/observable";
  29787. import { Nullable } from "babylonjs/types";
  29788. import { Color4 } from "babylonjs/Maths/math";
  29789. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  29790. import { Effect } from "babylonjs/Materials/effect";
  29791. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  29792. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  29793. /**
  29794. * Interface to follow in your material defines to integrate easily the
  29795. * Image proccessing functions.
  29796. * @hidden
  29797. */
  29798. export interface IImageProcessingConfigurationDefines {
  29799. IMAGEPROCESSING: boolean;
  29800. VIGNETTE: boolean;
  29801. VIGNETTEBLENDMODEMULTIPLY: boolean;
  29802. VIGNETTEBLENDMODEOPAQUE: boolean;
  29803. TONEMAPPING: boolean;
  29804. TONEMAPPING_ACES: boolean;
  29805. CONTRAST: boolean;
  29806. EXPOSURE: boolean;
  29807. COLORCURVES: boolean;
  29808. COLORGRADING: boolean;
  29809. COLORGRADING3D: boolean;
  29810. SAMPLER3DGREENDEPTH: boolean;
  29811. SAMPLER3DBGRMAP: boolean;
  29812. IMAGEPROCESSINGPOSTPROCESS: boolean;
  29813. }
  29814. /**
  29815. * @hidden
  29816. */
  29817. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  29818. IMAGEPROCESSING: boolean;
  29819. VIGNETTE: boolean;
  29820. VIGNETTEBLENDMODEMULTIPLY: boolean;
  29821. VIGNETTEBLENDMODEOPAQUE: boolean;
  29822. TONEMAPPING: boolean;
  29823. TONEMAPPING_ACES: boolean;
  29824. CONTRAST: boolean;
  29825. COLORCURVES: boolean;
  29826. COLORGRADING: boolean;
  29827. COLORGRADING3D: boolean;
  29828. SAMPLER3DGREENDEPTH: boolean;
  29829. SAMPLER3DBGRMAP: boolean;
  29830. IMAGEPROCESSINGPOSTPROCESS: boolean;
  29831. EXPOSURE: boolean;
  29832. constructor();
  29833. }
  29834. /**
  29835. * This groups together the common properties used for image processing either in direct forward pass
  29836. * or through post processing effect depending on the use of the image processing pipeline in your scene
  29837. * or not.
  29838. */
  29839. export class ImageProcessingConfiguration {
  29840. /**
  29841. * Default tone mapping applied in BabylonJS.
  29842. */
  29843. static readonly TONEMAPPING_STANDARD: number;
  29844. /**
  29845. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  29846. * to other engines rendering to increase portability.
  29847. */
  29848. static readonly TONEMAPPING_ACES: number;
  29849. /**
  29850. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  29851. */
  29852. colorCurves: Nullable<ColorCurves>;
  29853. private _colorCurvesEnabled;
  29854. /**
  29855. * Gets wether the color curves effect is enabled.
  29856. */
  29857. /**
  29858. * Sets wether the color curves effect is enabled.
  29859. */
  29860. colorCurvesEnabled: boolean;
  29861. private _colorGradingTexture;
  29862. /**
  29863. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  29864. */
  29865. /**
  29866. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  29867. */
  29868. colorGradingTexture: Nullable<BaseTexture>;
  29869. private _colorGradingEnabled;
  29870. /**
  29871. * Gets wether the color grading effect is enabled.
  29872. */
  29873. /**
  29874. * Sets wether the color grading effect is enabled.
  29875. */
  29876. colorGradingEnabled: boolean;
  29877. private _colorGradingWithGreenDepth;
  29878. /**
  29879. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  29880. */
  29881. /**
  29882. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  29883. */
  29884. colorGradingWithGreenDepth: boolean;
  29885. private _colorGradingBGR;
  29886. /**
  29887. * Gets wether the color grading texture contains BGR values.
  29888. */
  29889. /**
  29890. * Sets wether the color grading texture contains BGR values.
  29891. */
  29892. colorGradingBGR: boolean;
  29893. /** @hidden */
  29894. _exposure: number;
  29895. /**
  29896. * Gets the Exposure used in the effect.
  29897. */
  29898. /**
  29899. * Sets the Exposure used in the effect.
  29900. */
  29901. exposure: number;
  29902. private _toneMappingEnabled;
  29903. /**
  29904. * Gets wether the tone mapping effect is enabled.
  29905. */
  29906. /**
  29907. * Sets wether the tone mapping effect is enabled.
  29908. */
  29909. toneMappingEnabled: boolean;
  29910. private _toneMappingType;
  29911. /**
  29912. * Gets the type of tone mapping effect.
  29913. */
  29914. /**
  29915. * Sets the type of tone mapping effect used in BabylonJS.
  29916. */
  29917. toneMappingType: number;
  29918. protected _contrast: number;
  29919. /**
  29920. * Gets the contrast used in the effect.
  29921. */
  29922. /**
  29923. * Sets the contrast used in the effect.
  29924. */
  29925. contrast: number;
  29926. /**
  29927. * Vignette stretch size.
  29928. */
  29929. vignetteStretch: number;
  29930. /**
  29931. * Vignette centre X Offset.
  29932. */
  29933. vignetteCentreX: number;
  29934. /**
  29935. * Vignette centre Y Offset.
  29936. */
  29937. vignetteCentreY: number;
  29938. /**
  29939. * Vignette weight or intensity of the vignette effect.
  29940. */
  29941. vignetteWeight: number;
  29942. /**
  29943. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  29944. * if vignetteEnabled is set to true.
  29945. */
  29946. vignetteColor: Color4;
  29947. /**
  29948. * Camera field of view used by the Vignette effect.
  29949. */
  29950. vignetteCameraFov: number;
  29951. private _vignetteBlendMode;
  29952. /**
  29953. * Gets the vignette blend mode allowing different kind of effect.
  29954. */
  29955. /**
  29956. * Sets the vignette blend mode allowing different kind of effect.
  29957. */
  29958. vignetteBlendMode: number;
  29959. private _vignetteEnabled;
  29960. /**
  29961. * Gets wether the vignette effect is enabled.
  29962. */
  29963. /**
  29964. * Sets wether the vignette effect is enabled.
  29965. */
  29966. vignetteEnabled: boolean;
  29967. private _applyByPostProcess;
  29968. /**
  29969. * Gets wether the image processing is applied through a post process or not.
  29970. */
  29971. /**
  29972. * Sets wether the image processing is applied through a post process or not.
  29973. */
  29974. applyByPostProcess: boolean;
  29975. private _isEnabled;
  29976. /**
  29977. * Gets wether the image processing is enabled or not.
  29978. */
  29979. /**
  29980. * Sets wether the image processing is enabled or not.
  29981. */
  29982. isEnabled: boolean;
  29983. /**
  29984. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  29985. */
  29986. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  29987. /**
  29988. * Method called each time the image processing information changes requires to recompile the effect.
  29989. */
  29990. protected _updateParameters(): void;
  29991. /**
  29992. * Gets the current class name.
  29993. * @return "ImageProcessingConfiguration"
  29994. */
  29995. getClassName(): string;
  29996. /**
  29997. * Prepare the list of uniforms associated with the Image Processing effects.
  29998. * @param uniforms The list of uniforms used in the effect
  29999. * @param defines the list of defines currently in use
  30000. */
  30001. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  30002. /**
  30003. * Prepare the list of samplers associated with the Image Processing effects.
  30004. * @param samplersList The list of uniforms used in the effect
  30005. * @param defines the list of defines currently in use
  30006. */
  30007. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  30008. /**
  30009. * Prepare the list of defines associated to the shader.
  30010. * @param defines the list of defines to complete
  30011. * @param forPostProcess Define if we are currently in post process mode or not
  30012. */
  30013. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  30014. /**
  30015. * Returns true if all the image processing information are ready.
  30016. * @returns True if ready, otherwise, false
  30017. */
  30018. isReady(): boolean;
  30019. /**
  30020. * Binds the image processing to the shader.
  30021. * @param effect The effect to bind to
  30022. * @param aspectRatio Define the current aspect ratio of the effect
  30023. */
  30024. bind(effect: Effect, aspectRatio?: number): void;
  30025. /**
  30026. * Clones the current image processing instance.
  30027. * @return The cloned image processing
  30028. */
  30029. clone(): ImageProcessingConfiguration;
  30030. /**
  30031. * Serializes the current image processing instance to a json representation.
  30032. * @return a JSON representation
  30033. */
  30034. serialize(): any;
  30035. /**
  30036. * Parses the image processing from a json representation.
  30037. * @param source the JSON source to parse
  30038. * @return The parsed image processing
  30039. */
  30040. static Parse(source: any): ImageProcessingConfiguration;
  30041. private static _VIGNETTEMODE_MULTIPLY;
  30042. private static _VIGNETTEMODE_OPAQUE;
  30043. /**
  30044. * Used to apply the vignette as a mix with the pixel color.
  30045. */
  30046. static readonly VIGNETTEMODE_MULTIPLY: number;
  30047. /**
  30048. * Used to apply the vignette as a replacement of the pixel color.
  30049. */
  30050. static readonly VIGNETTEMODE_OPAQUE: number;
  30051. }
  30052. }
  30053. declare module "babylonjs/Materials/fresnelParameters" {
  30054. import { Color3 } from "babylonjs/Maths/math";
  30055. /**
  30056. * This represents all the required information to add a fresnel effect on a material:
  30057. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30058. */
  30059. export class FresnelParameters {
  30060. private _isEnabled;
  30061. /**
  30062. * Define if the fresnel effect is enable or not.
  30063. */
  30064. isEnabled: boolean;
  30065. /**
  30066. * Define the color used on edges (grazing angle)
  30067. */
  30068. leftColor: Color3;
  30069. /**
  30070. * Define the color used on center
  30071. */
  30072. rightColor: Color3;
  30073. /**
  30074. * Define bias applied to computed fresnel term
  30075. */
  30076. bias: number;
  30077. /**
  30078. * Defined the power exponent applied to fresnel term
  30079. */
  30080. power: number;
  30081. /**
  30082. * Clones the current fresnel and its valuues
  30083. * @returns a clone fresnel configuration
  30084. */
  30085. clone(): FresnelParameters;
  30086. /**
  30087. * Serializes the current fresnel parameters to a JSON representation.
  30088. * @return the JSON serialization
  30089. */
  30090. serialize(): any;
  30091. /**
  30092. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  30093. * @param parsedFresnelParameters Define the JSON representation
  30094. * @returns the parsed parameters
  30095. */
  30096. static Parse(parsedFresnelParameters: any): FresnelParameters;
  30097. }
  30098. }
  30099. declare module "babylonjs/Misc/decorators" {
  30100. import { Nullable } from "babylonjs/types";
  30101. import { Scene } from "babylonjs/scene";
  30102. import { IAnimatable } from "babylonjs/Misc/tools";
  30103. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  30104. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30105. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30106. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30107. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30108. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30109. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30110. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30111. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30112. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30113. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30114. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30115. /**
  30116. * Decorator used to define property that can be serialized as reference to a camera
  30117. * @param sourceName defines the name of the property to decorate
  30118. */
  30119. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30120. /**
  30121. * Class used to help serialization objects
  30122. */
  30123. export class SerializationHelper {
  30124. /** hidden */
  30125. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  30126. /** hidden */
  30127. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  30128. /** hidden */
  30129. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  30130. /** hidden */
  30131. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  30132. /**
  30133. * Appends the serialized animations from the source animations
  30134. * @param source Source containing the animations
  30135. * @param destination Target to store the animations
  30136. */
  30137. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30138. /**
  30139. * Static function used to serialized a specific entity
  30140. * @param entity defines the entity to serialize
  30141. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  30142. * @returns a JSON compatible object representing the serialization of the entity
  30143. */
  30144. static Serialize<T>(entity: T, serializationObject?: any): any;
  30145. /**
  30146. * Creates a new entity from a serialization data object
  30147. * @param creationFunction defines a function used to instanciated the new entity
  30148. * @param source defines the source serialization data
  30149. * @param scene defines the hosting scene
  30150. * @param rootUrl defines the root url for resources
  30151. * @returns a new entity
  30152. */
  30153. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  30154. /**
  30155. * Clones an object
  30156. * @param creationFunction defines the function used to instanciate the new object
  30157. * @param source defines the source object
  30158. * @returns the cloned object
  30159. */
  30160. static Clone<T>(creationFunction: () => T, source: T): T;
  30161. /**
  30162. * Instanciates a new object based on a source one (some data will be shared between both object)
  30163. * @param creationFunction defines the function used to instanciate the new object
  30164. * @param source defines the source object
  30165. * @returns the new object
  30166. */
  30167. static Instanciate<T>(creationFunction: () => T, source: T): T;
  30168. }
  30169. }
  30170. declare module "babylonjs/Cameras/camera" {
  30171. import { SmartArray } from "babylonjs/Misc/smartArray";
  30172. import { Observable } from "babylonjs/Misc/observable";
  30173. import { Nullable } from "babylonjs/types";
  30174. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  30175. import { Scene } from "babylonjs/scene";
  30176. import { Matrix, Vector3, Viewport } from "babylonjs/Maths/math";
  30177. import { Node } from "babylonjs/node";
  30178. import { Mesh } from "babylonjs/Meshes/mesh";
  30179. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  30180. import { ICullable } from "babylonjs/Culling/boundingInfo";
  30181. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  30182. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30183. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  30184. import { Ray } from "babylonjs/Culling/ray";
  30185. /**
  30186. * This is the base class of all the camera used in the application.
  30187. * @see http://doc.babylonjs.com/features/cameras
  30188. */
  30189. export class Camera extends Node {
  30190. /** @hidden */
  30191. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  30192. /**
  30193. * This is the default projection mode used by the cameras.
  30194. * It helps recreating a feeling of perspective and better appreciate depth.
  30195. * This is the best way to simulate real life cameras.
  30196. */
  30197. static readonly PERSPECTIVE_CAMERA: number;
  30198. /**
  30199. * This helps creating camera with an orthographic mode.
  30200. * 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.
  30201. */
  30202. static readonly ORTHOGRAPHIC_CAMERA: number;
  30203. /**
  30204. * This is the default FOV mode for perspective cameras.
  30205. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  30206. */
  30207. static readonly FOVMODE_VERTICAL_FIXED: number;
  30208. /**
  30209. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  30210. */
  30211. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  30212. /**
  30213. * This specifies ther is no need for a camera rig.
  30214. * Basically only one eye is rendered corresponding to the camera.
  30215. */
  30216. static readonly RIG_MODE_NONE: number;
  30217. /**
  30218. * Simulates a camera Rig with one blue eye and one red eye.
  30219. * This can be use with 3d blue and red glasses.
  30220. */
  30221. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  30222. /**
  30223. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  30224. */
  30225. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  30226. /**
  30227. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  30228. */
  30229. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  30230. /**
  30231. * Defines that both eyes of the camera will be rendered over under each other.
  30232. */
  30233. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  30234. /**
  30235. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  30236. */
  30237. static readonly RIG_MODE_VR: number;
  30238. /**
  30239. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  30240. */
  30241. static readonly RIG_MODE_WEBVR: number;
  30242. /**
  30243. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  30244. */
  30245. static readonly RIG_MODE_CUSTOM: number;
  30246. /**
  30247. * Defines if by default attaching controls should prevent the default javascript event to continue.
  30248. */
  30249. static ForceAttachControlToAlwaysPreventDefault: boolean;
  30250. /**
  30251. * @hidden
  30252. * Might be removed once multiview will be a thing
  30253. */
  30254. static UseAlternateWebVRRendering: boolean;
  30255. /**
  30256. * Define the input manager associated with the camera.
  30257. */
  30258. inputs: CameraInputsManager<Camera>;
  30259. /** @hidden */
  30260. _position: Vector3;
  30261. /**
  30262. * Define the current local position of the camera in the scene
  30263. */
  30264. position: Vector3;
  30265. /**
  30266. * The vector the camera should consider as up.
  30267. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  30268. */
  30269. upVector: Vector3;
  30270. /**
  30271. * Define the current limit on the left side for an orthographic camera
  30272. * In scene unit
  30273. */
  30274. orthoLeft: Nullable<number>;
  30275. /**
  30276. * Define the current limit on the right side for an orthographic camera
  30277. * In scene unit
  30278. */
  30279. orthoRight: Nullable<number>;
  30280. /**
  30281. * Define the current limit on the bottom side for an orthographic camera
  30282. * In scene unit
  30283. */
  30284. orthoBottom: Nullable<number>;
  30285. /**
  30286. * Define the current limit on the top side for an orthographic camera
  30287. * In scene unit
  30288. */
  30289. orthoTop: Nullable<number>;
  30290. /**
  30291. * Field Of View is set in Radians. (default is 0.8)
  30292. */
  30293. fov: number;
  30294. /**
  30295. * Define the minimum distance the camera can see from.
  30296. * This is important to note that the depth buffer are not infinite and the closer it starts
  30297. * the more your scene might encounter depth fighting issue.
  30298. */
  30299. minZ: number;
  30300. /**
  30301. * Define the maximum distance the camera can see to.
  30302. * This is important to note that the depth buffer are not infinite and the further it end
  30303. * the more your scene might encounter depth fighting issue.
  30304. */
  30305. maxZ: number;
  30306. /**
  30307. * Define the default inertia of the camera.
  30308. * This helps giving a smooth feeling to the camera movement.
  30309. */
  30310. inertia: number;
  30311. /**
  30312. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  30313. */
  30314. mode: number;
  30315. /**
  30316. * Define wether the camera is intermediate.
  30317. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  30318. */
  30319. isIntermediate: boolean;
  30320. /**
  30321. * Define the viewport of the camera.
  30322. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  30323. */
  30324. viewport: Viewport;
  30325. /**
  30326. * Restricts the camera to viewing objects with the same layerMask.
  30327. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  30328. */
  30329. layerMask: number;
  30330. /**
  30331. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  30332. */
  30333. fovMode: number;
  30334. /**
  30335. * Rig mode of the camera.
  30336. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  30337. * This is normally controlled byt the camera themselves as internal use.
  30338. */
  30339. cameraRigMode: number;
  30340. /**
  30341. * Defines the distance between both "eyes" in case of a RIG
  30342. */
  30343. interaxialDistance: number;
  30344. /**
  30345. * Defines if stereoscopic rendering is done side by side or over under.
  30346. */
  30347. isStereoscopicSideBySide: boolean;
  30348. /**
  30349. * 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
  30350. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  30351. * else in the scene.
  30352. */
  30353. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  30354. /**
  30355. * When set, the camera will render to this render target instead of the default canvas
  30356. */
  30357. outputRenderTarget: Nullable<RenderTargetTexture>;
  30358. /**
  30359. * Observable triggered when the camera view matrix has changed.
  30360. */
  30361. onViewMatrixChangedObservable: Observable<Camera>;
  30362. /**
  30363. * Observable triggered when the camera Projection matrix has changed.
  30364. */
  30365. onProjectionMatrixChangedObservable: Observable<Camera>;
  30366. /**
  30367. * Observable triggered when the inputs have been processed.
  30368. */
  30369. onAfterCheckInputsObservable: Observable<Camera>;
  30370. /**
  30371. * Observable triggered when reset has been called and applied to the camera.
  30372. */
  30373. onRestoreStateObservable: Observable<Camera>;
  30374. /** @hidden */
  30375. _cameraRigParams: any;
  30376. /** @hidden */
  30377. _rigCameras: Camera[];
  30378. /** @hidden */
  30379. _rigPostProcess: Nullable<PostProcess>;
  30380. protected _webvrViewMatrix: Matrix;
  30381. /** @hidden */
  30382. _skipRendering: boolean;
  30383. /** @hidden */
  30384. _alternateCamera: Camera;
  30385. /** @hidden */
  30386. _projectionMatrix: Matrix;
  30387. /** @hidden */
  30388. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  30389. /** @hidden */
  30390. _activeMeshes: SmartArray<AbstractMesh>;
  30391. protected _globalPosition: Vector3;
  30392. /** hidden */
  30393. _computedViewMatrix: Matrix;
  30394. private _doNotComputeProjectionMatrix;
  30395. private _transformMatrix;
  30396. private _frustumPlanes;
  30397. private _refreshFrustumPlanes;
  30398. private _storedFov;
  30399. private _stateStored;
  30400. /**
  30401. * Instantiates a new camera object.
  30402. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  30403. * @see http://doc.babylonjs.com/features/cameras
  30404. * @param name Defines the name of the camera in the scene
  30405. * @param position Defines the position of the camera
  30406. * @param scene Defines the scene the camera belongs too
  30407. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  30408. */
  30409. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  30410. /**
  30411. * Store current camera state (fov, position, etc..)
  30412. * @returns the camera
  30413. */
  30414. storeState(): Camera;
  30415. /**
  30416. * Restores the camera state values if it has been stored. You must call storeState() first
  30417. */
  30418. protected _restoreStateValues(): boolean;
  30419. /**
  30420. * Restored camera state. You must call storeState() first.
  30421. * @returns true if restored and false otherwise
  30422. */
  30423. restoreState(): boolean;
  30424. /**
  30425. * Gets the class name of the camera.
  30426. * @returns the class name
  30427. */
  30428. getClassName(): string;
  30429. /** @hidden */
  30430. readonly _isCamera: boolean;
  30431. /**
  30432. * Gets a string representation of the camera useful for debug purpose.
  30433. * @param fullDetails Defines that a more verboe level of logging is required
  30434. * @returns the string representation
  30435. */
  30436. toString(fullDetails?: boolean): string;
  30437. /**
  30438. * Gets the current world space position of the camera.
  30439. */
  30440. readonly globalPosition: Vector3;
  30441. /**
  30442. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  30443. * @returns the active meshe list
  30444. */
  30445. getActiveMeshes(): SmartArray<AbstractMesh>;
  30446. /**
  30447. * Check wether a mesh is part of the current active mesh list of the camera
  30448. * @param mesh Defines the mesh to check
  30449. * @returns true if active, false otherwise
  30450. */
  30451. isActiveMesh(mesh: Mesh): boolean;
  30452. /**
  30453. * Is this camera ready to be used/rendered
  30454. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  30455. * @return true if the camera is ready
  30456. */
  30457. isReady(completeCheck?: boolean): boolean;
  30458. /** @hidden */
  30459. _initCache(): void;
  30460. /** @hidden */
  30461. _updateCache(ignoreParentClass?: boolean): void;
  30462. /** @hidden */
  30463. _isSynchronized(): boolean;
  30464. /** @hidden */
  30465. _isSynchronizedViewMatrix(): boolean;
  30466. /** @hidden */
  30467. _isSynchronizedProjectionMatrix(): boolean;
  30468. /**
  30469. * Attach the input controls to a specific dom element to get the input from.
  30470. * @param element Defines the element the controls should be listened from
  30471. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  30472. */
  30473. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  30474. /**
  30475. * Detach the current controls from the specified dom element.
  30476. * @param element Defines the element to stop listening the inputs from
  30477. */
  30478. detachControl(element: HTMLElement): void;
  30479. /**
  30480. * Update the camera state according to the different inputs gathered during the frame.
  30481. */
  30482. update(): void;
  30483. /** @hidden */
  30484. _checkInputs(): void;
  30485. /** @hidden */
  30486. readonly rigCameras: Camera[];
  30487. /**
  30488. * Gets the post process used by the rig cameras
  30489. */
  30490. readonly rigPostProcess: Nullable<PostProcess>;
  30491. /**
  30492. * Internal, gets the first post proces.
  30493. * @returns the first post process to be run on this camera.
  30494. */
  30495. _getFirstPostProcess(): Nullable<PostProcess>;
  30496. private _cascadePostProcessesToRigCams;
  30497. /**
  30498. * Attach a post process to the camera.
  30499. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  30500. * @param postProcess The post process to attach to the camera
  30501. * @param insertAt The position of the post process in case several of them are in use in the scene
  30502. * @returns the position the post process has been inserted at
  30503. */
  30504. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  30505. /**
  30506. * Detach a post process to the camera.
  30507. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  30508. * @param postProcess The post process to detach from the camera
  30509. */
  30510. detachPostProcess(postProcess: PostProcess): void;
  30511. /**
  30512. * Gets the current world matrix of the camera
  30513. */
  30514. getWorldMatrix(): Matrix;
  30515. /** @hidden */
  30516. _getViewMatrix(): Matrix;
  30517. /**
  30518. * Gets the current view matrix of the camera.
  30519. * @param force forces the camera to recompute the matrix without looking at the cached state
  30520. * @returns the view matrix
  30521. */
  30522. getViewMatrix(force?: boolean): Matrix;
  30523. /**
  30524. * Freeze the projection matrix.
  30525. * It will prevent the cache check of the camera projection compute and can speed up perf
  30526. * if no parameter of the camera are meant to change
  30527. * @param projection Defines manually a projection if necessary
  30528. */
  30529. freezeProjectionMatrix(projection?: Matrix): void;
  30530. /**
  30531. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  30532. */
  30533. unfreezeProjectionMatrix(): void;
  30534. /**
  30535. * Gets the current projection matrix of the camera.
  30536. * @param force forces the camera to recompute the matrix without looking at the cached state
  30537. * @returns the projection matrix
  30538. */
  30539. getProjectionMatrix(force?: boolean): Matrix;
  30540. /**
  30541. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  30542. * @returns a Matrix
  30543. */
  30544. getTransformationMatrix(): Matrix;
  30545. private _updateFrustumPlanes;
  30546. /**
  30547. * Checks if a cullable object (mesh...) is in the camera frustum
  30548. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  30549. * @param target The object to check
  30550. * @returns true if the object is in frustum otherwise false
  30551. */
  30552. isInFrustum(target: ICullable): boolean;
  30553. /**
  30554. * Checks if a cullable object (mesh...) is in the camera frustum
  30555. * Unlike isInFrustum this cheks the full bounding box
  30556. * @param target The object to check
  30557. * @returns true if the object is in frustum otherwise false
  30558. */
  30559. isCompletelyInFrustum(target: ICullable): boolean;
  30560. /**
  30561. * Gets a ray in the forward direction from the camera.
  30562. * @param length Defines the length of the ray to create
  30563. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  30564. * @param origin Defines the start point of the ray which defaults to the camera position
  30565. * @returns the forward ray
  30566. */
  30567. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  30568. /**
  30569. * Releases resources associated with this node.
  30570. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  30571. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  30572. */
  30573. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  30574. /** @hidden */
  30575. _isLeftCamera: boolean;
  30576. /**
  30577. * Gets the left camera of a rig setup in case of Rigged Camera
  30578. */
  30579. readonly isLeftCamera: boolean;
  30580. /** @hidden */
  30581. _isRightCamera: boolean;
  30582. /**
  30583. * Gets the right camera of a rig setup in case of Rigged Camera
  30584. */
  30585. readonly isRightCamera: boolean;
  30586. /**
  30587. * Gets the left camera of a rig setup in case of Rigged Camera
  30588. */
  30589. readonly leftCamera: Nullable<FreeCamera>;
  30590. /**
  30591. * Gets the right camera of a rig setup in case of Rigged Camera
  30592. */
  30593. readonly rightCamera: Nullable<FreeCamera>;
  30594. /**
  30595. * Gets the left camera target of a rig setup in case of Rigged Camera
  30596. * @returns the target position
  30597. */
  30598. getLeftTarget(): Nullable<Vector3>;
  30599. /**
  30600. * Gets the right camera target of a rig setup in case of Rigged Camera
  30601. * @returns the target position
  30602. */
  30603. getRightTarget(): Nullable<Vector3>;
  30604. /**
  30605. * @hidden
  30606. */
  30607. setCameraRigMode(mode: number, rigParams: any): void;
  30608. /** @hidden */
  30609. static _setStereoscopicRigMode(camera: Camera): void;
  30610. /** @hidden */
  30611. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  30612. /** @hidden */
  30613. static _setVRRigMode(camera: Camera, rigParams: any): void;
  30614. /** @hidden */
  30615. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  30616. /** @hidden */
  30617. _getVRProjectionMatrix(): Matrix;
  30618. protected _updateCameraRotationMatrix(): void;
  30619. protected _updateWebVRCameraRotationMatrix(): void;
  30620. /**
  30621. * This function MUST be overwritten by the different WebVR cameras available.
  30622. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30623. * @hidden
  30624. */
  30625. _getWebVRProjectionMatrix(): Matrix;
  30626. /**
  30627. * This function MUST be overwritten by the different WebVR cameras available.
  30628. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30629. * @hidden
  30630. */
  30631. _getWebVRViewMatrix(): Matrix;
  30632. /** @hidden */
  30633. setCameraRigParameter(name: string, value: any): void;
  30634. /**
  30635. * needs to be overridden by children so sub has required properties to be copied
  30636. * @hidden
  30637. */
  30638. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  30639. /**
  30640. * May need to be overridden by children
  30641. * @hidden
  30642. */
  30643. _updateRigCameras(): void;
  30644. /** @hidden */
  30645. _setupInputs(): void;
  30646. /**
  30647. * Serialiaze the camera setup to a json represention
  30648. * @returns the JSON representation
  30649. */
  30650. serialize(): any;
  30651. /**
  30652. * Clones the current camera.
  30653. * @param name The cloned camera name
  30654. * @returns the cloned camera
  30655. */
  30656. clone(name: string): Camera;
  30657. /**
  30658. * Gets the direction of the camera relative to a given local axis.
  30659. * @param localAxis Defines the reference axis to provide a relative direction.
  30660. * @return the direction
  30661. */
  30662. getDirection(localAxis: Vector3): Vector3;
  30663. /**
  30664. * Gets the direction of the camera relative to a given local axis into a passed vector.
  30665. * @param localAxis Defines the reference axis to provide a relative direction.
  30666. * @param result Defines the vector to store the result in
  30667. */
  30668. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  30669. /**
  30670. * Gets a camera constructor for a given camera type
  30671. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  30672. * @param name The name of the camera the result will be able to instantiate
  30673. * @param scene The scene the result will construct the camera in
  30674. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  30675. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  30676. * @returns a factory method to construc the camera
  30677. */
  30678. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  30679. /**
  30680. * Compute the world matrix of the camera.
  30681. * @returns the camera workd matrix
  30682. */
  30683. computeWorldMatrix(): Matrix;
  30684. /**
  30685. * Parse a JSON and creates the camera from the parsed information
  30686. * @param parsedCamera The JSON to parse
  30687. * @param scene The scene to instantiate the camera in
  30688. * @returns the newly constructed camera
  30689. */
  30690. static Parse(parsedCamera: any, scene: Scene): Camera;
  30691. }
  30692. }
  30693. declare module "babylonjs/Misc/tools" {
  30694. import { FloatArray, IndicesArray, Nullable } from "babylonjs/types";
  30695. import { Color4, Color3, Vector2, Vector3 } from "babylonjs/Maths/math";
  30696. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  30697. import { Observable } from "babylonjs/Misc/observable";
  30698. import { DomManagement } from "babylonjs/Misc/domManagement";
  30699. import { Camera } from "babylonjs/Cameras/camera";
  30700. import { Engine } from "babylonjs/Engines/engine";
  30701. import { Animation } from "babylonjs/Animations/animation";
  30702. /**
  30703. * Interface for any object that can request an animation frame
  30704. */
  30705. export interface ICustomAnimationFrameRequester {
  30706. /**
  30707. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  30708. */
  30709. renderFunction?: Function;
  30710. /**
  30711. * Called to request the next frame to render to
  30712. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  30713. */
  30714. requestAnimationFrame: Function;
  30715. /**
  30716. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  30717. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  30718. */
  30719. requestID?: number;
  30720. }
  30721. /**
  30722. * Interface containing an array of animations
  30723. */
  30724. export interface IAnimatable {
  30725. /**
  30726. * Array of animations
  30727. */
  30728. animations: Array<Animation>;
  30729. }
  30730. /** Interface used by value gradients (color, factor, ...) */
  30731. export interface IValueGradient {
  30732. /**
  30733. * Gets or sets the gradient value (between 0 and 1)
  30734. */
  30735. gradient: number;
  30736. }
  30737. /** Class used to store color4 gradient */
  30738. export class ColorGradient implements IValueGradient {
  30739. /**
  30740. * Gets or sets the gradient value (between 0 and 1)
  30741. */
  30742. gradient: number;
  30743. /**
  30744. * Gets or sets first associated color
  30745. */
  30746. color1: Color4;
  30747. /**
  30748. * Gets or sets second associated color
  30749. */
  30750. color2?: Color4;
  30751. /**
  30752. * Will get a color picked randomly between color1 and color2.
  30753. * If color2 is undefined then color1 will be used
  30754. * @param result defines the target Color4 to store the result in
  30755. */
  30756. getColorToRef(result: Color4): void;
  30757. }
  30758. /** Class used to store color 3 gradient */
  30759. export class Color3Gradient implements IValueGradient {
  30760. /**
  30761. * Gets or sets the gradient value (between 0 and 1)
  30762. */
  30763. gradient: number;
  30764. /**
  30765. * Gets or sets the associated color
  30766. */
  30767. color: Color3;
  30768. }
  30769. /** Class used to store factor gradient */
  30770. export class FactorGradient implements IValueGradient {
  30771. /**
  30772. * Gets or sets the gradient value (between 0 and 1)
  30773. */
  30774. gradient: number;
  30775. /**
  30776. * Gets or sets first associated factor
  30777. */
  30778. factor1: number;
  30779. /**
  30780. * Gets or sets second associated factor
  30781. */
  30782. factor2?: number;
  30783. /**
  30784. * Will get a number picked randomly between factor1 and factor2.
  30785. * If factor2 is undefined then factor1 will be used
  30786. * @returns the picked number
  30787. */
  30788. getFactor(): number;
  30789. }
  30790. /**
  30791. * @ignore
  30792. * Application error to support additional information when loading a file
  30793. */
  30794. export class LoadFileError extends Error {
  30795. /** defines the optional XHR request */
  30796. request?: XMLHttpRequest | undefined;
  30797. private static _setPrototypeOf;
  30798. /**
  30799. * Creates a new LoadFileError
  30800. * @param message defines the message of the error
  30801. * @param request defines the optional XHR request
  30802. */
  30803. constructor(message: string,
  30804. /** defines the optional XHR request */
  30805. request?: XMLHttpRequest | undefined);
  30806. }
  30807. /**
  30808. * Class used to define a retry strategy when error happens while loading assets
  30809. */
  30810. export class RetryStrategy {
  30811. /**
  30812. * Function used to defines an exponential back off strategy
  30813. * @param maxRetries defines the maximum number of retries (3 by default)
  30814. * @param baseInterval defines the interval between retries
  30815. * @returns the strategy function to use
  30816. */
  30817. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  30818. }
  30819. /**
  30820. * File request interface
  30821. */
  30822. export interface IFileRequest {
  30823. /**
  30824. * Raised when the request is complete (success or error).
  30825. */
  30826. onCompleteObservable: Observable<IFileRequest>;
  30827. /**
  30828. * Aborts the request for a file.
  30829. */
  30830. abort: () => void;
  30831. }
  30832. /**
  30833. * Class containing a set of static utilities functions
  30834. */
  30835. export class Tools {
  30836. /**
  30837. * Gets or sets the base URL to use to load assets
  30838. */
  30839. static BaseUrl: string;
  30840. /**
  30841. * Enable/Disable Custom HTTP Request Headers globally.
  30842. * default = false
  30843. * @see CustomRequestHeaders
  30844. */
  30845. static UseCustomRequestHeaders: boolean;
  30846. /**
  30847. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  30848. * i.e. when loading files, where the server/service expects an Authorization header
  30849. */
  30850. static CustomRequestHeaders: {
  30851. [key: string]: string;
  30852. };
  30853. /**
  30854. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  30855. */
  30856. static DefaultRetryStrategy: (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  30857. /**
  30858. * Default behaviour for cors in the application.
  30859. * It can be a string if the expected behavior is identical in the entire app.
  30860. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  30861. */
  30862. static CorsBehavior: string | ((url: string | string[]) => string);
  30863. /**
  30864. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  30865. * @ignorenaming
  30866. */
  30867. static UseFallbackTexture: boolean;
  30868. /**
  30869. * Use this object to register external classes like custom textures or material
  30870. * to allow the laoders to instantiate them
  30871. */
  30872. static RegisteredExternalClasses: {
  30873. [key: string]: Object;
  30874. };
  30875. /**
  30876. * Texture content used if a texture cannot loaded
  30877. * @ignorenaming
  30878. */
  30879. static fallbackTexture: string;
  30880. /**
  30881. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  30882. * @param u defines the coordinate on X axis
  30883. * @param v defines the coordinate on Y axis
  30884. * @param width defines the width of the source data
  30885. * @param height defines the height of the source data
  30886. * @param pixels defines the source byte array
  30887. * @param color defines the output color
  30888. */
  30889. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  30890. /**
  30891. * Interpolates between a and b via alpha
  30892. * @param a The lower value (returned when alpha = 0)
  30893. * @param b The upper value (returned when alpha = 1)
  30894. * @param alpha The interpolation-factor
  30895. * @return The mixed value
  30896. */
  30897. static Mix(a: number, b: number, alpha: number): number;
  30898. /**
  30899. * Tries to instantiate a new object from a given class name
  30900. * @param className defines the class name to instantiate
  30901. * @returns the new object or null if the system was not able to do the instantiation
  30902. */
  30903. static Instantiate(className: string): any;
  30904. /**
  30905. * Provides a slice function that will work even on IE
  30906. * @param data defines the array to slice
  30907. * @param start defines the start of the data (optional)
  30908. * @param end defines the end of the data (optional)
  30909. * @returns the new sliced array
  30910. */
  30911. static Slice<T>(data: T, start?: number, end?: number): T;
  30912. /**
  30913. * Polyfill for setImmediate
  30914. * @param action defines the action to execute after the current execution block
  30915. */
  30916. static SetImmediate(action: () => void): void;
  30917. /**
  30918. * Function indicating if a number is an exponent of 2
  30919. * @param value defines the value to test
  30920. * @returns true if the value is an exponent of 2
  30921. */
  30922. static IsExponentOfTwo(value: number): boolean;
  30923. private static _tmpFloatArray;
  30924. /**
  30925. * Returns the nearest 32-bit single precision float representation of a Number
  30926. * @param value A Number. If the parameter is of a different type, it will get converted
  30927. * to a number or to NaN if it cannot be converted
  30928. * @returns number
  30929. */
  30930. static FloatRound(value: number): number;
  30931. /**
  30932. * Find the next highest power of two.
  30933. * @param x Number to start search from.
  30934. * @return Next highest power of two.
  30935. */
  30936. static CeilingPOT(x: number): number;
  30937. /**
  30938. * Find the next lowest power of two.
  30939. * @param x Number to start search from.
  30940. * @return Next lowest power of two.
  30941. */
  30942. static FloorPOT(x: number): number;
  30943. /**
  30944. * Find the nearest power of two.
  30945. * @param x Number to start search from.
  30946. * @return Next nearest power of two.
  30947. */
  30948. static NearestPOT(x: number): number;
  30949. /**
  30950. * Get the closest exponent of two
  30951. * @param value defines the value to approximate
  30952. * @param max defines the maximum value to return
  30953. * @param mode defines how to define the closest value
  30954. * @returns closest exponent of two of the given value
  30955. */
  30956. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  30957. /**
  30958. * Extracts the filename from a path
  30959. * @param path defines the path to use
  30960. * @returns the filename
  30961. */
  30962. static GetFilename(path: string): string;
  30963. /**
  30964. * Extracts the "folder" part of a path (everything before the filename).
  30965. * @param uri The URI to extract the info from
  30966. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  30967. * @returns The "folder" part of the path
  30968. */
  30969. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  30970. /**
  30971. * Extracts text content from a DOM element hierarchy
  30972. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  30973. */
  30974. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  30975. /**
  30976. * Convert an angle in radians to degrees
  30977. * @param angle defines the angle to convert
  30978. * @returns the angle in degrees
  30979. */
  30980. static ToDegrees(angle: number): number;
  30981. /**
  30982. * Convert an angle in degrees to radians
  30983. * @param angle defines the angle to convert
  30984. * @returns the angle in radians
  30985. */
  30986. static ToRadians(angle: number): number;
  30987. /**
  30988. * Encode a buffer to a base64 string
  30989. * @param buffer defines the buffer to encode
  30990. * @returns the encoded string
  30991. */
  30992. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  30993. /**
  30994. * Extracts minimum and maximum values from a list of indexed positions
  30995. * @param positions defines the positions to use
  30996. * @param indices defines the indices to the positions
  30997. * @param indexStart defines the start index
  30998. * @param indexCount defines the end index
  30999. * @param bias defines bias value to add to the result
  31000. * @return minimum and maximum values
  31001. */
  31002. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  31003. minimum: Vector3;
  31004. maximum: Vector3;
  31005. };
  31006. /**
  31007. * Extracts minimum and maximum values from a list of positions
  31008. * @param positions defines the positions to use
  31009. * @param start defines the start index in the positions array
  31010. * @param count defines the number of positions to handle
  31011. * @param bias defines bias value to add to the result
  31012. * @param stride defines the stride size to use (distance between two positions in the positions array)
  31013. * @return minimum and maximum values
  31014. */
  31015. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  31016. minimum: Vector3;
  31017. maximum: Vector3;
  31018. };
  31019. /**
  31020. * Returns an array if obj is not an array
  31021. * @param obj defines the object to evaluate as an array
  31022. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  31023. * @returns either obj directly if obj is an array or a new array containing obj
  31024. */
  31025. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  31026. /**
  31027. * Gets the pointer prefix to use
  31028. * @returns "pointer" if touch is enabled. Else returns "mouse"
  31029. */
  31030. static GetPointerPrefix(): string;
  31031. /**
  31032. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  31033. * @param func - the function to be called
  31034. * @param requester - the object that will request the next frame. Falls back to window.
  31035. * @returns frame number
  31036. */
  31037. static QueueNewFrame(func: () => void, requester?: any): number;
  31038. /**
  31039. * Ask the browser to promote the current element to fullscreen rendering mode
  31040. * @param element defines the DOM element to promote
  31041. */
  31042. static RequestFullscreen(element: HTMLElement): void;
  31043. /**
  31044. * Asks the browser to exit fullscreen mode
  31045. */
  31046. static ExitFullscreen(): void;
  31047. /**
  31048. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  31049. * @param url define the url we are trying
  31050. * @param element define the dom element where to configure the cors policy
  31051. */
  31052. static SetCorsBehavior(url: string | string[], element: {
  31053. crossOrigin: string | null;
  31054. }): void;
  31055. /**
  31056. * Removes unwanted characters from an url
  31057. * @param url defines the url to clean
  31058. * @returns the cleaned url
  31059. */
  31060. static CleanUrl(url: string): string;
  31061. /**
  31062. * Gets or sets a function used to pre-process url before using them to load assets
  31063. */
  31064. static PreprocessUrl: (url: string) => string;
  31065. /**
  31066. * Loads an image as an HTMLImageElement.
  31067. * @param input url string, ArrayBuffer, or Blob to load
  31068. * @param onLoad callback called when the image successfully loads
  31069. * @param onError callback called when the image fails to load
  31070. * @param offlineProvider offline provider for caching
  31071. * @returns the HTMLImageElement of the loaded image
  31072. */
  31073. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  31074. /**
  31075. * Loads a file
  31076. * @param url url string, ArrayBuffer, or Blob to load
  31077. * @param onSuccess callback called when the file successfully loads
  31078. * @param onProgress callback called while file is loading (if the server supports this mode)
  31079. * @param offlineProvider defines the offline provider for caching
  31080. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  31081. * @param onError callback called when the file fails to load
  31082. * @returns a file request object
  31083. */
  31084. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: XMLHttpRequest, exception?: any) => void): IFileRequest;
  31085. /**
  31086. * Load a script (identified by an url). When the url returns, the
  31087. * content of this file is added into a new script element, attached to the DOM (body element)
  31088. * @param scriptUrl defines the url of the script to laod
  31089. * @param onSuccess defines the callback called when the script is loaded
  31090. * @param onError defines the callback to call if an error occurs
  31091. */
  31092. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void): void;
  31093. /**
  31094. * Loads a file from a blob
  31095. * @param fileToLoad defines the blob to use
  31096. * @param callback defines the callback to call when data is loaded
  31097. * @param progressCallback defines the callback to call during loading process
  31098. * @returns a file request object
  31099. */
  31100. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  31101. /**
  31102. * Loads a file
  31103. * @param fileToLoad defines the file to load
  31104. * @param callback defines the callback to call when data is loaded
  31105. * @param progressCallBack defines the callback to call during loading process
  31106. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  31107. * @returns a file request object
  31108. */
  31109. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  31110. /**
  31111. * Creates a data url from a given string content
  31112. * @param content defines the content to convert
  31113. * @returns the new data url link
  31114. */
  31115. static FileAsURL(content: string): string;
  31116. /**
  31117. * Format the given number to a specific decimal format
  31118. * @param value defines the number to format
  31119. * @param decimals defines the number of decimals to use
  31120. * @returns the formatted string
  31121. */
  31122. static Format(value: number, decimals?: number): string;
  31123. /**
  31124. * Checks if a given vector is inside a specific range
  31125. * @param v defines the vector to test
  31126. * @param min defines the minimum range
  31127. * @param max defines the maximum range
  31128. */
  31129. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  31130. /**
  31131. * Tries to copy an object by duplicating every property
  31132. * @param source defines the source object
  31133. * @param destination defines the target object
  31134. * @param doNotCopyList defines a list of properties to avoid
  31135. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  31136. */
  31137. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  31138. /**
  31139. * Gets a boolean indicating if the given object has no own property
  31140. * @param obj defines the object to test
  31141. * @returns true if object has no own property
  31142. */
  31143. static IsEmpty(obj: any): boolean;
  31144. /**
  31145. * Function used to register events at window level
  31146. * @param events defines the events to register
  31147. */
  31148. static RegisterTopRootEvents(events: {
  31149. name: string;
  31150. handler: Nullable<(e: FocusEvent) => any>;
  31151. }[]): void;
  31152. /**
  31153. * Function used to unregister events from window level
  31154. * @param events defines the events to unregister
  31155. */
  31156. static UnregisterTopRootEvents(events: {
  31157. name: string;
  31158. handler: Nullable<(e: FocusEvent) => any>;
  31159. }[]): void;
  31160. /**
  31161. * @ignore
  31162. */
  31163. static _ScreenshotCanvas: HTMLCanvasElement;
  31164. /**
  31165. * Dumps the current bound framebuffer
  31166. * @param width defines the rendering width
  31167. * @param height defines the rendering height
  31168. * @param engine defines the hosting engine
  31169. * @param successCallback defines the callback triggered once the data are available
  31170. * @param mimeType defines the mime type of the result
  31171. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  31172. */
  31173. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31174. /**
  31175. * Converts the canvas data to blob.
  31176. * This acts as a polyfill for browsers not supporting the to blob function.
  31177. * @param canvas Defines the canvas to extract the data from
  31178. * @param successCallback Defines the callback triggered once the data are available
  31179. * @param mimeType Defines the mime type of the result
  31180. */
  31181. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  31182. /**
  31183. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  31184. * @param successCallback defines the callback triggered once the data are available
  31185. * @param mimeType defines the mime type of the result
  31186. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  31187. */
  31188. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31189. /**
  31190. * Downloads a blob in the browser
  31191. * @param blob defines the blob to download
  31192. * @param fileName defines the name of the downloaded file
  31193. */
  31194. static Download(blob: Blob, fileName: string): void;
  31195. /**
  31196. * Captures a screenshot of the current rendering
  31197. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31198. * @param engine defines the rendering engine
  31199. * @param camera defines the source camera
  31200. * @param size This parameter can be set to a single number or to an object with the
  31201. * following (optional) properties: precision, width, height. If a single number is passed,
  31202. * it will be used for both width and height. If an object is passed, the screenshot size
  31203. * will be derived from the parameters. The precision property is a multiplier allowing
  31204. * rendering at a higher or lower resolution
  31205. * @param successCallback defines the callback receives a single parameter which contains the
  31206. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31207. * src parameter of an <img> to display it
  31208. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  31209. * Check your browser for supported MIME types
  31210. */
  31211. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  31212. /**
  31213. * Generates an image screenshot from the specified camera.
  31214. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31215. * @param engine The engine to use for rendering
  31216. * @param camera The camera to use for rendering
  31217. * @param size This parameter can be set to a single number or to an object with the
  31218. * following (optional) properties: precision, width, height. If a single number is passed,
  31219. * it will be used for both width and height. If an object is passed, the screenshot size
  31220. * will be derived from the parameters. The precision property is a multiplier allowing
  31221. * rendering at a higher or lower resolution
  31222. * @param successCallback The callback receives a single parameter which contains the
  31223. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31224. * src parameter of an <img> to display it
  31225. * @param mimeType The MIME type of the screenshot image (default: image/png).
  31226. * Check your browser for supported MIME types
  31227. * @param samples Texture samples (default: 1)
  31228. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  31229. * @param fileName A name for for the downloaded file.
  31230. */
  31231. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  31232. /**
  31233. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  31234. * Be aware Math.random() could cause collisions, but:
  31235. * "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"
  31236. * @returns a pseudo random id
  31237. */
  31238. static RandomId(): string;
  31239. /**
  31240. * Test if the given uri is a base64 string
  31241. * @param uri The uri to test
  31242. * @return True if the uri is a base64 string or false otherwise
  31243. */
  31244. static IsBase64(uri: string): boolean;
  31245. /**
  31246. * Decode the given base64 uri.
  31247. * @param uri The uri to decode
  31248. * @return The decoded base64 data.
  31249. */
  31250. static DecodeBase64(uri: string): ArrayBuffer;
  31251. /**
  31252. * No log
  31253. */
  31254. static readonly NoneLogLevel: number;
  31255. /**
  31256. * Only message logs
  31257. */
  31258. static readonly MessageLogLevel: number;
  31259. /**
  31260. * Only warning logs
  31261. */
  31262. static readonly WarningLogLevel: number;
  31263. /**
  31264. * Only error logs
  31265. */
  31266. static readonly ErrorLogLevel: number;
  31267. /**
  31268. * All logs
  31269. */
  31270. static readonly AllLogLevel: number;
  31271. /**
  31272. * Gets a value indicating the number of loading errors
  31273. * @ignorenaming
  31274. */
  31275. static readonly errorsCount: number;
  31276. /**
  31277. * Callback called when a new log is added
  31278. */
  31279. static OnNewCacheEntry: (entry: string) => void;
  31280. /**
  31281. * Log a message to the console
  31282. * @param message defines the message to log
  31283. */
  31284. static Log(message: string): void;
  31285. /**
  31286. * Write a warning message to the console
  31287. * @param message defines the message to log
  31288. */
  31289. static Warn(message: string): void;
  31290. /**
  31291. * Write an error message to the console
  31292. * @param message defines the message to log
  31293. */
  31294. static Error(message: string): void;
  31295. /**
  31296. * Gets current log cache (list of logs)
  31297. */
  31298. static readonly LogCache: string;
  31299. /**
  31300. * Clears the log cache
  31301. */
  31302. static ClearLogCache(): void;
  31303. /**
  31304. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  31305. */
  31306. static LogLevels: number;
  31307. /**
  31308. * Checks if the loaded document was accessed via `file:`-Protocol.
  31309. * @returns boolean
  31310. */
  31311. static IsFileURL(): boolean;
  31312. /**
  31313. * Checks if the window object exists
  31314. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  31315. */
  31316. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  31317. /**
  31318. * No performance log
  31319. */
  31320. static readonly PerformanceNoneLogLevel: number;
  31321. /**
  31322. * Use user marks to log performance
  31323. */
  31324. static readonly PerformanceUserMarkLogLevel: number;
  31325. /**
  31326. * Log performance to the console
  31327. */
  31328. static readonly PerformanceConsoleLogLevel: number;
  31329. private static _performance;
  31330. /**
  31331. * Sets the current performance log level
  31332. */
  31333. static PerformanceLogLevel: number;
  31334. private static _StartPerformanceCounterDisabled;
  31335. private static _EndPerformanceCounterDisabled;
  31336. private static _StartUserMark;
  31337. private static _EndUserMark;
  31338. private static _StartPerformanceConsole;
  31339. private static _EndPerformanceConsole;
  31340. /**
  31341. * Starts a performance counter
  31342. */
  31343. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31344. /**
  31345. * Ends a specific performance coutner
  31346. */
  31347. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31348. /**
  31349. * Gets either window.performance.now() if supported or Date.now() else
  31350. */
  31351. static readonly Now: number;
  31352. /**
  31353. * This method will return the name of the class used to create the instance of the given object.
  31354. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  31355. * @param object the object to get the class name from
  31356. * @param isType defines if the object is actually a type
  31357. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  31358. */
  31359. static GetClassName(object: any, isType?: boolean): string;
  31360. /**
  31361. * Gets the first element of an array satisfying a given predicate
  31362. * @param array defines the array to browse
  31363. * @param predicate defines the predicate to use
  31364. * @returns null if not found or the element
  31365. */
  31366. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  31367. /**
  31368. * This method will return the name of the full name of the class, including its owning module (if any).
  31369. * 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).
  31370. * @param object the object to get the class name from
  31371. * @param isType defines if the object is actually a type
  31372. * @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.
  31373. * @ignorenaming
  31374. */
  31375. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  31376. /**
  31377. * Returns a promise that resolves after the given amount of time.
  31378. * @param delay Number of milliseconds to delay
  31379. * @returns Promise that resolves after the given amount of time
  31380. */
  31381. static DelayAsync(delay: number): Promise<void>;
  31382. /**
  31383. * Gets the current gradient from an array of IValueGradient
  31384. * @param ratio defines the current ratio to get
  31385. * @param gradients defines the array of IValueGradient
  31386. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  31387. */
  31388. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  31389. }
  31390. /**
  31391. * This class is used to track a performance counter which is number based.
  31392. * The user has access to many properties which give statistics of different nature.
  31393. *
  31394. * The implementer can track two kinds of Performance Counter: time and count.
  31395. * 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.
  31396. * 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.
  31397. */
  31398. export class PerfCounter {
  31399. /**
  31400. * Gets or sets a global boolean to turn on and off all the counters
  31401. */
  31402. static Enabled: boolean;
  31403. /**
  31404. * Returns the smallest value ever
  31405. */
  31406. readonly min: number;
  31407. /**
  31408. * Returns the biggest value ever
  31409. */
  31410. readonly max: number;
  31411. /**
  31412. * Returns the average value since the performance counter is running
  31413. */
  31414. readonly average: number;
  31415. /**
  31416. * Returns the average value of the last second the counter was monitored
  31417. */
  31418. readonly lastSecAverage: number;
  31419. /**
  31420. * Returns the current value
  31421. */
  31422. readonly current: number;
  31423. /**
  31424. * Gets the accumulated total
  31425. */
  31426. readonly total: number;
  31427. /**
  31428. * Gets the total value count
  31429. */
  31430. readonly count: number;
  31431. /**
  31432. * Creates a new counter
  31433. */
  31434. constructor();
  31435. /**
  31436. * Call this method to start monitoring a new frame.
  31437. * 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.
  31438. */
  31439. fetchNewFrame(): void;
  31440. /**
  31441. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  31442. * @param newCount the count value to add to the monitored count
  31443. * @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.
  31444. */
  31445. addCount(newCount: number, fetchResult: boolean): void;
  31446. /**
  31447. * Start monitoring this performance counter
  31448. */
  31449. beginMonitoring(): void;
  31450. /**
  31451. * Compute the time lapsed since the previous beginMonitoring() call.
  31452. * @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
  31453. */
  31454. endMonitoring(newFrame?: boolean): void;
  31455. private _fetchResult;
  31456. private _startMonitoringTime;
  31457. private _min;
  31458. private _max;
  31459. private _average;
  31460. private _current;
  31461. private _totalValueCount;
  31462. private _totalAccumulated;
  31463. private _lastSecAverage;
  31464. private _lastSecAccumulated;
  31465. private _lastSecTime;
  31466. private _lastSecValueCount;
  31467. }
  31468. /**
  31469. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  31470. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  31471. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  31472. * @param name The name of the class, case should be preserved
  31473. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  31474. */
  31475. export function className(name: string, module?: string): (target: Object) => void;
  31476. /**
  31477. * An implementation of a loop for asynchronous functions.
  31478. */
  31479. export class AsyncLoop {
  31480. /**
  31481. * Defines the number of iterations for the loop
  31482. */
  31483. iterations: number;
  31484. /**
  31485. * Defines the current index of the loop.
  31486. */
  31487. index: number;
  31488. private _done;
  31489. private _fn;
  31490. private _successCallback;
  31491. /**
  31492. * Constructor.
  31493. * @param iterations the number of iterations.
  31494. * @param func the function to run each iteration
  31495. * @param successCallback the callback that will be called upon succesful execution
  31496. * @param offset starting offset.
  31497. */
  31498. constructor(
  31499. /**
  31500. * Defines the number of iterations for the loop
  31501. */
  31502. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  31503. /**
  31504. * Execute the next iteration. Must be called after the last iteration was finished.
  31505. */
  31506. executeNext(): void;
  31507. /**
  31508. * Break the loop and run the success callback.
  31509. */
  31510. breakLoop(): void;
  31511. /**
  31512. * Create and run an async loop.
  31513. * @param iterations the number of iterations.
  31514. * @param fn the function to run each iteration
  31515. * @param successCallback the callback that will be called upon succesful execution
  31516. * @param offset starting offset.
  31517. * @returns the created async loop object
  31518. */
  31519. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  31520. /**
  31521. * A for-loop that will run a given number of iterations synchronous and the rest async.
  31522. * @param iterations total number of iterations
  31523. * @param syncedIterations number of synchronous iterations in each async iteration.
  31524. * @param fn the function to call each iteration.
  31525. * @param callback a success call back that will be called when iterating stops.
  31526. * @param breakFunction a break condition (optional)
  31527. * @param timeout timeout settings for the setTimeout function. default - 0.
  31528. * @returns the created async loop object
  31529. */
  31530. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  31531. }
  31532. }
  31533. declare module "babylonjs/Collisions/collisionCoordinator" {
  31534. import { Nullable } from "babylonjs/types";
  31535. import { Scene } from "babylonjs/scene";
  31536. import { Vector3 } from "babylonjs/Maths/math";
  31537. import { Collider } from "babylonjs/Collisions/collider";
  31538. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  31539. /** @hidden */
  31540. export interface ICollisionCoordinator {
  31541. createCollider(): Collider;
  31542. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  31543. init(scene: Scene): void;
  31544. }
  31545. /** @hidden */
  31546. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  31547. private _scene;
  31548. private _scaledPosition;
  31549. private _scaledVelocity;
  31550. private _finalPosition;
  31551. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  31552. createCollider(): Collider;
  31553. init(scene: Scene): void;
  31554. private _collideWithWorld;
  31555. }
  31556. }
  31557. declare module "babylonjs/Animations/animationGroup" {
  31558. import { Animatable } from "babylonjs/Animations/animatable";
  31559. import { Animation } from "babylonjs/Animations/animation";
  31560. import { Scene, IDisposable } from "babylonjs/scene";
  31561. import { Observable } from "babylonjs/Misc/observable";
  31562. import { Nullable } from "babylonjs/types";
  31563. /**
  31564. * This class defines the direct association between an animation and a target
  31565. */
  31566. export class TargetedAnimation {
  31567. /**
  31568. * Animation to perform
  31569. */
  31570. animation: Animation;
  31571. /**
  31572. * Target to animate
  31573. */
  31574. target: any;
  31575. }
  31576. /**
  31577. * Use this class to create coordinated animations on multiple targets
  31578. */
  31579. export class AnimationGroup implements IDisposable {
  31580. /** The name of the animation group */
  31581. name: string;
  31582. private _scene;
  31583. private _targetedAnimations;
  31584. private _animatables;
  31585. private _from;
  31586. private _to;
  31587. private _isStarted;
  31588. private _isPaused;
  31589. private _speedRatio;
  31590. /**
  31591. * Gets or sets the unique id of the node
  31592. */
  31593. uniqueId: number;
  31594. /**
  31595. * This observable will notify when one animation have ended
  31596. */
  31597. onAnimationEndObservable: Observable<TargetedAnimation>;
  31598. /**
  31599. * Observer raised when one animation loops
  31600. */
  31601. onAnimationLoopObservable: Observable<TargetedAnimation>;
  31602. /**
  31603. * This observable will notify when all animations have ended.
  31604. */
  31605. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  31606. /**
  31607. * This observable will notify when all animations have paused.
  31608. */
  31609. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  31610. /**
  31611. * This observable will notify when all animations are playing.
  31612. */
  31613. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  31614. /**
  31615. * Gets the first frame
  31616. */
  31617. readonly from: number;
  31618. /**
  31619. * Gets the last frame
  31620. */
  31621. readonly to: number;
  31622. /**
  31623. * Define if the animations are started
  31624. */
  31625. readonly isStarted: boolean;
  31626. /**
  31627. * Gets a value indicating that the current group is playing
  31628. */
  31629. readonly isPlaying: boolean;
  31630. /**
  31631. * Gets or sets the speed ratio to use for all animations
  31632. */
  31633. /**
  31634. * Gets or sets the speed ratio to use for all animations
  31635. */
  31636. speedRatio: number;
  31637. /**
  31638. * Gets the targeted animations for this animation group
  31639. */
  31640. readonly targetedAnimations: Array<TargetedAnimation>;
  31641. /**
  31642. * returning the list of animatables controlled by this animation group.
  31643. */
  31644. readonly animatables: Array<Animatable>;
  31645. /**
  31646. * Instantiates a new Animation Group.
  31647. * This helps managing several animations at once.
  31648. * @see http://doc.babylonjs.com/how_to/group
  31649. * @param name Defines the name of the group
  31650. * @param scene Defines the scene the group belongs to
  31651. */
  31652. constructor(
  31653. /** The name of the animation group */
  31654. name: string, scene?: Nullable<Scene>);
  31655. /**
  31656. * Add an animation (with its target) in the group
  31657. * @param animation defines the animation we want to add
  31658. * @param target defines the target of the animation
  31659. * @returns the TargetedAnimation object
  31660. */
  31661. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  31662. /**
  31663. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  31664. * It can add constant keys at begin or end
  31665. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  31666. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  31667. * @returns the animation group
  31668. */
  31669. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  31670. /**
  31671. * Start all animations on given targets
  31672. * @param loop defines if animations must loop
  31673. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  31674. * @param from defines the from key (optional)
  31675. * @param to defines the to key (optional)
  31676. * @returns the current animation group
  31677. */
  31678. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  31679. /**
  31680. * Pause all animations
  31681. * @returns the animation group
  31682. */
  31683. pause(): AnimationGroup;
  31684. /**
  31685. * Play all animations to initial state
  31686. * This function will start() the animations if they were not started or will restart() them if they were paused
  31687. * @param loop defines if animations must loop
  31688. * @returns the animation group
  31689. */
  31690. play(loop?: boolean): AnimationGroup;
  31691. /**
  31692. * Reset all animations to initial state
  31693. * @returns the animation group
  31694. */
  31695. reset(): AnimationGroup;
  31696. /**
  31697. * Restart animations from key 0
  31698. * @returns the animation group
  31699. */
  31700. restart(): AnimationGroup;
  31701. /**
  31702. * Stop all animations
  31703. * @returns the animation group
  31704. */
  31705. stop(): AnimationGroup;
  31706. /**
  31707. * Set animation weight for all animatables
  31708. * @param weight defines the weight to use
  31709. * @return the animationGroup
  31710. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  31711. */
  31712. setWeightForAllAnimatables(weight: number): AnimationGroup;
  31713. /**
  31714. * Synchronize and normalize all animatables with a source animatable
  31715. * @param root defines the root animatable to synchronize with
  31716. * @return the animationGroup
  31717. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  31718. */
  31719. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  31720. /**
  31721. * Goes to a specific frame in this animation group
  31722. * @param frame the frame number to go to
  31723. * @return the animationGroup
  31724. */
  31725. goToFrame(frame: number): AnimationGroup;
  31726. /**
  31727. * Dispose all associated resources
  31728. */
  31729. dispose(): void;
  31730. private _checkAnimationGroupEnded;
  31731. /**
  31732. * Clone the current animation group and returns a copy
  31733. * @param newName defines the name of the new group
  31734. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  31735. * @returns the new aniamtion group
  31736. */
  31737. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  31738. /**
  31739. * Returns a new AnimationGroup object parsed from the source provided.
  31740. * @param parsedAnimationGroup defines the source
  31741. * @param scene defines the scene that will receive the animationGroup
  31742. * @returns a new AnimationGroup
  31743. */
  31744. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  31745. /**
  31746. * Returns the string "AnimationGroup"
  31747. * @returns "AnimationGroup"
  31748. */
  31749. getClassName(): string;
  31750. /**
  31751. * Creates a detailled string about the object
  31752. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  31753. * @returns a string representing the object
  31754. */
  31755. toString(fullDetails?: boolean): string;
  31756. }
  31757. }
  31758. declare module "babylonjs/scene" {
  31759. import { Nullable } from "babylonjs/types";
  31760. import { IAnimatable, IFileRequest, PerfCounter } from "babylonjs/Misc/tools";
  31761. import { Observable } from "babylonjs/Misc/observable";
  31762. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  31763. import { Color4, Color3, Plane, Vector2, Vector3, Matrix } from "babylonjs/Maths/math";
  31764. import { Geometry } from "babylonjs/Meshes/geometry";
  31765. import { TransformNode } from "babylonjs/Meshes/transformNode";
  31766. import { SubMesh } from "babylonjs/Meshes/subMesh";
  31767. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  31768. import { Mesh } from "babylonjs/Meshes/mesh";
  31769. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  31770. import { Bone } from "babylonjs/Bones/bone";
  31771. import { Skeleton } from "babylonjs/Bones/skeleton";
  31772. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  31773. import { Camera } from "babylonjs/Cameras/camera";
  31774. import { AbstractScene } from "babylonjs/abstractScene";
  31775. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31776. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  31777. import { Material } from "babylonjs/Materials/material";
  31778. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  31779. import { Effect } from "babylonjs/Materials/effect";
  31780. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  31781. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  31782. import { Light } from "babylonjs/Lights/light";
  31783. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  31784. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  31785. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  31786. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  31787. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  31788. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  31789. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  31790. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  31791. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction } from "babylonjs/sceneComponent";
  31792. import { Engine } from "babylonjs/Engines/engine";
  31793. import { Node } from "babylonjs/node";
  31794. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  31795. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  31796. import { Ray } from "babylonjs/Culling/ray";
  31797. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  31798. import { Animation } from "babylonjs/Animations/animation";
  31799. import { Animatable } from "babylonjs/Animations/animatable";
  31800. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  31801. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  31802. import { Collider } from "babylonjs/Collisions/collider";
  31803. /**
  31804. * Define an interface for all classes that will hold resources
  31805. */
  31806. export interface IDisposable {
  31807. /**
  31808. * Releases all held resources
  31809. */
  31810. dispose(): void;
  31811. }
  31812. /** Interface defining initialization parameters for Scene class */
  31813. export interface SceneOptions {
  31814. /**
  31815. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  31816. * It will improve performance when the number of geometries becomes important.
  31817. */
  31818. useGeometryUniqueIdsMap?: boolean;
  31819. /**
  31820. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  31821. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  31822. */
  31823. useMaterialMeshMap?: boolean;
  31824. /**
  31825. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  31826. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  31827. */
  31828. useClonedMeshhMap?: boolean;
  31829. }
  31830. /**
  31831. * Represents a scene to be rendered by the engine.
  31832. * @see http://doc.babylonjs.com/features/scene
  31833. */
  31834. export class Scene extends AbstractScene implements IAnimatable {
  31835. private static _uniqueIdCounter;
  31836. /** The fog is deactivated */
  31837. static readonly FOGMODE_NONE: number;
  31838. /** The fog density is following an exponential function */
  31839. static readonly FOGMODE_EXP: number;
  31840. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  31841. static readonly FOGMODE_EXP2: number;
  31842. /** The fog density is following a linear function. */
  31843. static readonly FOGMODE_LINEAR: number;
  31844. /**
  31845. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  31846. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31847. */
  31848. static MinDeltaTime: number;
  31849. /**
  31850. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  31851. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31852. */
  31853. static MaxDeltaTime: number;
  31854. /**
  31855. * Factory used to create the default material.
  31856. * @param name The name of the material to create
  31857. * @param scene The scene to create the material for
  31858. * @returns The default material
  31859. */
  31860. static DefaultMaterialFactory(scene: Scene): Material;
  31861. /**
  31862. * Factory used to create the a collision coordinator.
  31863. * @returns The collision coordinator
  31864. */
  31865. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  31866. /** @hidden */
  31867. readonly _isScene: boolean;
  31868. /**
  31869. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  31870. */
  31871. autoClear: boolean;
  31872. /**
  31873. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  31874. */
  31875. autoClearDepthAndStencil: boolean;
  31876. /**
  31877. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  31878. */
  31879. clearColor: Color4;
  31880. /**
  31881. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  31882. */
  31883. ambientColor: Color3;
  31884. /** @hidden */
  31885. _environmentBRDFTexture: BaseTexture;
  31886. /** @hidden */
  31887. protected _environmentTexture: Nullable<BaseTexture>;
  31888. /**
  31889. * Texture used in all pbr material as the reflection texture.
  31890. * As in the majority of the scene they are the same (exception for multi room and so on),
  31891. * this is easier to reference from here than from all the materials.
  31892. */
  31893. /**
  31894. * Texture used in all pbr material as the reflection texture.
  31895. * As in the majority of the scene they are the same (exception for multi room and so on),
  31896. * this is easier to set here than in all the materials.
  31897. */
  31898. environmentTexture: Nullable<BaseTexture>;
  31899. /** @hidden */
  31900. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  31901. /**
  31902. * Default image processing configuration used either in the rendering
  31903. * Forward main pass or through the imageProcessingPostProcess if present.
  31904. * As in the majority of the scene they are the same (exception for multi camera),
  31905. * this is easier to reference from here than from all the materials and post process.
  31906. *
  31907. * No setter as we it is a shared configuration, you can set the values instead.
  31908. */
  31909. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  31910. private _forceWireframe;
  31911. /**
  31912. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  31913. */
  31914. forceWireframe: boolean;
  31915. private _forcePointsCloud;
  31916. /**
  31917. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  31918. */
  31919. forcePointsCloud: boolean;
  31920. /**
  31921. * Gets or sets the active clipplane 1
  31922. */
  31923. clipPlane: Nullable<Plane>;
  31924. /**
  31925. * Gets or sets the active clipplane 2
  31926. */
  31927. clipPlane2: Nullable<Plane>;
  31928. /**
  31929. * Gets or sets the active clipplane 3
  31930. */
  31931. clipPlane3: Nullable<Plane>;
  31932. /**
  31933. * Gets or sets the active clipplane 4
  31934. */
  31935. clipPlane4: Nullable<Plane>;
  31936. /**
  31937. * Gets or sets a boolean indicating if animations are enabled
  31938. */
  31939. animationsEnabled: boolean;
  31940. private _animationPropertiesOverride;
  31941. /**
  31942. * Gets or sets the animation properties override
  31943. */
  31944. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  31945. /**
  31946. * Gets or sets a boolean indicating if a constant deltatime has to be used
  31947. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  31948. */
  31949. useConstantAnimationDeltaTime: boolean;
  31950. /**
  31951. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  31952. * Please note that it requires to run a ray cast through the scene on every frame
  31953. */
  31954. constantlyUpdateMeshUnderPointer: boolean;
  31955. /**
  31956. * Defines the HTML cursor to use when hovering over interactive elements
  31957. */
  31958. hoverCursor: string;
  31959. /**
  31960. * Defines the HTML default cursor to use (empty by default)
  31961. */
  31962. defaultCursor: string;
  31963. /**
  31964. * This is used to call preventDefault() on pointer down
  31965. * in order to block unwanted artifacts like system double clicks
  31966. */
  31967. preventDefaultOnPointerDown: boolean;
  31968. /**
  31969. * This is used to call preventDefault() on pointer up
  31970. * in order to block unwanted artifacts like system double clicks
  31971. */
  31972. preventDefaultOnPointerUp: boolean;
  31973. /**
  31974. * Gets or sets user defined metadata
  31975. */
  31976. metadata: any;
  31977. /**
  31978. * For internal use only. Please do not use.
  31979. */
  31980. reservedDataStore: any;
  31981. /**
  31982. * Gets the name of the plugin used to load this scene (null by default)
  31983. */
  31984. loadingPluginName: string;
  31985. /**
  31986. * Use this array to add regular expressions used to disable offline support for specific urls
  31987. */
  31988. disableOfflineSupportExceptionRules: RegExp[];
  31989. /**
  31990. * An event triggered when the scene is disposed.
  31991. */
  31992. onDisposeObservable: Observable<Scene>;
  31993. private _onDisposeObserver;
  31994. /** Sets a function to be executed when this scene is disposed. */
  31995. onDispose: () => void;
  31996. /**
  31997. * An event triggered before rendering the scene (right after animations and physics)
  31998. */
  31999. onBeforeRenderObservable: Observable<Scene>;
  32000. private _onBeforeRenderObserver;
  32001. /** Sets a function to be executed before rendering this scene */
  32002. beforeRender: Nullable<() => void>;
  32003. /**
  32004. * An event triggered after rendering the scene
  32005. */
  32006. onAfterRenderObservable: Observable<Scene>;
  32007. private _onAfterRenderObserver;
  32008. /** Sets a function to be executed after rendering this scene */
  32009. afterRender: Nullable<() => void>;
  32010. /**
  32011. * An event triggered before animating the scene
  32012. */
  32013. onBeforeAnimationsObservable: Observable<Scene>;
  32014. /**
  32015. * An event triggered after animations processing
  32016. */
  32017. onAfterAnimationsObservable: Observable<Scene>;
  32018. /**
  32019. * An event triggered before draw calls are ready to be sent
  32020. */
  32021. onBeforeDrawPhaseObservable: Observable<Scene>;
  32022. /**
  32023. * An event triggered after draw calls have been sent
  32024. */
  32025. onAfterDrawPhaseObservable: Observable<Scene>;
  32026. /**
  32027. * An event triggered when the scene is ready
  32028. */
  32029. onReadyObservable: Observable<Scene>;
  32030. /**
  32031. * An event triggered before rendering a camera
  32032. */
  32033. onBeforeCameraRenderObservable: Observable<Camera>;
  32034. private _onBeforeCameraRenderObserver;
  32035. /** Sets a function to be executed before rendering a camera*/
  32036. beforeCameraRender: () => void;
  32037. /**
  32038. * An event triggered after rendering a camera
  32039. */
  32040. onAfterCameraRenderObservable: Observable<Camera>;
  32041. private _onAfterCameraRenderObserver;
  32042. /** Sets a function to be executed after rendering a camera*/
  32043. afterCameraRender: () => void;
  32044. /**
  32045. * An event triggered when active meshes evaluation is about to start
  32046. */
  32047. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  32048. /**
  32049. * An event triggered when active meshes evaluation is done
  32050. */
  32051. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  32052. /**
  32053. * An event triggered when particles rendering is about to start
  32054. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  32055. */
  32056. onBeforeParticlesRenderingObservable: Observable<Scene>;
  32057. /**
  32058. * An event triggered when particles rendering is done
  32059. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  32060. */
  32061. onAfterParticlesRenderingObservable: Observable<Scene>;
  32062. /**
  32063. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  32064. */
  32065. onDataLoadedObservable: Observable<Scene>;
  32066. /**
  32067. * An event triggered when a camera is created
  32068. */
  32069. onNewCameraAddedObservable: Observable<Camera>;
  32070. /**
  32071. * An event triggered when a camera is removed
  32072. */
  32073. onCameraRemovedObservable: Observable<Camera>;
  32074. /**
  32075. * An event triggered when a light is created
  32076. */
  32077. onNewLightAddedObservable: Observable<Light>;
  32078. /**
  32079. * An event triggered when a light is removed
  32080. */
  32081. onLightRemovedObservable: Observable<Light>;
  32082. /**
  32083. * An event triggered when a geometry is created
  32084. */
  32085. onNewGeometryAddedObservable: Observable<Geometry>;
  32086. /**
  32087. * An event triggered when a geometry is removed
  32088. */
  32089. onGeometryRemovedObservable: Observable<Geometry>;
  32090. /**
  32091. * An event triggered when a transform node is created
  32092. */
  32093. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  32094. /**
  32095. * An event triggered when a transform node is removed
  32096. */
  32097. onTransformNodeRemovedObservable: Observable<TransformNode>;
  32098. /**
  32099. * An event triggered when a mesh is created
  32100. */
  32101. onNewMeshAddedObservable: Observable<AbstractMesh>;
  32102. /**
  32103. * An event triggered when a mesh is removed
  32104. */
  32105. onMeshRemovedObservable: Observable<AbstractMesh>;
  32106. /**
  32107. * An event triggered when a material is created
  32108. */
  32109. onNewMaterialAddedObservable: Observable<Material>;
  32110. /**
  32111. * An event triggered when a material is removed
  32112. */
  32113. onMaterialRemovedObservable: Observable<Material>;
  32114. /**
  32115. * An event triggered when a texture is created
  32116. */
  32117. onNewTextureAddedObservable: Observable<BaseTexture>;
  32118. /**
  32119. * An event triggered when a texture is removed
  32120. */
  32121. onTextureRemovedObservable: Observable<BaseTexture>;
  32122. /**
  32123. * An event triggered when render targets are about to be rendered
  32124. * Can happen multiple times per frame.
  32125. */
  32126. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  32127. /**
  32128. * An event triggered when render targets were rendered.
  32129. * Can happen multiple times per frame.
  32130. */
  32131. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  32132. /**
  32133. * An event triggered before calculating deterministic simulation step
  32134. */
  32135. onBeforeStepObservable: Observable<Scene>;
  32136. /**
  32137. * An event triggered after calculating deterministic simulation step
  32138. */
  32139. onAfterStepObservable: Observable<Scene>;
  32140. /**
  32141. * An event triggered when the activeCamera property is updated
  32142. */
  32143. onActiveCameraChanged: Observable<Scene>;
  32144. /**
  32145. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  32146. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  32147. * 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)
  32148. */
  32149. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  32150. /**
  32151. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  32152. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  32153. * 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)
  32154. */
  32155. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  32156. /**
  32157. * This Observable will when a mesh has been imported into the scene.
  32158. */
  32159. onMeshImportedObservable: Observable<AbstractMesh>;
  32160. /**
  32161. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  32162. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  32163. */
  32164. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  32165. /** @hidden */
  32166. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  32167. /**
  32168. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  32169. */
  32170. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  32171. /**
  32172. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  32173. */
  32174. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  32175. /**
  32176. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  32177. */
  32178. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  32179. private _onPointerMove;
  32180. private _onPointerDown;
  32181. private _onPointerUp;
  32182. /** Callback called when a pointer move is detected */
  32183. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  32184. /** Callback called when a pointer down is detected */
  32185. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  32186. /** Callback called when a pointer up is detected */
  32187. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  32188. /** Callback called when a pointer pick is detected */
  32189. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  32190. /**
  32191. * 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).
  32192. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  32193. */
  32194. onPrePointerObservable: Observable<PointerInfoPre>;
  32195. /**
  32196. * Observable event triggered each time an input event is received from the rendering canvas
  32197. */
  32198. onPointerObservable: Observable<PointerInfo>;
  32199. /**
  32200. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  32201. */
  32202. readonly unTranslatedPointer: Vector2;
  32203. /** The distance in pixel that you have to move to prevent some events */
  32204. static DragMovementThreshold: number;
  32205. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  32206. static LongPressDelay: number;
  32207. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  32208. static DoubleClickDelay: number;
  32209. /** If you need to check double click without raising a single click at first click, enable this flag */
  32210. static ExclusiveDoubleClickMode: boolean;
  32211. private _initClickEvent;
  32212. private _initActionManager;
  32213. private _delayedSimpleClick;
  32214. private _delayedSimpleClickTimeout;
  32215. private _previousDelayedSimpleClickTimeout;
  32216. private _meshPickProceed;
  32217. private _previousButtonPressed;
  32218. private _currentPickResult;
  32219. private _previousPickResult;
  32220. private _totalPointersPressed;
  32221. private _doubleClickOccured;
  32222. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  32223. cameraToUseForPointers: Nullable<Camera>;
  32224. private _pointerX;
  32225. private _pointerY;
  32226. private _unTranslatedPointerX;
  32227. private _unTranslatedPointerY;
  32228. private _startingPointerPosition;
  32229. private _previousStartingPointerPosition;
  32230. private _startingPointerTime;
  32231. private _previousStartingPointerTime;
  32232. private _pointerCaptures;
  32233. private _timeAccumulator;
  32234. private _currentStepId;
  32235. private _currentInternalStep;
  32236. /** @hidden */
  32237. _mirroredCameraPosition: Nullable<Vector3>;
  32238. /**
  32239. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  32240. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  32241. */
  32242. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  32243. /**
  32244. * Observable event triggered each time an keyboard event is received from the hosting window
  32245. */
  32246. onKeyboardObservable: Observable<KeyboardInfo>;
  32247. private _onKeyDown;
  32248. private _onKeyUp;
  32249. private _onCanvasFocusObserver;
  32250. private _onCanvasBlurObserver;
  32251. private _useRightHandedSystem;
  32252. /**
  32253. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  32254. */
  32255. useRightHandedSystem: boolean;
  32256. /**
  32257. * Sets the step Id used by deterministic lock step
  32258. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32259. * @param newStepId defines the step Id
  32260. */
  32261. setStepId(newStepId: number): void;
  32262. /**
  32263. * Gets the step Id used by deterministic lock step
  32264. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32265. * @returns the step Id
  32266. */
  32267. getStepId(): number;
  32268. /**
  32269. * Gets the internal step used by deterministic lock step
  32270. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32271. * @returns the internal step
  32272. */
  32273. getInternalStep(): number;
  32274. private _fogEnabled;
  32275. /**
  32276. * Gets or sets a boolean indicating if fog is enabled on this scene
  32277. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32278. * (Default is true)
  32279. */
  32280. fogEnabled: boolean;
  32281. private _fogMode;
  32282. /**
  32283. * Gets or sets the fog mode to use
  32284. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32285. * | mode | value |
  32286. * | --- | --- |
  32287. * | FOGMODE_NONE | 0 |
  32288. * | FOGMODE_EXP | 1 |
  32289. * | FOGMODE_EXP2 | 2 |
  32290. * | FOGMODE_LINEAR | 3 |
  32291. */
  32292. fogMode: number;
  32293. /**
  32294. * Gets or sets the fog color to use
  32295. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32296. * (Default is Color3(0.2, 0.2, 0.3))
  32297. */
  32298. fogColor: Color3;
  32299. /**
  32300. * Gets or sets the fog density to use
  32301. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32302. * (Default is 0.1)
  32303. */
  32304. fogDensity: number;
  32305. /**
  32306. * Gets or sets the fog start distance to use
  32307. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32308. * (Default is 0)
  32309. */
  32310. fogStart: number;
  32311. /**
  32312. * Gets or sets the fog end distance to use
  32313. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32314. * (Default is 1000)
  32315. */
  32316. fogEnd: number;
  32317. private _shadowsEnabled;
  32318. /**
  32319. * Gets or sets a boolean indicating if shadows are enabled on this scene
  32320. */
  32321. shadowsEnabled: boolean;
  32322. private _lightsEnabled;
  32323. /**
  32324. * Gets or sets a boolean indicating if lights are enabled on this scene
  32325. */
  32326. lightsEnabled: boolean;
  32327. /** All of the active cameras added to this scene. */
  32328. activeCameras: Camera[];
  32329. private _activeCamera;
  32330. /** Gets or sets the current active camera */
  32331. activeCamera: Nullable<Camera>;
  32332. private _defaultMaterial;
  32333. /** The default material used on meshes when no material is affected */
  32334. /** The default material used on meshes when no material is affected */
  32335. defaultMaterial: Material;
  32336. private _texturesEnabled;
  32337. /**
  32338. * Gets or sets a boolean indicating if textures are enabled on this scene
  32339. */
  32340. texturesEnabled: boolean;
  32341. /**
  32342. * Gets or sets a boolean indicating if particles are enabled on this scene
  32343. */
  32344. particlesEnabled: boolean;
  32345. /**
  32346. * Gets or sets a boolean indicating if sprites are enabled on this scene
  32347. */
  32348. spritesEnabled: boolean;
  32349. private _skeletonsEnabled;
  32350. /**
  32351. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  32352. */
  32353. skeletonsEnabled: boolean;
  32354. /**
  32355. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  32356. */
  32357. lensFlaresEnabled: boolean;
  32358. /**
  32359. * Gets or sets a boolean indicating if collisions are enabled on this scene
  32360. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32361. */
  32362. collisionsEnabled: boolean;
  32363. private _collisionCoordinator;
  32364. /** @hidden */
  32365. readonly collisionCoordinator: ICollisionCoordinator;
  32366. /**
  32367. * Defines the gravity applied to this scene (used only for collisions)
  32368. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32369. */
  32370. gravity: Vector3;
  32371. /**
  32372. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  32373. */
  32374. postProcessesEnabled: boolean;
  32375. /**
  32376. * The list of postprocesses added to the scene
  32377. */
  32378. postProcesses: PostProcess[];
  32379. /**
  32380. * Gets the current postprocess manager
  32381. */
  32382. postProcessManager: PostProcessManager;
  32383. /**
  32384. * Gets or sets a boolean indicating if render targets are enabled on this scene
  32385. */
  32386. renderTargetsEnabled: boolean;
  32387. /**
  32388. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  32389. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  32390. */
  32391. dumpNextRenderTargets: boolean;
  32392. /**
  32393. * The list of user defined render targets added to the scene
  32394. */
  32395. customRenderTargets: RenderTargetTexture[];
  32396. /**
  32397. * Defines if texture loading must be delayed
  32398. * If true, textures will only be loaded when they need to be rendered
  32399. */
  32400. useDelayedTextureLoading: boolean;
  32401. /**
  32402. * Gets the list of meshes imported to the scene through SceneLoader
  32403. */
  32404. importedMeshesFiles: String[];
  32405. /**
  32406. * Gets or sets a boolean indicating if probes are enabled on this scene
  32407. */
  32408. probesEnabled: boolean;
  32409. /**
  32410. * Gets or sets the current offline provider to use to store scene data
  32411. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  32412. */
  32413. offlineProvider: IOfflineProvider;
  32414. /**
  32415. * Gets or sets the action manager associated with the scene
  32416. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  32417. */
  32418. actionManager: AbstractActionManager;
  32419. private _meshesForIntersections;
  32420. /**
  32421. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  32422. */
  32423. proceduralTexturesEnabled: boolean;
  32424. private _engine;
  32425. private _totalVertices;
  32426. /** @hidden */
  32427. _activeIndices: PerfCounter;
  32428. /** @hidden */
  32429. _activeParticles: PerfCounter;
  32430. /** @hidden */
  32431. _activeBones: PerfCounter;
  32432. private _animationRatio;
  32433. /** @hidden */
  32434. _animationTimeLast: number;
  32435. /** @hidden */
  32436. _animationTime: number;
  32437. /**
  32438. * Gets or sets a general scale for animation speed
  32439. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  32440. */
  32441. animationTimeScale: number;
  32442. /** @hidden */
  32443. _cachedMaterial: Nullable<Material>;
  32444. /** @hidden */
  32445. _cachedEffect: Nullable<Effect>;
  32446. /** @hidden */
  32447. _cachedVisibility: Nullable<number>;
  32448. private _renderId;
  32449. private _frameId;
  32450. private _executeWhenReadyTimeoutId;
  32451. private _intermediateRendering;
  32452. private _viewUpdateFlag;
  32453. private _projectionUpdateFlag;
  32454. private _alternateViewUpdateFlag;
  32455. private _alternateProjectionUpdateFlag;
  32456. /** @hidden */
  32457. _toBeDisposed: Nullable<IDisposable>[];
  32458. private _activeRequests;
  32459. /** @hidden */
  32460. _pendingData: any[];
  32461. private _isDisposed;
  32462. /**
  32463. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  32464. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  32465. */
  32466. dispatchAllSubMeshesOfActiveMeshes: boolean;
  32467. private _activeMeshes;
  32468. private _processedMaterials;
  32469. private _renderTargets;
  32470. /** @hidden */
  32471. _activeParticleSystems: SmartArray<IParticleSystem>;
  32472. private _activeSkeletons;
  32473. private _softwareSkinnedMeshes;
  32474. private _renderingManager;
  32475. /** @hidden */
  32476. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  32477. private _transformMatrix;
  32478. private _sceneUbo;
  32479. private _alternateSceneUbo;
  32480. private _viewMatrix;
  32481. private _projectionMatrix;
  32482. private _alternateViewMatrix;
  32483. private _alternateProjectionMatrix;
  32484. private _alternateTransformMatrix;
  32485. private _useAlternateCameraConfiguration;
  32486. private _alternateRendering;
  32487. private _wheelEventName;
  32488. /** @hidden */
  32489. _forcedViewPosition: Nullable<Vector3>;
  32490. /** @hidden */
  32491. readonly _isAlternateRenderingEnabled: boolean;
  32492. private _frustumPlanes;
  32493. /**
  32494. * Gets the list of frustum planes (built from the active camera)
  32495. */
  32496. readonly frustumPlanes: Plane[];
  32497. /**
  32498. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  32499. * This is useful if there are more lights that the maximum simulteanous authorized
  32500. */
  32501. requireLightSorting: boolean;
  32502. /** @hidden */
  32503. readonly useMaterialMeshMap: boolean;
  32504. /** @hidden */
  32505. readonly useClonedMeshhMap: boolean;
  32506. private _pointerOverMesh;
  32507. private _pickedDownMesh;
  32508. private _pickedUpMesh;
  32509. private _externalData;
  32510. private _uid;
  32511. /**
  32512. * @hidden
  32513. * Backing store of defined scene components.
  32514. */
  32515. _components: ISceneComponent[];
  32516. /**
  32517. * @hidden
  32518. * Backing store of defined scene components.
  32519. */
  32520. _serializableComponents: ISceneSerializableComponent[];
  32521. /**
  32522. * List of components to register on the next registration step.
  32523. */
  32524. private _transientComponents;
  32525. /**
  32526. * Registers the transient components if needed.
  32527. */
  32528. private _registerTransientComponents;
  32529. /**
  32530. * @hidden
  32531. * Add a component to the scene.
  32532. * Note that the ccomponent could be registered on th next frame if this is called after
  32533. * the register component stage.
  32534. * @param component Defines the component to add to the scene
  32535. */
  32536. _addComponent(component: ISceneComponent): void;
  32537. /**
  32538. * @hidden
  32539. * Gets a component from the scene.
  32540. * @param name defines the name of the component to retrieve
  32541. * @returns the component or null if not present
  32542. */
  32543. _getComponent(name: string): Nullable<ISceneComponent>;
  32544. /**
  32545. * @hidden
  32546. * Defines the actions happening before camera updates.
  32547. */
  32548. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  32549. /**
  32550. * @hidden
  32551. * Defines the actions happening before clear the canvas.
  32552. */
  32553. _beforeClearStage: Stage<SimpleStageAction>;
  32554. /**
  32555. * @hidden
  32556. * Defines the actions when collecting render targets for the frame.
  32557. */
  32558. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  32559. /**
  32560. * @hidden
  32561. * Defines the actions happening for one camera in the frame.
  32562. */
  32563. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  32564. /**
  32565. * @hidden
  32566. * Defines the actions happening during the per mesh ready checks.
  32567. */
  32568. _isReadyForMeshStage: Stage<MeshStageAction>;
  32569. /**
  32570. * @hidden
  32571. * Defines the actions happening before evaluate active mesh checks.
  32572. */
  32573. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  32574. /**
  32575. * @hidden
  32576. * Defines the actions happening during the evaluate sub mesh checks.
  32577. */
  32578. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  32579. /**
  32580. * @hidden
  32581. * Defines the actions happening during the active mesh stage.
  32582. */
  32583. _activeMeshStage: Stage<ActiveMeshStageAction>;
  32584. /**
  32585. * @hidden
  32586. * Defines the actions happening during the per camera render target step.
  32587. */
  32588. _cameraDrawRenderTargetStage: Stage<CameraStageAction>;
  32589. /**
  32590. * @hidden
  32591. * Defines the actions happening just before the active camera is drawing.
  32592. */
  32593. _beforeCameraDrawStage: Stage<CameraStageAction>;
  32594. /**
  32595. * @hidden
  32596. * Defines the actions happening just before a render target is drawing.
  32597. */
  32598. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  32599. /**
  32600. * @hidden
  32601. * Defines the actions happening just before a rendering group is drawing.
  32602. */
  32603. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  32604. /**
  32605. * @hidden
  32606. * Defines the actions happening just before a mesh is drawing.
  32607. */
  32608. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  32609. /**
  32610. * @hidden
  32611. * Defines the actions happening just after a mesh has been drawn.
  32612. */
  32613. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  32614. /**
  32615. * @hidden
  32616. * Defines the actions happening just after a rendering group has been drawn.
  32617. */
  32618. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  32619. /**
  32620. * @hidden
  32621. * Defines the actions happening just after the active camera has been drawn.
  32622. */
  32623. _afterCameraDrawStage: Stage<CameraStageAction>;
  32624. /**
  32625. * @hidden
  32626. * Defines the actions happening just after a render target has been drawn.
  32627. */
  32628. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  32629. /**
  32630. * @hidden
  32631. * Defines the actions happening just after rendering all cameras and computing intersections.
  32632. */
  32633. _afterRenderStage: Stage<SimpleStageAction>;
  32634. /**
  32635. * @hidden
  32636. * Defines the actions happening when a pointer move event happens.
  32637. */
  32638. _pointerMoveStage: Stage<PointerMoveStageAction>;
  32639. /**
  32640. * @hidden
  32641. * Defines the actions happening when a pointer down event happens.
  32642. */
  32643. _pointerDownStage: Stage<PointerUpDownStageAction>;
  32644. /**
  32645. * @hidden
  32646. * Defines the actions happening when a pointer up event happens.
  32647. */
  32648. _pointerUpStage: Stage<PointerUpDownStageAction>;
  32649. /**
  32650. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  32651. */
  32652. private geometriesByUniqueId;
  32653. /**
  32654. * Creates a new Scene
  32655. * @param engine defines the engine to use to render this scene
  32656. * @param options defines the scene options
  32657. */
  32658. constructor(engine: Engine, options?: SceneOptions);
  32659. private _defaultMeshCandidates;
  32660. /**
  32661. * @hidden
  32662. */
  32663. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  32664. private _defaultSubMeshCandidates;
  32665. /**
  32666. * @hidden
  32667. */
  32668. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  32669. /**
  32670. * Sets the default candidate providers for the scene.
  32671. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  32672. * and getCollidingSubMeshCandidates to their default function
  32673. */
  32674. setDefaultCandidateProviders(): void;
  32675. /**
  32676. * Gets the mesh that is currently under the pointer
  32677. */
  32678. readonly meshUnderPointer: Nullable<AbstractMesh>;
  32679. /**
  32680. * Gets or sets the current on-screen X position of the pointer
  32681. */
  32682. pointerX: number;
  32683. /**
  32684. * Gets or sets the current on-screen Y position of the pointer
  32685. */
  32686. pointerY: number;
  32687. /**
  32688. * Gets the cached material (ie. the latest rendered one)
  32689. * @returns the cached material
  32690. */
  32691. getCachedMaterial(): Nullable<Material>;
  32692. /**
  32693. * Gets the cached effect (ie. the latest rendered one)
  32694. * @returns the cached effect
  32695. */
  32696. getCachedEffect(): Nullable<Effect>;
  32697. /**
  32698. * Gets the cached visibility state (ie. the latest rendered one)
  32699. * @returns the cached visibility state
  32700. */
  32701. getCachedVisibility(): Nullable<number>;
  32702. /**
  32703. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  32704. * @param material defines the current material
  32705. * @param effect defines the current effect
  32706. * @param visibility defines the current visibility state
  32707. * @returns true if one parameter is not cached
  32708. */
  32709. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  32710. /**
  32711. * Gets the engine associated with the scene
  32712. * @returns an Engine
  32713. */
  32714. getEngine(): Engine;
  32715. /**
  32716. * Gets the total number of vertices rendered per frame
  32717. * @returns the total number of vertices rendered per frame
  32718. */
  32719. getTotalVertices(): number;
  32720. /**
  32721. * Gets the performance counter for total vertices
  32722. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32723. */
  32724. readonly totalVerticesPerfCounter: PerfCounter;
  32725. /**
  32726. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  32727. * @returns the total number of active indices rendered per frame
  32728. */
  32729. getActiveIndices(): number;
  32730. /**
  32731. * Gets the performance counter for active indices
  32732. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32733. */
  32734. readonly totalActiveIndicesPerfCounter: PerfCounter;
  32735. /**
  32736. * Gets the total number of active particles rendered per frame
  32737. * @returns the total number of active particles rendered per frame
  32738. */
  32739. getActiveParticles(): number;
  32740. /**
  32741. * Gets the performance counter for active particles
  32742. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32743. */
  32744. readonly activeParticlesPerfCounter: PerfCounter;
  32745. /**
  32746. * Gets the total number of active bones rendered per frame
  32747. * @returns the total number of active bones rendered per frame
  32748. */
  32749. getActiveBones(): number;
  32750. /**
  32751. * Gets the performance counter for active bones
  32752. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32753. */
  32754. readonly activeBonesPerfCounter: PerfCounter;
  32755. /**
  32756. * Gets the array of active meshes
  32757. * @returns an array of AbstractMesh
  32758. */
  32759. getActiveMeshes(): SmartArray<AbstractMesh>;
  32760. /**
  32761. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  32762. * @returns a number
  32763. */
  32764. getAnimationRatio(): number;
  32765. /**
  32766. * Gets an unique Id for the current render phase
  32767. * @returns a number
  32768. */
  32769. getRenderId(): number;
  32770. /**
  32771. * Gets an unique Id for the current frame
  32772. * @returns a number
  32773. */
  32774. getFrameId(): number;
  32775. /** Call this function if you want to manually increment the render Id*/
  32776. incrementRenderId(): void;
  32777. private _updatePointerPosition;
  32778. private _createUbo;
  32779. private _createAlternateUbo;
  32780. private _setRayOnPointerInfo;
  32781. /**
  32782. * Use this method to simulate a pointer move on a mesh
  32783. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32784. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32785. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32786. * @returns the current scene
  32787. */
  32788. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  32789. private _processPointerMove;
  32790. private _checkPrePointerObservable;
  32791. /**
  32792. * Use this method to simulate a pointer down on a mesh
  32793. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32794. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32795. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32796. * @returns the current scene
  32797. */
  32798. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  32799. private _processPointerDown;
  32800. /**
  32801. * Use this method to simulate a pointer up on a mesh
  32802. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32803. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32804. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32805. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  32806. * @returns the current scene
  32807. */
  32808. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  32809. private _processPointerUp;
  32810. /**
  32811. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  32812. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  32813. * @returns true if the pointer was captured
  32814. */
  32815. isPointerCaptured(pointerId?: number): boolean;
  32816. /** @hidden */
  32817. _isPointerSwiping(): boolean;
  32818. /**
  32819. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  32820. * @param attachUp defines if you want to attach events to pointerup
  32821. * @param attachDown defines if you want to attach events to pointerdown
  32822. * @param attachMove defines if you want to attach events to pointermove
  32823. */
  32824. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  32825. /** Detaches all event handlers*/
  32826. detachControl(): void;
  32827. /**
  32828. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  32829. * Delay loaded resources are not taking in account
  32830. * @return true if all required resources are ready
  32831. */
  32832. isReady(): boolean;
  32833. /** Resets all cached information relative to material (including effect and visibility) */
  32834. resetCachedMaterial(): void;
  32835. /**
  32836. * Registers a function to be called before every frame render
  32837. * @param func defines the function to register
  32838. */
  32839. registerBeforeRender(func: () => void): void;
  32840. /**
  32841. * Unregisters a function called before every frame render
  32842. * @param func defines the function to unregister
  32843. */
  32844. unregisterBeforeRender(func: () => void): void;
  32845. /**
  32846. * Registers a function to be called after every frame render
  32847. * @param func defines the function to register
  32848. */
  32849. registerAfterRender(func: () => void): void;
  32850. /**
  32851. * Unregisters a function called after every frame render
  32852. * @param func defines the function to unregister
  32853. */
  32854. unregisterAfterRender(func: () => void): void;
  32855. private _executeOnceBeforeRender;
  32856. /**
  32857. * The provided function will run before render once and will be disposed afterwards.
  32858. * A timeout delay can be provided so that the function will be executed in N ms.
  32859. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  32860. * @param func The function to be executed.
  32861. * @param timeout optional delay in ms
  32862. */
  32863. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  32864. /** @hidden */
  32865. _addPendingData(data: any): void;
  32866. /** @hidden */
  32867. _removePendingData(data: any): void;
  32868. /**
  32869. * Returns the number of items waiting to be loaded
  32870. * @returns the number of items waiting to be loaded
  32871. */
  32872. getWaitingItemsCount(): number;
  32873. /**
  32874. * Returns a boolean indicating if the scene is still loading data
  32875. */
  32876. readonly isLoading: boolean;
  32877. /**
  32878. * Registers a function to be executed when the scene is ready
  32879. * @param {Function} func - the function to be executed
  32880. */
  32881. executeWhenReady(func: () => void): void;
  32882. /**
  32883. * Returns a promise that resolves when the scene is ready
  32884. * @returns A promise that resolves when the scene is ready
  32885. */
  32886. whenReadyAsync(): Promise<void>;
  32887. /** @hidden */
  32888. _checkIsReady(): void;
  32889. /**
  32890. * Gets all animatable attached to the scene
  32891. */
  32892. readonly animatables: Animatable[];
  32893. /**
  32894. * Resets the last animation time frame.
  32895. * Useful to override when animations start running when loading a scene for the first time.
  32896. */
  32897. resetLastAnimationTimeFrame(): void;
  32898. /** @hidden */
  32899. _switchToAlternateCameraConfiguration(active: boolean): void;
  32900. /**
  32901. * Gets the current view matrix
  32902. * @returns a Matrix
  32903. */
  32904. getViewMatrix(): Matrix;
  32905. /**
  32906. * Gets the current projection matrix
  32907. * @returns a Matrix
  32908. */
  32909. getProjectionMatrix(): Matrix;
  32910. /**
  32911. * Gets the current transform matrix
  32912. * @returns a Matrix made of View * Projection
  32913. */
  32914. getTransformMatrix(): Matrix;
  32915. /**
  32916. * Sets the current transform matrix
  32917. * @param view defines the View matrix to use
  32918. * @param projection defines the Projection matrix to use
  32919. */
  32920. setTransformMatrix(view: Matrix, projection: Matrix): void;
  32921. /** @hidden */
  32922. _setAlternateTransformMatrix(view: Matrix, projection: Matrix): void;
  32923. /**
  32924. * Gets the uniform buffer used to store scene data
  32925. * @returns a UniformBuffer
  32926. */
  32927. getSceneUniformBuffer(): UniformBuffer;
  32928. /**
  32929. * Gets an unique (relatively to the current scene) Id
  32930. * @returns an unique number for the scene
  32931. */
  32932. getUniqueId(): number;
  32933. /**
  32934. * Add a mesh to the list of scene's meshes
  32935. * @param newMesh defines the mesh to add
  32936. * @param recursive if all child meshes should also be added to the scene
  32937. */
  32938. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  32939. /**
  32940. * Remove a mesh for the list of scene's meshes
  32941. * @param toRemove defines the mesh to remove
  32942. * @param recursive if all child meshes should also be removed from the scene
  32943. * @returns the index where the mesh was in the mesh list
  32944. */
  32945. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  32946. /**
  32947. * Add a transform node to the list of scene's transform nodes
  32948. * @param newTransformNode defines the transform node to add
  32949. */
  32950. addTransformNode(newTransformNode: TransformNode): void;
  32951. /**
  32952. * Remove a transform node for the list of scene's transform nodes
  32953. * @param toRemove defines the transform node to remove
  32954. * @returns the index where the transform node was in the transform node list
  32955. */
  32956. removeTransformNode(toRemove: TransformNode): number;
  32957. /**
  32958. * Remove a skeleton for the list of scene's skeletons
  32959. * @param toRemove defines the skeleton to remove
  32960. * @returns the index where the skeleton was in the skeleton list
  32961. */
  32962. removeSkeleton(toRemove: Skeleton): number;
  32963. /**
  32964. * Remove a morph target for the list of scene's morph targets
  32965. * @param toRemove defines the morph target to remove
  32966. * @returns the index where the morph target was in the morph target list
  32967. */
  32968. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  32969. /**
  32970. * Remove a light for the list of scene's lights
  32971. * @param toRemove defines the light to remove
  32972. * @returns the index where the light was in the light list
  32973. */
  32974. removeLight(toRemove: Light): number;
  32975. /**
  32976. * Remove a camera for the list of scene's cameras
  32977. * @param toRemove defines the camera to remove
  32978. * @returns the index where the camera was in the camera list
  32979. */
  32980. removeCamera(toRemove: Camera): number;
  32981. /**
  32982. * Remove a particle system for the list of scene's particle systems
  32983. * @param toRemove defines the particle system to remove
  32984. * @returns the index where the particle system was in the particle system list
  32985. */
  32986. removeParticleSystem(toRemove: IParticleSystem): number;
  32987. /**
  32988. * Remove a animation for the list of scene's animations
  32989. * @param toRemove defines the animation to remove
  32990. * @returns the index where the animation was in the animation list
  32991. */
  32992. removeAnimation(toRemove: Animation): number;
  32993. /**
  32994. * Removes the given animation group from this scene.
  32995. * @param toRemove The animation group to remove
  32996. * @returns The index of the removed animation group
  32997. */
  32998. removeAnimationGroup(toRemove: AnimationGroup): number;
  32999. /**
  33000. * Removes the given multi-material from this scene.
  33001. * @param toRemove The multi-material to remove
  33002. * @returns The index of the removed multi-material
  33003. */
  33004. removeMultiMaterial(toRemove: MultiMaterial): number;
  33005. /**
  33006. * Removes the given material from this scene.
  33007. * @param toRemove The material to remove
  33008. * @returns The index of the removed material
  33009. */
  33010. removeMaterial(toRemove: Material): number;
  33011. /**
  33012. * Removes the given action manager from this scene.
  33013. * @param toRemove The action manager to remove
  33014. * @returns The index of the removed action manager
  33015. */
  33016. removeActionManager(toRemove: AbstractActionManager): number;
  33017. /**
  33018. * Removes the given texture from this scene.
  33019. * @param toRemove The texture to remove
  33020. * @returns The index of the removed texture
  33021. */
  33022. removeTexture(toRemove: BaseTexture): number;
  33023. /**
  33024. * Adds the given light to this scene
  33025. * @param newLight The light to add
  33026. */
  33027. addLight(newLight: Light): void;
  33028. /**
  33029. * Sorts the list list based on light priorities
  33030. */
  33031. sortLightsByPriority(): void;
  33032. /**
  33033. * Adds the given camera to this scene
  33034. * @param newCamera The camera to add
  33035. */
  33036. addCamera(newCamera: Camera): void;
  33037. /**
  33038. * Adds the given skeleton to this scene
  33039. * @param newSkeleton The skeleton to add
  33040. */
  33041. addSkeleton(newSkeleton: Skeleton): void;
  33042. /**
  33043. * Adds the given particle system to this scene
  33044. * @param newParticleSystem The particle system to add
  33045. */
  33046. addParticleSystem(newParticleSystem: IParticleSystem): void;
  33047. /**
  33048. * Adds the given animation to this scene
  33049. * @param newAnimation The animation to add
  33050. */
  33051. addAnimation(newAnimation: Animation): void;
  33052. /**
  33053. * Adds the given animation group to this scene.
  33054. * @param newAnimationGroup The animation group to add
  33055. */
  33056. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  33057. /**
  33058. * Adds the given multi-material to this scene
  33059. * @param newMultiMaterial The multi-material to add
  33060. */
  33061. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  33062. /**
  33063. * Adds the given material to this scene
  33064. * @param newMaterial The material to add
  33065. */
  33066. addMaterial(newMaterial: Material): void;
  33067. /**
  33068. * Adds the given morph target to this scene
  33069. * @param newMorphTargetManager The morph target to add
  33070. */
  33071. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  33072. /**
  33073. * Adds the given geometry to this scene
  33074. * @param newGeometry The geometry to add
  33075. */
  33076. addGeometry(newGeometry: Geometry): void;
  33077. /**
  33078. * Adds the given action manager to this scene
  33079. * @param newActionManager The action manager to add
  33080. */
  33081. addActionManager(newActionManager: AbstractActionManager): void;
  33082. /**
  33083. * Adds the given texture to this scene.
  33084. * @param newTexture The texture to add
  33085. */
  33086. addTexture(newTexture: BaseTexture): void;
  33087. /**
  33088. * Switch active camera
  33089. * @param newCamera defines the new active camera
  33090. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  33091. */
  33092. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  33093. /**
  33094. * sets the active camera of the scene using its ID
  33095. * @param id defines the camera's ID
  33096. * @return the new active camera or null if none found.
  33097. */
  33098. setActiveCameraByID(id: string): Nullable<Camera>;
  33099. /**
  33100. * sets the active camera of the scene using its name
  33101. * @param name defines the camera's name
  33102. * @returns the new active camera or null if none found.
  33103. */
  33104. setActiveCameraByName(name: string): Nullable<Camera>;
  33105. /**
  33106. * get an animation group using its name
  33107. * @param name defines the material's name
  33108. * @return the animation group or null if none found.
  33109. */
  33110. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  33111. /**
  33112. * get a material using its id
  33113. * @param id defines the material's ID
  33114. * @return the material or null if none found.
  33115. */
  33116. getMaterialByID(id: string): Nullable<Material>;
  33117. /**
  33118. * Gets a material using its name
  33119. * @param name defines the material's name
  33120. * @return the material or null if none found.
  33121. */
  33122. getMaterialByName(name: string): Nullable<Material>;
  33123. /**
  33124. * Gets a camera using its id
  33125. * @param id defines the id to look for
  33126. * @returns the camera or null if not found
  33127. */
  33128. getCameraByID(id: string): Nullable<Camera>;
  33129. /**
  33130. * Gets a camera using its unique id
  33131. * @param uniqueId defines the unique id to look for
  33132. * @returns the camera or null if not found
  33133. */
  33134. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  33135. /**
  33136. * Gets a camera using its name
  33137. * @param name defines the camera's name
  33138. * @return the camera or null if none found.
  33139. */
  33140. getCameraByName(name: string): Nullable<Camera>;
  33141. /**
  33142. * Gets a bone using its id
  33143. * @param id defines the bone's id
  33144. * @return the bone or null if not found
  33145. */
  33146. getBoneByID(id: string): Nullable<Bone>;
  33147. /**
  33148. * Gets a bone using its id
  33149. * @param name defines the bone's name
  33150. * @return the bone or null if not found
  33151. */
  33152. getBoneByName(name: string): Nullable<Bone>;
  33153. /**
  33154. * Gets a light node using its name
  33155. * @param name defines the the light's name
  33156. * @return the light or null if none found.
  33157. */
  33158. getLightByName(name: string): Nullable<Light>;
  33159. /**
  33160. * Gets a light node using its id
  33161. * @param id defines the light's id
  33162. * @return the light or null if none found.
  33163. */
  33164. getLightByID(id: string): Nullable<Light>;
  33165. /**
  33166. * Gets a light node using its scene-generated unique ID
  33167. * @param uniqueId defines the light's unique id
  33168. * @return the light or null if none found.
  33169. */
  33170. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  33171. /**
  33172. * Gets a particle system by id
  33173. * @param id defines the particle system id
  33174. * @return the corresponding system or null if none found
  33175. */
  33176. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  33177. /**
  33178. * Gets a geometry using its ID
  33179. * @param id defines the geometry's id
  33180. * @return the geometry or null if none found.
  33181. */
  33182. getGeometryByID(id: string): Nullable<Geometry>;
  33183. private _getGeometryByUniqueID;
  33184. /**
  33185. * Add a new geometry to this scene
  33186. * @param geometry defines the geometry to be added to the scene.
  33187. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  33188. * @return a boolean defining if the geometry was added or not
  33189. */
  33190. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  33191. /**
  33192. * Removes an existing geometry
  33193. * @param geometry defines the geometry to be removed from the scene
  33194. * @return a boolean defining if the geometry was removed or not
  33195. */
  33196. removeGeometry(geometry: Geometry): boolean;
  33197. /**
  33198. * Gets the list of geometries attached to the scene
  33199. * @returns an array of Geometry
  33200. */
  33201. getGeometries(): Geometry[];
  33202. /**
  33203. * Gets the first added mesh found of a given ID
  33204. * @param id defines the id to search for
  33205. * @return the mesh found or null if not found at all
  33206. */
  33207. getMeshByID(id: string): Nullable<AbstractMesh>;
  33208. /**
  33209. * Gets a list of meshes using their id
  33210. * @param id defines the id to search for
  33211. * @returns a list of meshes
  33212. */
  33213. getMeshesByID(id: string): Array<AbstractMesh>;
  33214. /**
  33215. * Gets the first added transform node found of a given ID
  33216. * @param id defines the id to search for
  33217. * @return the found transform node or null if not found at all.
  33218. */
  33219. getTransformNodeByID(id: string): Nullable<TransformNode>;
  33220. /**
  33221. * Gets a list of transform nodes using their id
  33222. * @param id defines the id to search for
  33223. * @returns a list of transform nodes
  33224. */
  33225. getTransformNodesByID(id: string): Array<TransformNode>;
  33226. /**
  33227. * Gets a mesh with its auto-generated unique id
  33228. * @param uniqueId defines the unique id to search for
  33229. * @return the found mesh or null if not found at all.
  33230. */
  33231. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  33232. /**
  33233. * Gets a the last added mesh using a given id
  33234. * @param id defines the id to search for
  33235. * @return the found mesh or null if not found at all.
  33236. */
  33237. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  33238. /**
  33239. * Gets a the last added node (Mesh, Camera, Light) using a given id
  33240. * @param id defines the id to search for
  33241. * @return the found node or null if not found at all
  33242. */
  33243. getLastEntryByID(id: string): Nullable<Node>;
  33244. /**
  33245. * Gets a node (Mesh, Camera, Light) using a given id
  33246. * @param id defines the id to search for
  33247. * @return the found node or null if not found at all
  33248. */
  33249. getNodeByID(id: string): Nullable<Node>;
  33250. /**
  33251. * Gets a node (Mesh, Camera, Light) using a given name
  33252. * @param name defines the name to search for
  33253. * @return the found node or null if not found at all.
  33254. */
  33255. getNodeByName(name: string): Nullable<Node>;
  33256. /**
  33257. * Gets a mesh using a given name
  33258. * @param name defines the name to search for
  33259. * @return the found mesh or null if not found at all.
  33260. */
  33261. getMeshByName(name: string): Nullable<AbstractMesh>;
  33262. /**
  33263. * Gets a transform node using a given name
  33264. * @param name defines the name to search for
  33265. * @return the found transform node or null if not found at all.
  33266. */
  33267. getTransformNodeByName(name: string): Nullable<TransformNode>;
  33268. /**
  33269. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  33270. * @param id defines the id to search for
  33271. * @return the found skeleton or null if not found at all.
  33272. */
  33273. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  33274. /**
  33275. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  33276. * @param id defines the id to search for
  33277. * @return the found skeleton or null if not found at all.
  33278. */
  33279. getSkeletonById(id: string): Nullable<Skeleton>;
  33280. /**
  33281. * Gets a skeleton using a given name
  33282. * @param name defines the name to search for
  33283. * @return the found skeleton or null if not found at all.
  33284. */
  33285. getSkeletonByName(name: string): Nullable<Skeleton>;
  33286. /**
  33287. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  33288. * @param id defines the id to search for
  33289. * @return the found morph target manager or null if not found at all.
  33290. */
  33291. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  33292. /**
  33293. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  33294. * @param id defines the id to search for
  33295. * @return the found morph target or null if not found at all.
  33296. */
  33297. getMorphTargetById(id: string): Nullable<MorphTarget>;
  33298. /**
  33299. * Gets a boolean indicating if the given mesh is active
  33300. * @param mesh defines the mesh to look for
  33301. * @returns true if the mesh is in the active list
  33302. */
  33303. isActiveMesh(mesh: AbstractMesh): boolean;
  33304. /**
  33305. * Return a unique id as a string which can serve as an identifier for the scene
  33306. */
  33307. readonly uid: string;
  33308. /**
  33309. * Add an externaly attached data from its key.
  33310. * This method call will fail and return false, if such key already exists.
  33311. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  33312. * @param key the unique key that identifies the data
  33313. * @param data the data object to associate to the key for this Engine instance
  33314. * @return true if no such key were already present and the data was added successfully, false otherwise
  33315. */
  33316. addExternalData<T>(key: string, data: T): boolean;
  33317. /**
  33318. * Get an externaly attached data from its key
  33319. * @param key the unique key that identifies the data
  33320. * @return the associated data, if present (can be null), or undefined if not present
  33321. */
  33322. getExternalData<T>(key: string): Nullable<T>;
  33323. /**
  33324. * Get an externaly attached data from its key, create it using a factory if it's not already present
  33325. * @param key the unique key that identifies the data
  33326. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  33327. * @return the associated data, can be null if the factory returned null.
  33328. */
  33329. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  33330. /**
  33331. * Remove an externaly attached data from the Engine instance
  33332. * @param key the unique key that identifies the data
  33333. * @return true if the data was successfully removed, false if it doesn't exist
  33334. */
  33335. removeExternalData(key: string): boolean;
  33336. private _evaluateSubMesh;
  33337. /**
  33338. * Clear the processed materials smart array preventing retention point in material dispose.
  33339. */
  33340. freeProcessedMaterials(): void;
  33341. private _preventFreeActiveMeshesAndRenderingGroups;
  33342. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  33343. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  33344. * when disposing several meshes in a row or a hierarchy of meshes.
  33345. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  33346. */
  33347. blockfreeActiveMeshesAndRenderingGroups: boolean;
  33348. /**
  33349. * Clear the active meshes smart array preventing retention point in mesh dispose.
  33350. */
  33351. freeActiveMeshes(): void;
  33352. /**
  33353. * Clear the info related to rendering groups preventing retention points during dispose.
  33354. */
  33355. freeRenderingGroups(): void;
  33356. /** @hidden */
  33357. _isInIntermediateRendering(): boolean;
  33358. /**
  33359. * Lambda returning the list of potentially active meshes.
  33360. */
  33361. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  33362. /**
  33363. * Lambda returning the list of potentially active sub meshes.
  33364. */
  33365. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  33366. /**
  33367. * Lambda returning the list of potentially intersecting sub meshes.
  33368. */
  33369. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  33370. /**
  33371. * Lambda returning the list of potentially colliding sub meshes.
  33372. */
  33373. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  33374. private _activeMeshesFrozen;
  33375. /**
  33376. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  33377. * @returns the current scene
  33378. */
  33379. freezeActiveMeshes(): Scene;
  33380. /**
  33381. * Use this function to restart evaluating active meshes on every frame
  33382. * @returns the current scene
  33383. */
  33384. unfreezeActiveMeshes(): Scene;
  33385. private _evaluateActiveMeshes;
  33386. private _activeMesh;
  33387. /**
  33388. * Update the transform matrix to update from the current active camera
  33389. * @param force defines a boolean used to force the update even if cache is up to date
  33390. */
  33391. updateTransformMatrix(force?: boolean): void;
  33392. /**
  33393. * 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)
  33394. * @param alternateCamera defines the camera to use
  33395. */
  33396. updateAlternateTransformMatrix(alternateCamera: Camera): void;
  33397. /** @hidden */
  33398. _allowPostProcessClearColor: boolean;
  33399. private _renderForCamera;
  33400. private _processSubCameras;
  33401. private _checkIntersections;
  33402. /** @hidden */
  33403. _advancePhysicsEngineStep(step: number): void;
  33404. /**
  33405. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  33406. */
  33407. getDeterministicFrameTime: () => number;
  33408. /** @hidden */
  33409. _animate(): void;
  33410. /**
  33411. * Render the scene
  33412. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  33413. */
  33414. render(updateCameras?: boolean): void;
  33415. /**
  33416. * Freeze all materials
  33417. * A frozen material will not be updatable but should be faster to render
  33418. */
  33419. freezeMaterials(): void;
  33420. /**
  33421. * Unfreeze all materials
  33422. * A frozen material will not be updatable but should be faster to render
  33423. */
  33424. unfreezeMaterials(): void;
  33425. /**
  33426. * Releases all held ressources
  33427. */
  33428. dispose(): void;
  33429. /**
  33430. * Gets if the scene is already disposed
  33431. */
  33432. readonly isDisposed: boolean;
  33433. /**
  33434. * Call this function to reduce memory footprint of the scene.
  33435. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  33436. */
  33437. clearCachedVertexData(): void;
  33438. /**
  33439. * This function will remove the local cached buffer data from texture.
  33440. * It will save memory but will prevent the texture from being rebuilt
  33441. */
  33442. cleanCachedTextureBuffer(): void;
  33443. /**
  33444. * Get the world extend vectors with an optional filter
  33445. *
  33446. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  33447. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  33448. */
  33449. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  33450. min: Vector3;
  33451. max: Vector3;
  33452. };
  33453. /**
  33454. * Creates a ray that can be used to pick in the scene
  33455. * @param x defines the x coordinate of the origin (on-screen)
  33456. * @param y defines the y coordinate of the origin (on-screen)
  33457. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  33458. * @param camera defines the camera to use for the picking
  33459. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  33460. * @returns a Ray
  33461. */
  33462. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  33463. /**
  33464. * Creates a ray that can be used to pick in the scene
  33465. * @param x defines the x coordinate of the origin (on-screen)
  33466. * @param y defines the y coordinate of the origin (on-screen)
  33467. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  33468. * @param result defines the ray where to store the picking ray
  33469. * @param camera defines the camera to use for the picking
  33470. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  33471. * @returns the current scene
  33472. */
  33473. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  33474. /**
  33475. * Creates a ray that can be used to pick in the scene
  33476. * @param x defines the x coordinate of the origin (on-screen)
  33477. * @param y defines the y coordinate of the origin (on-screen)
  33478. * @param camera defines the camera to use for the picking
  33479. * @returns a Ray
  33480. */
  33481. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  33482. /**
  33483. * Creates a ray that can be used to pick in the scene
  33484. * @param x defines the x coordinate of the origin (on-screen)
  33485. * @param y defines the y coordinate of the origin (on-screen)
  33486. * @param result defines the ray where to store the picking ray
  33487. * @param camera defines the camera to use for the picking
  33488. * @returns the current scene
  33489. */
  33490. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  33491. /** Launch a ray to try to pick a mesh in the scene
  33492. * @param x position on screen
  33493. * @param y position on screen
  33494. * @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
  33495. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  33496. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  33497. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33498. * @returns a PickingInfo
  33499. */
  33500. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: (p0: Vector3, p1: Vector3, p2: Vector3) => boolean): Nullable<PickingInfo>;
  33501. /** Use the given ray to pick a mesh in the scene
  33502. * @param ray The ray to use to pick meshes
  33503. * @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
  33504. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  33505. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33506. * @returns a PickingInfo
  33507. */
  33508. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  33509. /**
  33510. * Launch a ray to try to pick a mesh in the scene
  33511. * @param x X position on screen
  33512. * @param y Y position on screen
  33513. * @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
  33514. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  33515. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33516. * @returns an array of PickingInfo
  33517. */
  33518. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  33519. /**
  33520. * Launch a ray to try to pick a mesh in the scene
  33521. * @param ray Ray to use
  33522. * @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
  33523. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33524. * @returns an array of PickingInfo
  33525. */
  33526. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  33527. /**
  33528. * Force the value of meshUnderPointer
  33529. * @param mesh defines the mesh to use
  33530. */
  33531. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  33532. /**
  33533. * Gets the mesh under the pointer
  33534. * @returns a Mesh or null if no mesh is under the pointer
  33535. */
  33536. getPointerOverMesh(): Nullable<AbstractMesh>;
  33537. /** @hidden */
  33538. _rebuildGeometries(): void;
  33539. /** @hidden */
  33540. _rebuildTextures(): void;
  33541. private _getByTags;
  33542. /**
  33543. * Get a list of meshes by tags
  33544. * @param tagsQuery defines the tags query to use
  33545. * @param forEach defines a predicate used to filter results
  33546. * @returns an array of Mesh
  33547. */
  33548. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  33549. /**
  33550. * Get a list of cameras by tags
  33551. * @param tagsQuery defines the tags query to use
  33552. * @param forEach defines a predicate used to filter results
  33553. * @returns an array of Camera
  33554. */
  33555. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  33556. /**
  33557. * Get a list of lights by tags
  33558. * @param tagsQuery defines the tags query to use
  33559. * @param forEach defines a predicate used to filter results
  33560. * @returns an array of Light
  33561. */
  33562. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  33563. /**
  33564. * Get a list of materials by tags
  33565. * @param tagsQuery defines the tags query to use
  33566. * @param forEach defines a predicate used to filter results
  33567. * @returns an array of Material
  33568. */
  33569. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  33570. /**
  33571. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  33572. * This allowed control for front to back rendering or reversly depending of the special needs.
  33573. *
  33574. * @param renderingGroupId The rendering group id corresponding to its index
  33575. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  33576. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  33577. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  33578. */
  33579. 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;
  33580. /**
  33581. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  33582. *
  33583. * @param renderingGroupId The rendering group id corresponding to its index
  33584. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  33585. * @param depth Automatically clears depth between groups if true and autoClear is true.
  33586. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  33587. */
  33588. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  33589. /**
  33590. * Gets the current auto clear configuration for one rendering group of the rendering
  33591. * manager.
  33592. * @param index the rendering group index to get the information for
  33593. * @returns The auto clear setup for the requested rendering group
  33594. */
  33595. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  33596. private _blockMaterialDirtyMechanism;
  33597. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  33598. blockMaterialDirtyMechanism: boolean;
  33599. /**
  33600. * Will flag all materials as dirty to trigger new shader compilation
  33601. * @param flag defines the flag used to specify which material part must be marked as dirty
  33602. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  33603. */
  33604. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  33605. /** @hidden */
  33606. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (request?: XMLHttpRequest, exception?: any) => void): IFileRequest;
  33607. /** @hidden */
  33608. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  33609. }
  33610. }
  33611. declare module "babylonjs/assetContainer" {
  33612. import { AbstractScene } from "babylonjs/abstractScene";
  33613. import { Scene } from "babylonjs/scene";
  33614. import { Mesh } from "babylonjs/Meshes/mesh";
  33615. /**
  33616. * Set of assets to keep when moving a scene into an asset container.
  33617. */
  33618. export class KeepAssets extends AbstractScene {
  33619. }
  33620. /**
  33621. * Container with a set of assets that can be added or removed from a scene.
  33622. */
  33623. export class AssetContainer extends AbstractScene {
  33624. /**
  33625. * The scene the AssetContainer belongs to.
  33626. */
  33627. scene: Scene;
  33628. /**
  33629. * Instantiates an AssetContainer.
  33630. * @param scene The scene the AssetContainer belongs to.
  33631. */
  33632. constructor(scene: Scene);
  33633. /**
  33634. * Adds all the assets from the container to the scene.
  33635. */
  33636. addAllToScene(): void;
  33637. /**
  33638. * Removes all the assets in the container from the scene
  33639. */
  33640. removeAllFromScene(): void;
  33641. /**
  33642. * Disposes all the assets in the container
  33643. */
  33644. dispose(): void;
  33645. private _moveAssets;
  33646. /**
  33647. * Removes all the assets contained in the scene and adds them to the container.
  33648. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  33649. */
  33650. moveAllFromScene(keepAssets?: KeepAssets): void;
  33651. /**
  33652. * 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.
  33653. * @returns the root mesh
  33654. */
  33655. createRootMesh(): Mesh;
  33656. }
  33657. }
  33658. declare module "babylonjs/abstractScene" {
  33659. import { Scene } from "babylonjs/scene";
  33660. import { Nullable } from "babylonjs/types";
  33661. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33662. import { TransformNode } from "babylonjs/Meshes/transformNode";
  33663. import { Geometry } from "babylonjs/Meshes/geometry";
  33664. import { Skeleton } from "babylonjs/Bones/skeleton";
  33665. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  33666. import { AssetContainer } from "babylonjs/assetContainer";
  33667. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  33668. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  33669. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  33670. import { Material } from "babylonjs/Materials/material";
  33671. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  33672. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  33673. import { Camera } from "babylonjs/Cameras/camera";
  33674. import { Light } from "babylonjs/Lights/light";
  33675. import { Node } from "babylonjs/node";
  33676. import { Animation } from "babylonjs/Animations/animation";
  33677. /**
  33678. * Defines how the parser contract is defined.
  33679. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  33680. */
  33681. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  33682. /**
  33683. * Defines how the individual parser contract is defined.
  33684. * These parser can parse an individual asset
  33685. */
  33686. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  33687. /**
  33688. * Base class of the scene acting as a container for the different elements composing a scene.
  33689. * This class is dynamically extended by the different components of the scene increasing
  33690. * flexibility and reducing coupling
  33691. */
  33692. export abstract class AbstractScene {
  33693. /**
  33694. * Stores the list of available parsers in the application.
  33695. */
  33696. private static _BabylonFileParsers;
  33697. /**
  33698. * Stores the list of available individual parsers in the application.
  33699. */
  33700. private static _IndividualBabylonFileParsers;
  33701. /**
  33702. * Adds a parser in the list of available ones
  33703. * @param name Defines the name of the parser
  33704. * @param parser Defines the parser to add
  33705. */
  33706. static AddParser(name: string, parser: BabylonFileParser): void;
  33707. /**
  33708. * Gets a general parser from the list of avaialble ones
  33709. * @param name Defines the name of the parser
  33710. * @returns the requested parser or null
  33711. */
  33712. static GetParser(name: string): Nullable<BabylonFileParser>;
  33713. /**
  33714. * Adds n individual parser in the list of available ones
  33715. * @param name Defines the name of the parser
  33716. * @param parser Defines the parser to add
  33717. */
  33718. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  33719. /**
  33720. * Gets an individual parser from the list of avaialble ones
  33721. * @param name Defines the name of the parser
  33722. * @returns the requested parser or null
  33723. */
  33724. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  33725. /**
  33726. * Parser json data and populate both a scene and its associated container object
  33727. * @param jsonData Defines the data to parse
  33728. * @param scene Defines the scene to parse the data for
  33729. * @param container Defines the container attached to the parsing sequence
  33730. * @param rootUrl Defines the root url of the data
  33731. */
  33732. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  33733. /**
  33734. * Gets the list of root nodes (ie. nodes with no parent)
  33735. */
  33736. rootNodes: Node[];
  33737. /** All of the cameras added to this scene
  33738. * @see http://doc.babylonjs.com/babylon101/cameras
  33739. */
  33740. cameras: Camera[];
  33741. /**
  33742. * All of the lights added to this scene
  33743. * @see http://doc.babylonjs.com/babylon101/lights
  33744. */
  33745. lights: Light[];
  33746. /**
  33747. * All of the (abstract) meshes added to this scene
  33748. */
  33749. meshes: AbstractMesh[];
  33750. /**
  33751. * The list of skeletons added to the scene
  33752. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  33753. */
  33754. skeletons: Skeleton[];
  33755. /**
  33756. * All of the particle systems added to this scene
  33757. * @see http://doc.babylonjs.com/babylon101/particles
  33758. */
  33759. particleSystems: IParticleSystem[];
  33760. /**
  33761. * Gets a list of Animations associated with the scene
  33762. */
  33763. animations: Animation[];
  33764. /**
  33765. * All of the animation groups added to this scene
  33766. * @see http://doc.babylonjs.com/how_to/group
  33767. */
  33768. animationGroups: AnimationGroup[];
  33769. /**
  33770. * All of the multi-materials added to this scene
  33771. * @see http://doc.babylonjs.com/how_to/multi_materials
  33772. */
  33773. multiMaterials: MultiMaterial[];
  33774. /**
  33775. * All of the materials added to this scene
  33776. * In the context of a Scene, it is not supposed to be modified manually.
  33777. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  33778. * Note also that the order of the Material wihin the array is not significant and might change.
  33779. * @see http://doc.babylonjs.com/babylon101/materials
  33780. */
  33781. materials: Material[];
  33782. /**
  33783. * The list of morph target managers added to the scene
  33784. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  33785. */
  33786. morphTargetManagers: MorphTargetManager[];
  33787. /**
  33788. * The list of geometries used in the scene.
  33789. */
  33790. geometries: Geometry[];
  33791. /**
  33792. * All of the tranform nodes added to this scene
  33793. * In the context of a Scene, it is not supposed to be modified manually.
  33794. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  33795. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  33796. * @see http://doc.babylonjs.com/how_to/transformnode
  33797. */
  33798. transformNodes: TransformNode[];
  33799. /**
  33800. * ActionManagers available on the scene.
  33801. */
  33802. actionManagers: AbstractActionManager[];
  33803. /**
  33804. * Textures to keep.
  33805. */
  33806. textures: BaseTexture[];
  33807. }
  33808. }
  33809. declare module "babylonjs/Audio/sound" {
  33810. import { Observable } from "babylonjs/Misc/observable";
  33811. import { Vector3 } from "babylonjs/Maths/math";
  33812. import { Nullable } from "babylonjs/types";
  33813. import { Scene } from "babylonjs/scene";
  33814. import { TransformNode } from "babylonjs/Meshes/transformNode";
  33815. /**
  33816. * Defines a sound that can be played in the application.
  33817. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  33818. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33819. */
  33820. export class Sound {
  33821. /**
  33822. * The name of the sound in the scene.
  33823. */
  33824. name: string;
  33825. /**
  33826. * Does the sound autoplay once loaded.
  33827. */
  33828. autoplay: boolean;
  33829. /**
  33830. * Does the sound loop after it finishes playing once.
  33831. */
  33832. loop: boolean;
  33833. /**
  33834. * Does the sound use a custom attenuation curve to simulate the falloff
  33835. * happening when the source gets further away from the camera.
  33836. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  33837. */
  33838. useCustomAttenuation: boolean;
  33839. /**
  33840. * The sound track id this sound belongs to.
  33841. */
  33842. soundTrackId: number;
  33843. /**
  33844. * Is this sound currently played.
  33845. */
  33846. isPlaying: boolean;
  33847. /**
  33848. * Is this sound currently paused.
  33849. */
  33850. isPaused: boolean;
  33851. /**
  33852. * Does this sound enables spatial sound.
  33853. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33854. */
  33855. spatialSound: boolean;
  33856. /**
  33857. * Define the reference distance the sound should be heard perfectly.
  33858. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33859. */
  33860. refDistance: number;
  33861. /**
  33862. * Define the roll off factor of spatial sounds.
  33863. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33864. */
  33865. rolloffFactor: number;
  33866. /**
  33867. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  33868. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33869. */
  33870. maxDistance: number;
  33871. /**
  33872. * Define the distance attenuation model the sound will follow.
  33873. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33874. */
  33875. distanceModel: string;
  33876. /**
  33877. * @hidden
  33878. * Back Compat
  33879. **/
  33880. onended: () => any;
  33881. /**
  33882. * Observable event when the current playing sound finishes.
  33883. */
  33884. onEndedObservable: Observable<Sound>;
  33885. private _panningModel;
  33886. private _playbackRate;
  33887. private _streaming;
  33888. private _startTime;
  33889. private _startOffset;
  33890. private _position;
  33891. /** @hidden */
  33892. _positionInEmitterSpace: boolean;
  33893. private _localDirection;
  33894. private _volume;
  33895. private _isReadyToPlay;
  33896. private _isDirectional;
  33897. private _readyToPlayCallback;
  33898. private _audioBuffer;
  33899. private _soundSource;
  33900. private _streamingSource;
  33901. private _soundPanner;
  33902. private _soundGain;
  33903. private _inputAudioNode;
  33904. private _outputAudioNode;
  33905. private _coneInnerAngle;
  33906. private _coneOuterAngle;
  33907. private _coneOuterGain;
  33908. private _scene;
  33909. private _connectedTransformNode;
  33910. private _customAttenuationFunction;
  33911. private _registerFunc;
  33912. private _isOutputConnected;
  33913. private _htmlAudioElement;
  33914. private _urlType;
  33915. /** @hidden */
  33916. static _SceneComponentInitialization: (scene: Scene) => void;
  33917. /**
  33918. * Create a sound and attach it to a scene
  33919. * @param name Name of your sound
  33920. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  33921. * @param scene defines the scene the sound belongs to
  33922. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  33923. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  33924. */
  33925. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  33926. /**
  33927. * Release the sound and its associated resources
  33928. */
  33929. dispose(): void;
  33930. /**
  33931. * Gets if the sounds is ready to be played or not.
  33932. * @returns true if ready, otherwise false
  33933. */
  33934. isReady(): boolean;
  33935. private _soundLoaded;
  33936. /**
  33937. * Sets the data of the sound from an audiobuffer
  33938. * @param audioBuffer The audioBuffer containing the data
  33939. */
  33940. setAudioBuffer(audioBuffer: AudioBuffer): void;
  33941. /**
  33942. * Updates the current sounds options such as maxdistance, loop...
  33943. * @param options A JSON object containing values named as the object properties
  33944. */
  33945. updateOptions(options: any): void;
  33946. private _createSpatialParameters;
  33947. private _updateSpatialParameters;
  33948. /**
  33949. * Switch the panning model to HRTF:
  33950. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  33951. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33952. */
  33953. switchPanningModelToHRTF(): void;
  33954. /**
  33955. * Switch the panning model to Equal Power:
  33956. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  33957. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33958. */
  33959. switchPanningModelToEqualPower(): void;
  33960. private _switchPanningModel;
  33961. /**
  33962. * Connect this sound to a sound track audio node like gain...
  33963. * @param soundTrackAudioNode the sound track audio node to connect to
  33964. */
  33965. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  33966. /**
  33967. * Transform this sound into a directional source
  33968. * @param coneInnerAngle Size of the inner cone in degree
  33969. * @param coneOuterAngle Size of the outer cone in degree
  33970. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  33971. */
  33972. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  33973. /**
  33974. * Gets or sets the inner angle for the directional cone.
  33975. */
  33976. /**
  33977. * Gets or sets the inner angle for the directional cone.
  33978. */
  33979. directionalConeInnerAngle: number;
  33980. /**
  33981. * Gets or sets the outer angle for the directional cone.
  33982. */
  33983. /**
  33984. * Gets or sets the outer angle for the directional cone.
  33985. */
  33986. directionalConeOuterAngle: number;
  33987. /**
  33988. * Sets the position of the emitter if spatial sound is enabled
  33989. * @param newPosition Defines the new posisiton
  33990. */
  33991. setPosition(newPosition: Vector3): void;
  33992. /**
  33993. * Sets the local direction of the emitter if spatial sound is enabled
  33994. * @param newLocalDirection Defines the new local direction
  33995. */
  33996. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  33997. private _updateDirection;
  33998. /** @hidden */
  33999. updateDistanceFromListener(): void;
  34000. /**
  34001. * Sets a new custom attenuation function for the sound.
  34002. * @param callback Defines the function used for the attenuation
  34003. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  34004. */
  34005. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  34006. /**
  34007. * Play the sound
  34008. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  34009. * @param offset (optional) Start the sound setting it at a specific time
  34010. */
  34011. play(time?: number, offset?: number): void;
  34012. private _onended;
  34013. /**
  34014. * Stop the sound
  34015. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  34016. */
  34017. stop(time?: number): void;
  34018. /**
  34019. * Put the sound in pause
  34020. */
  34021. pause(): void;
  34022. /**
  34023. * Sets a dedicated volume for this sounds
  34024. * @param newVolume Define the new volume of the sound
  34025. * @param time Define in how long the sound should be at this value
  34026. */
  34027. setVolume(newVolume: number, time?: number): void;
  34028. /**
  34029. * Set the sound play back rate
  34030. * @param newPlaybackRate Define the playback rate the sound should be played at
  34031. */
  34032. setPlaybackRate(newPlaybackRate: number): void;
  34033. /**
  34034. * Gets the volume of the sound.
  34035. * @returns the volume of the sound
  34036. */
  34037. getVolume(): number;
  34038. /**
  34039. * Attach the sound to a dedicated mesh
  34040. * @param transformNode The transform node to connect the sound with
  34041. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  34042. */
  34043. attachToMesh(transformNode: TransformNode): void;
  34044. /**
  34045. * Detach the sound from the previously attached mesh
  34046. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  34047. */
  34048. detachFromMesh(): void;
  34049. private _onRegisterAfterWorldMatrixUpdate;
  34050. /**
  34051. * Clone the current sound in the scene.
  34052. * @returns the new sound clone
  34053. */
  34054. clone(): Nullable<Sound>;
  34055. /**
  34056. * Gets the current underlying audio buffer containing the data
  34057. * @returns the audio buffer
  34058. */
  34059. getAudioBuffer(): Nullable<AudioBuffer>;
  34060. /**
  34061. * Serializes the Sound in a JSON representation
  34062. * @returns the JSON representation of the sound
  34063. */
  34064. serialize(): any;
  34065. /**
  34066. * Parse a JSON representation of a sound to innstantiate in a given scene
  34067. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  34068. * @param scene Define the scene the new parsed sound should be created in
  34069. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  34070. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  34071. * @returns the newly parsed sound
  34072. */
  34073. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  34074. }
  34075. }
  34076. declare module "babylonjs/Actions/directAudioActions" {
  34077. import { Action } from "babylonjs/Actions/action";
  34078. import { Condition } from "babylonjs/Actions/condition";
  34079. import { Sound } from "babylonjs/Audio/sound";
  34080. /**
  34081. * This defines an action helpful to play a defined sound on a triggered action.
  34082. */
  34083. export class PlaySoundAction extends Action {
  34084. private _sound;
  34085. /**
  34086. * Instantiate the action
  34087. * @param triggerOptions defines the trigger options
  34088. * @param sound defines the sound to play
  34089. * @param condition defines the trigger related conditions
  34090. */
  34091. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  34092. /** @hidden */
  34093. _prepare(): void;
  34094. /**
  34095. * Execute the action and play the sound.
  34096. */
  34097. execute(): void;
  34098. /**
  34099. * Serializes the actions and its related information.
  34100. * @param parent defines the object to serialize in
  34101. * @returns the serialized object
  34102. */
  34103. serialize(parent: any): any;
  34104. }
  34105. /**
  34106. * This defines an action helpful to stop a defined sound on a triggered action.
  34107. */
  34108. export class StopSoundAction extends Action {
  34109. private _sound;
  34110. /**
  34111. * Instantiate the action
  34112. * @param triggerOptions defines the trigger options
  34113. * @param sound defines the sound to stop
  34114. * @param condition defines the trigger related conditions
  34115. */
  34116. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  34117. /** @hidden */
  34118. _prepare(): void;
  34119. /**
  34120. * Execute the action and stop the sound.
  34121. */
  34122. execute(): void;
  34123. /**
  34124. * Serializes the actions and its related information.
  34125. * @param parent defines the object to serialize in
  34126. * @returns the serialized object
  34127. */
  34128. serialize(parent: any): any;
  34129. }
  34130. }
  34131. declare module "babylonjs/Actions/interpolateValueAction" {
  34132. import { Action } from "babylonjs/Actions/action";
  34133. import { Condition } from "babylonjs/Actions/condition";
  34134. import { Observable } from "babylonjs/Misc/observable";
  34135. /**
  34136. * This defines an action responsible to change the value of a property
  34137. * by interpolating between its current value and the newly set one once triggered.
  34138. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  34139. */
  34140. export class InterpolateValueAction extends Action {
  34141. /**
  34142. * Defines the path of the property where the value should be interpolated
  34143. */
  34144. propertyPath: string;
  34145. /**
  34146. * Defines the target value at the end of the interpolation.
  34147. */
  34148. value: any;
  34149. /**
  34150. * Defines the time it will take for the property to interpolate to the value.
  34151. */
  34152. duration: number;
  34153. /**
  34154. * Defines if the other scene animations should be stopped when the action has been triggered
  34155. */
  34156. stopOtherAnimations?: boolean;
  34157. /**
  34158. * Defines a callback raised once the interpolation animation has been done.
  34159. */
  34160. onInterpolationDone?: () => void;
  34161. /**
  34162. * Observable triggered once the interpolation animation has been done.
  34163. */
  34164. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  34165. private _target;
  34166. private _effectiveTarget;
  34167. private _property;
  34168. /**
  34169. * Instantiate the action
  34170. * @param triggerOptions defines the trigger options
  34171. * @param target defines the object containing the value to interpolate
  34172. * @param propertyPath defines the path to the property in the target object
  34173. * @param value defines the target value at the end of the interpolation
  34174. * @param duration deines the time it will take for the property to interpolate to the value.
  34175. * @param condition defines the trigger related conditions
  34176. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  34177. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  34178. */
  34179. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  34180. /** @hidden */
  34181. _prepare(): void;
  34182. /**
  34183. * Execute the action starts the value interpolation.
  34184. */
  34185. execute(): void;
  34186. /**
  34187. * Serializes the actions and its related information.
  34188. * @param parent defines the object to serialize in
  34189. * @returns the serialized object
  34190. */
  34191. serialize(parent: any): any;
  34192. }
  34193. }
  34194. declare module "babylonjs/Actions/index" {
  34195. export * from "babylonjs/Actions/action";
  34196. export * from "babylonjs/Actions/actionEvent";
  34197. export * from "babylonjs/Actions/actionManager";
  34198. export * from "babylonjs/Actions/condition";
  34199. export * from "babylonjs/Actions/directActions";
  34200. export * from "babylonjs/Actions/directAudioActions";
  34201. export * from "babylonjs/Actions/interpolateValueAction";
  34202. }
  34203. declare module "babylonjs/Animations/index" {
  34204. export * from "babylonjs/Animations/animatable";
  34205. export * from "babylonjs/Animations/animation";
  34206. export * from "babylonjs/Animations/animationGroup";
  34207. export * from "babylonjs/Animations/animationPropertiesOverride";
  34208. export * from "babylonjs/Animations/easing";
  34209. export * from "babylonjs/Animations/runtimeAnimation";
  34210. export * from "babylonjs/Animations/animationEvent";
  34211. export * from "babylonjs/Animations/animationGroup";
  34212. export * from "babylonjs/Animations/animationKey";
  34213. export * from "babylonjs/Animations/animationRange";
  34214. }
  34215. declare module "babylonjs/Audio/soundTrack" {
  34216. import { Sound } from "babylonjs/Audio/sound";
  34217. import { Analyser } from "babylonjs/Audio/analyser";
  34218. import { Scene } from "babylonjs/scene";
  34219. /**
  34220. * Options allowed during the creation of a sound track.
  34221. */
  34222. export interface ISoundTrackOptions {
  34223. /**
  34224. * The volume the sound track should take during creation
  34225. */
  34226. volume?: number;
  34227. /**
  34228. * Define if the sound track is the main sound track of the scene
  34229. */
  34230. mainTrack?: boolean;
  34231. }
  34232. /**
  34233. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  34234. * It will be also used in a future release to apply effects on a specific track.
  34235. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  34236. */
  34237. export class SoundTrack {
  34238. /**
  34239. * The unique identifier of the sound track in the scene.
  34240. */
  34241. id: number;
  34242. /**
  34243. * The list of sounds included in the sound track.
  34244. */
  34245. soundCollection: Array<Sound>;
  34246. private _outputAudioNode;
  34247. private _scene;
  34248. private _isMainTrack;
  34249. private _connectedAnalyser;
  34250. private _options;
  34251. private _isInitialized;
  34252. /**
  34253. * Creates a new sound track.
  34254. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  34255. * @param scene Define the scene the sound track belongs to
  34256. * @param options
  34257. */
  34258. constructor(scene: Scene, options?: ISoundTrackOptions);
  34259. private _initializeSoundTrackAudioGraph;
  34260. /**
  34261. * Release the sound track and its associated resources
  34262. */
  34263. dispose(): void;
  34264. /**
  34265. * Adds a sound to this sound track
  34266. * @param sound define the cound to add
  34267. * @ignoreNaming
  34268. */
  34269. AddSound(sound: Sound): void;
  34270. /**
  34271. * Removes a sound to this sound track
  34272. * @param sound define the cound to remove
  34273. * @ignoreNaming
  34274. */
  34275. RemoveSound(sound: Sound): void;
  34276. /**
  34277. * Set a global volume for the full sound track.
  34278. * @param newVolume Define the new volume of the sound track
  34279. */
  34280. setVolume(newVolume: number): void;
  34281. /**
  34282. * Switch the panning model to HRTF:
  34283. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  34284. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34285. */
  34286. switchPanningModelToHRTF(): void;
  34287. /**
  34288. * Switch the panning model to Equal Power:
  34289. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  34290. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34291. */
  34292. switchPanningModelToEqualPower(): void;
  34293. /**
  34294. * Connect the sound track to an audio analyser allowing some amazing
  34295. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  34296. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  34297. * @param analyser The analyser to connect to the engine
  34298. */
  34299. connectToAnalyser(analyser: Analyser): void;
  34300. }
  34301. }
  34302. declare module "babylonjs/Audio/audioSceneComponent" {
  34303. import { Sound } from "babylonjs/Audio/sound";
  34304. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  34305. import { Nullable } from "babylonjs/types";
  34306. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  34307. import { Scene } from "babylonjs/scene";
  34308. import { AbstractScene } from "babylonjs/abstractScene";
  34309. module "babylonjs/abstractScene" {
  34310. interface AbstractScene {
  34311. /**
  34312. * The list of sounds used in the scene.
  34313. */
  34314. sounds: Nullable<Array<Sound>>;
  34315. }
  34316. }
  34317. module "babylonjs/scene" {
  34318. interface Scene {
  34319. /**
  34320. * @hidden
  34321. * Backing field
  34322. */
  34323. _mainSoundTrack: SoundTrack;
  34324. /**
  34325. * The main sound track played by the scene.
  34326. * It cotains your primary collection of sounds.
  34327. */
  34328. mainSoundTrack: SoundTrack;
  34329. /**
  34330. * The list of sound tracks added to the scene
  34331. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34332. */
  34333. soundTracks: Nullable<Array<SoundTrack>>;
  34334. /**
  34335. * Gets a sound using a given name
  34336. * @param name defines the name to search for
  34337. * @return the found sound or null if not found at all.
  34338. */
  34339. getSoundByName(name: string): Nullable<Sound>;
  34340. /**
  34341. * Gets or sets if audio support is enabled
  34342. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34343. */
  34344. audioEnabled: boolean;
  34345. /**
  34346. * Gets or sets if audio will be output to headphones
  34347. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34348. */
  34349. headphone: boolean;
  34350. }
  34351. }
  34352. /**
  34353. * Defines the sound scene component responsible to manage any sounds
  34354. * in a given scene.
  34355. */
  34356. export class AudioSceneComponent implements ISceneSerializableComponent {
  34357. /**
  34358. * The component name helpfull to identify the component in the list of scene components.
  34359. */
  34360. readonly name: string;
  34361. /**
  34362. * The scene the component belongs to.
  34363. */
  34364. scene: Scene;
  34365. private _audioEnabled;
  34366. /**
  34367. * Gets whether audio is enabled or not.
  34368. * Please use related enable/disable method to switch state.
  34369. */
  34370. readonly audioEnabled: boolean;
  34371. private _headphone;
  34372. /**
  34373. * Gets whether audio is outputing to headphone or not.
  34374. * Please use the according Switch methods to change output.
  34375. */
  34376. readonly headphone: boolean;
  34377. /**
  34378. * Creates a new instance of the component for the given scene
  34379. * @param scene Defines the scene to register the component in
  34380. */
  34381. constructor(scene: Scene);
  34382. /**
  34383. * Registers the component in a given scene
  34384. */
  34385. register(): void;
  34386. /**
  34387. * Rebuilds the elements related to this component in case of
  34388. * context lost for instance.
  34389. */
  34390. rebuild(): void;
  34391. /**
  34392. * Serializes the component data to the specified json object
  34393. * @param serializationObject The object to serialize to
  34394. */
  34395. serialize(serializationObject: any): void;
  34396. /**
  34397. * Adds all the element from the container to the scene
  34398. * @param container the container holding the elements
  34399. */
  34400. addFromContainer(container: AbstractScene): void;
  34401. /**
  34402. * Removes all the elements in the container from the scene
  34403. * @param container contains the elements to remove
  34404. */
  34405. removeFromContainer(container: AbstractScene): void;
  34406. /**
  34407. * Disposes the component and the associated ressources.
  34408. */
  34409. dispose(): void;
  34410. /**
  34411. * Disables audio in the associated scene.
  34412. */
  34413. disableAudio(): void;
  34414. /**
  34415. * Enables audio in the associated scene.
  34416. */
  34417. enableAudio(): void;
  34418. /**
  34419. * Switch audio to headphone output.
  34420. */
  34421. switchAudioModeForHeadphones(): void;
  34422. /**
  34423. * Switch audio to normal speakers.
  34424. */
  34425. switchAudioModeForNormalSpeakers(): void;
  34426. private _afterRender;
  34427. }
  34428. }
  34429. declare module "babylonjs/Audio/weightedsound" {
  34430. import { Sound } from "babylonjs/Audio/sound";
  34431. /**
  34432. * Wraps one or more Sound objects and selects one with random weight for playback.
  34433. */
  34434. export class WeightedSound {
  34435. /** When true a Sound will be selected and played when the current playing Sound completes. */
  34436. loop: boolean;
  34437. private _coneInnerAngle;
  34438. private _coneOuterAngle;
  34439. private _volume;
  34440. /** A Sound is currently playing. */
  34441. isPlaying: boolean;
  34442. /** A Sound is currently paused. */
  34443. isPaused: boolean;
  34444. private _sounds;
  34445. private _weights;
  34446. private _currentIndex?;
  34447. /**
  34448. * Creates a new WeightedSound from the list of sounds given.
  34449. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  34450. * @param sounds Array of Sounds that will be selected from.
  34451. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  34452. */
  34453. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  34454. /**
  34455. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  34456. */
  34457. /**
  34458. * The size of cone in degress for a directional sound in which there will be no attenuation.
  34459. */
  34460. directionalConeInnerAngle: number;
  34461. /**
  34462. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  34463. * Listener angles between innerAngle and outerAngle will falloff linearly.
  34464. */
  34465. /**
  34466. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  34467. * Listener angles between innerAngle and outerAngle will falloff linearly.
  34468. */
  34469. directionalConeOuterAngle: number;
  34470. /**
  34471. * Playback volume.
  34472. */
  34473. /**
  34474. * Playback volume.
  34475. */
  34476. volume: number;
  34477. private _onended;
  34478. /**
  34479. * Suspend playback
  34480. */
  34481. pause(): void;
  34482. /**
  34483. * Stop playback
  34484. */
  34485. stop(): void;
  34486. /**
  34487. * Start playback.
  34488. * @param startOffset Position the clip head at a specific time in seconds.
  34489. */
  34490. play(startOffset?: number): void;
  34491. }
  34492. }
  34493. declare module "babylonjs/Audio/index" {
  34494. export * from "babylonjs/Audio/analyser";
  34495. export * from "babylonjs/Audio/audioEngine";
  34496. export * from "babylonjs/Audio/audioSceneComponent";
  34497. export * from "babylonjs/Audio/sound";
  34498. export * from "babylonjs/Audio/soundTrack";
  34499. export * from "babylonjs/Audio/weightedsound";
  34500. }
  34501. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  34502. import { Behavior } from "babylonjs/Behaviors/behavior";
  34503. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  34504. import { BackEase } from "babylonjs/Animations/easing";
  34505. /**
  34506. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  34507. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  34508. */
  34509. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  34510. /**
  34511. * Gets the name of the behavior.
  34512. */
  34513. readonly name: string;
  34514. /**
  34515. * The easing function used by animations
  34516. */
  34517. static EasingFunction: BackEase;
  34518. /**
  34519. * The easing mode used by animations
  34520. */
  34521. static EasingMode: number;
  34522. /**
  34523. * The duration of the animation, in milliseconds
  34524. */
  34525. transitionDuration: number;
  34526. /**
  34527. * Length of the distance animated by the transition when lower radius is reached
  34528. */
  34529. lowerRadiusTransitionRange: number;
  34530. /**
  34531. * Length of the distance animated by the transition when upper radius is reached
  34532. */
  34533. upperRadiusTransitionRange: number;
  34534. private _autoTransitionRange;
  34535. /**
  34536. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  34537. */
  34538. /**
  34539. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  34540. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  34541. */
  34542. autoTransitionRange: boolean;
  34543. private _attachedCamera;
  34544. private _onAfterCheckInputsObserver;
  34545. private _onMeshTargetChangedObserver;
  34546. /**
  34547. * Initializes the behavior.
  34548. */
  34549. init(): void;
  34550. /**
  34551. * Attaches the behavior to its arc rotate camera.
  34552. * @param camera Defines the camera to attach the behavior to
  34553. */
  34554. attach(camera: ArcRotateCamera): void;
  34555. /**
  34556. * Detaches the behavior from its current arc rotate camera.
  34557. */
  34558. detach(): void;
  34559. private _radiusIsAnimating;
  34560. private _radiusBounceTransition;
  34561. private _animatables;
  34562. private _cachedWheelPrecision;
  34563. /**
  34564. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  34565. * @param radiusLimit The limit to check against.
  34566. * @return Bool to indicate if at limit.
  34567. */
  34568. private _isRadiusAtLimit;
  34569. /**
  34570. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  34571. * @param radiusDelta The delta by which to animate to. Can be negative.
  34572. */
  34573. private _applyBoundRadiusAnimation;
  34574. /**
  34575. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  34576. */
  34577. protected _clearAnimationLocks(): void;
  34578. /**
  34579. * Stops and removes all animations that have been applied to the camera
  34580. */
  34581. stopAllAnimations(): void;
  34582. }
  34583. }
  34584. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  34585. import { Behavior } from "babylonjs/Behaviors/behavior";
  34586. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  34587. import { ExponentialEase } from "babylonjs/Animations/easing";
  34588. import { Nullable } from "babylonjs/types";
  34589. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  34590. import { Vector3 } from "babylonjs/Maths/math";
  34591. /**
  34592. * 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.
  34593. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  34594. */
  34595. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  34596. /**
  34597. * Gets the name of the behavior.
  34598. */
  34599. readonly name: string;
  34600. private _mode;
  34601. private _radiusScale;
  34602. private _positionScale;
  34603. private _defaultElevation;
  34604. private _elevationReturnTime;
  34605. private _elevationReturnWaitTime;
  34606. private _zoomStopsAnimation;
  34607. private _framingTime;
  34608. /**
  34609. * The easing function used by animations
  34610. */
  34611. static EasingFunction: ExponentialEase;
  34612. /**
  34613. * The easing mode used by animations
  34614. */
  34615. static EasingMode: number;
  34616. /**
  34617. * Sets the current mode used by the behavior
  34618. */
  34619. /**
  34620. * Gets current mode used by the behavior.
  34621. */
  34622. mode: number;
  34623. /**
  34624. * Sets the scale applied to the radius (1 by default)
  34625. */
  34626. /**
  34627. * Gets the scale applied to the radius
  34628. */
  34629. radiusScale: number;
  34630. /**
  34631. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  34632. */
  34633. /**
  34634. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  34635. */
  34636. positionScale: number;
  34637. /**
  34638. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  34639. * behaviour is triggered, in radians.
  34640. */
  34641. /**
  34642. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  34643. * behaviour is triggered, in radians.
  34644. */
  34645. defaultElevation: number;
  34646. /**
  34647. * Sets the time (in milliseconds) taken to return to the default beta position.
  34648. * Negative value indicates camera should not return to default.
  34649. */
  34650. /**
  34651. * Gets the time (in milliseconds) taken to return to the default beta position.
  34652. * Negative value indicates camera should not return to default.
  34653. */
  34654. elevationReturnTime: number;
  34655. /**
  34656. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  34657. */
  34658. /**
  34659. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  34660. */
  34661. elevationReturnWaitTime: number;
  34662. /**
  34663. * Sets the flag that indicates if user zooming should stop animation.
  34664. */
  34665. /**
  34666. * Gets the flag that indicates if user zooming should stop animation.
  34667. */
  34668. zoomStopsAnimation: boolean;
  34669. /**
  34670. * Sets the transition time when framing the mesh, in milliseconds
  34671. */
  34672. /**
  34673. * Gets the transition time when framing the mesh, in milliseconds
  34674. */
  34675. framingTime: number;
  34676. /**
  34677. * Define if the behavior should automatically change the configured
  34678. * camera limits and sensibilities.
  34679. */
  34680. autoCorrectCameraLimitsAndSensibility: boolean;
  34681. private _onPrePointerObservableObserver;
  34682. private _onAfterCheckInputsObserver;
  34683. private _onMeshTargetChangedObserver;
  34684. private _attachedCamera;
  34685. private _isPointerDown;
  34686. private _lastInteractionTime;
  34687. /**
  34688. * Initializes the behavior.
  34689. */
  34690. init(): void;
  34691. /**
  34692. * Attaches the behavior to its arc rotate camera.
  34693. * @param camera Defines the camera to attach the behavior to
  34694. */
  34695. attach(camera: ArcRotateCamera): void;
  34696. /**
  34697. * Detaches the behavior from its current arc rotate camera.
  34698. */
  34699. detach(): void;
  34700. private _animatables;
  34701. private _betaIsAnimating;
  34702. private _betaTransition;
  34703. private _radiusTransition;
  34704. private _vectorTransition;
  34705. /**
  34706. * Targets the given mesh and updates zoom level accordingly.
  34707. * @param mesh The mesh to target.
  34708. * @param radius Optional. If a cached radius position already exists, overrides default.
  34709. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34710. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34711. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34712. */
  34713. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34714. /**
  34715. * Targets the given mesh with its children and updates zoom level accordingly.
  34716. * @param mesh The mesh to target.
  34717. * @param radius Optional. If a cached radius position already exists, overrides default.
  34718. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34719. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34720. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34721. */
  34722. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34723. /**
  34724. * Targets the given meshes with their children and updates zoom level accordingly.
  34725. * @param meshes The mesh to target.
  34726. * @param radius Optional. If a cached radius position already exists, overrides default.
  34727. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34728. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34729. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34730. */
  34731. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34732. /**
  34733. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  34734. * @param minimumWorld Determines the smaller position of the bounding box extend
  34735. * @param maximumWorld Determines the bigger position of the bounding box extend
  34736. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34737. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34738. */
  34739. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34740. /**
  34741. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  34742. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  34743. * frustum width.
  34744. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  34745. * to fully enclose the mesh in the viewing frustum.
  34746. */
  34747. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  34748. /**
  34749. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  34750. * is automatically returned to its default position (expected to be above ground plane).
  34751. */
  34752. private _maintainCameraAboveGround;
  34753. /**
  34754. * Returns the frustum slope based on the canvas ratio and camera FOV
  34755. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  34756. */
  34757. private _getFrustumSlope;
  34758. /**
  34759. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  34760. */
  34761. private _clearAnimationLocks;
  34762. /**
  34763. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  34764. */
  34765. private _applyUserInteraction;
  34766. /**
  34767. * Stops and removes all animations that have been applied to the camera
  34768. */
  34769. stopAllAnimations(): void;
  34770. /**
  34771. * Gets a value indicating if the user is moving the camera
  34772. */
  34773. readonly isUserIsMoving: boolean;
  34774. /**
  34775. * The camera can move all the way towards the mesh.
  34776. */
  34777. static IgnoreBoundsSizeMode: number;
  34778. /**
  34779. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  34780. */
  34781. static FitFrustumSidesMode: number;
  34782. }
  34783. }
  34784. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  34785. import { Nullable } from "babylonjs/types";
  34786. import { Camera } from "babylonjs/Cameras/camera";
  34787. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  34788. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  34789. /**
  34790. * Base class for Camera Pointer Inputs.
  34791. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  34792. * for example usage.
  34793. */
  34794. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  34795. /**
  34796. * Defines the camera the input is attached to.
  34797. */
  34798. abstract camera: Camera;
  34799. /**
  34800. * Whether keyboard modifier keys are pressed at time of last mouse event.
  34801. */
  34802. protected _altKey: boolean;
  34803. protected _ctrlKey: boolean;
  34804. protected _metaKey: boolean;
  34805. protected _shiftKey: boolean;
  34806. /**
  34807. * Which mouse buttons were pressed at time of last mouse event.
  34808. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  34809. */
  34810. protected _buttonsPressed: number;
  34811. /**
  34812. * Defines the buttons associated with the input to handle camera move.
  34813. */
  34814. buttons: number[];
  34815. /**
  34816. * Attach the input controls to a specific dom element to get the input from.
  34817. * @param element Defines the element the controls should be listened from
  34818. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  34819. */
  34820. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  34821. /**
  34822. * Detach the current controls from the specified dom element.
  34823. * @param element Defines the element to stop listening the inputs from
  34824. */
  34825. detachControl(element: Nullable<HTMLElement>): void;
  34826. /**
  34827. * Gets the class name of the current input.
  34828. * @returns the class name
  34829. */
  34830. getClassName(): string;
  34831. /**
  34832. * Get the friendly name associated with the input class.
  34833. * @returns the input friendly name
  34834. */
  34835. getSimpleName(): string;
  34836. /**
  34837. * Called on pointer POINTERDOUBLETAP event.
  34838. * Override this method to provide functionality on POINTERDOUBLETAP event.
  34839. */
  34840. protected onDoubleTap(type: string): void;
  34841. /**
  34842. * Called on pointer POINTERMOVE event if only a single touch is active.
  34843. * Override this method to provide functionality.
  34844. */
  34845. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  34846. /**
  34847. * Called on pointer POINTERMOVE event if multiple touches are active.
  34848. * Override this method to provide functionality.
  34849. */
  34850. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  34851. /**
  34852. * Called on JS contextmenu event.
  34853. * Override this method to provide functionality.
  34854. */
  34855. protected onContextMenu(evt: PointerEvent): void;
  34856. /**
  34857. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  34858. * press.
  34859. * Override this method to provide functionality.
  34860. */
  34861. protected onButtonDown(evt: PointerEvent, buttonCount: number): void;
  34862. /**
  34863. * Called each time a new POINTERUP event occurs. Ie, for each button
  34864. * release.
  34865. * Override this method to provide functionality.
  34866. */
  34867. protected onButtonUp(evt: PointerEvent): void;
  34868. /**
  34869. * Called when window becomes inactive.
  34870. * Override this method to provide functionality.
  34871. */
  34872. protected onLostFocus(): void;
  34873. private _pointerInput;
  34874. private _observer;
  34875. private _onLostFocus;
  34876. }
  34877. }
  34878. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  34879. import { Nullable } from "babylonjs/types";
  34880. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  34881. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  34882. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  34883. /**
  34884. * Manage the pointers inputs to control an arc rotate camera.
  34885. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34886. */
  34887. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  34888. /**
  34889. * Defines the camera the input is attached to.
  34890. */
  34891. camera: ArcRotateCamera;
  34892. /**
  34893. * Gets the class name of the current input.
  34894. * @returns the class name
  34895. */
  34896. getClassName(): string;
  34897. /**
  34898. * Defines the buttons associated with the input to handle camera move.
  34899. */
  34900. buttons: number[];
  34901. /**
  34902. * Defines the pointer angular sensibility along the X axis or how fast is
  34903. * the camera rotating.
  34904. */
  34905. angularSensibilityX: number;
  34906. /**
  34907. * Defines the pointer angular sensibility along the Y axis or how fast is
  34908. * the camera rotating.
  34909. */
  34910. angularSensibilityY: number;
  34911. /**
  34912. * Defines the pointer pinch precision or how fast is the camera zooming.
  34913. */
  34914. pinchPrecision: number;
  34915. /**
  34916. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  34917. * from 0.
  34918. * It defines the percentage of current camera.radius to use as delta when
  34919. * pinch zoom is used.
  34920. */
  34921. pinchDeltaPercentage: number;
  34922. /**
  34923. * Defines the pointer panning sensibility or how fast is the camera moving.
  34924. */
  34925. panningSensibility: number;
  34926. /**
  34927. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  34928. */
  34929. multiTouchPanning: boolean;
  34930. /**
  34931. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  34932. * zoom (pinch) through multitouch.
  34933. */
  34934. multiTouchPanAndZoom: boolean;
  34935. /**
  34936. * Revers pinch action direction.
  34937. */
  34938. pinchInwards: boolean;
  34939. private _isPanClick;
  34940. private _twoFingerActivityCount;
  34941. private _isPinching;
  34942. /**
  34943. * Called on pointer POINTERMOVE event if only a single touch is active.
  34944. */
  34945. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  34946. /**
  34947. * Called on pointer POINTERDOUBLETAP event.
  34948. */
  34949. protected onDoubleTap(type: string): void;
  34950. /**
  34951. * Called on pointer POINTERMOVE event if multiple touches are active.
  34952. */
  34953. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  34954. /**
  34955. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  34956. * press.
  34957. */
  34958. protected onButtonDown(evt: PointerEvent, buttonCount: number): void;
  34959. /**
  34960. * Called each time a new POINTERUP event occurs. Ie, for each button
  34961. * release.
  34962. */
  34963. protected onButtonUp(evt: PointerEvent): void;
  34964. /**
  34965. * Called when window becomes inactive.
  34966. */
  34967. protected onLostFocus(): void;
  34968. }
  34969. }
  34970. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  34971. import { Nullable } from "babylonjs/types";
  34972. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  34973. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  34974. /**
  34975. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  34976. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34977. */
  34978. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  34979. /**
  34980. * Defines the camera the input is attached to.
  34981. */
  34982. camera: ArcRotateCamera;
  34983. /**
  34984. * Defines the list of key codes associated with the up action (increase alpha)
  34985. */
  34986. keysUp: number[];
  34987. /**
  34988. * Defines the list of key codes associated with the down action (decrease alpha)
  34989. */
  34990. keysDown: number[];
  34991. /**
  34992. * Defines the list of key codes associated with the left action (increase beta)
  34993. */
  34994. keysLeft: number[];
  34995. /**
  34996. * Defines the list of key codes associated with the right action (decrease beta)
  34997. */
  34998. keysRight: number[];
  34999. /**
  35000. * Defines the list of key codes associated with the reset action.
  35001. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  35002. */
  35003. keysReset: number[];
  35004. /**
  35005. * Defines the panning sensibility of the inputs.
  35006. * (How fast is the camera paning)
  35007. */
  35008. panningSensibility: number;
  35009. /**
  35010. * Defines the zooming sensibility of the inputs.
  35011. * (How fast is the camera zooming)
  35012. */
  35013. zoomingSensibility: number;
  35014. /**
  35015. * Defines wether maintaining the alt key down switch the movement mode from
  35016. * orientation to zoom.
  35017. */
  35018. useAltToZoom: boolean;
  35019. /**
  35020. * Rotation speed of the camera
  35021. */
  35022. angularSpeed: number;
  35023. private _keys;
  35024. private _ctrlPressed;
  35025. private _altPressed;
  35026. private _onCanvasBlurObserver;
  35027. private _onKeyboardObserver;
  35028. private _engine;
  35029. private _scene;
  35030. /**
  35031. * Attach the input controls to a specific dom element to get the input from.
  35032. * @param element Defines the element the controls should be listened from
  35033. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35034. */
  35035. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35036. /**
  35037. * Detach the current controls from the specified dom element.
  35038. * @param element Defines the element to stop listening the inputs from
  35039. */
  35040. detachControl(element: Nullable<HTMLElement>): void;
  35041. /**
  35042. * Update the current camera state depending on the inputs that have been used this frame.
  35043. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35044. */
  35045. checkInputs(): void;
  35046. /**
  35047. * Gets the class name of the current intput.
  35048. * @returns the class name
  35049. */
  35050. getClassName(): string;
  35051. /**
  35052. * Get the friendly name associated with the input class.
  35053. * @returns the input friendly name
  35054. */
  35055. getSimpleName(): string;
  35056. }
  35057. }
  35058. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  35059. import { Nullable } from "babylonjs/types";
  35060. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35061. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  35062. /**
  35063. * Manage the mouse wheel inputs to control an arc rotate camera.
  35064. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35065. */
  35066. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  35067. /**
  35068. * Defines the camera the input is attached to.
  35069. */
  35070. camera: ArcRotateCamera;
  35071. /**
  35072. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  35073. */
  35074. wheelPrecision: number;
  35075. /**
  35076. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  35077. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  35078. */
  35079. wheelDeltaPercentage: number;
  35080. private _wheel;
  35081. private _observer;
  35082. /**
  35083. * Attach the input controls to a specific dom element to get the input from.
  35084. * @param element Defines the element the controls should be listened from
  35085. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35086. */
  35087. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35088. /**
  35089. * Detach the current controls from the specified dom element.
  35090. * @param element Defines the element to stop listening the inputs from
  35091. */
  35092. detachControl(element: Nullable<HTMLElement>): void;
  35093. /**
  35094. * Gets the class name of the current intput.
  35095. * @returns the class name
  35096. */
  35097. getClassName(): string;
  35098. /**
  35099. * Get the friendly name associated with the input class.
  35100. * @returns the input friendly name
  35101. */
  35102. getSimpleName(): string;
  35103. }
  35104. }
  35105. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  35106. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35107. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  35108. /**
  35109. * Default Inputs manager for the ArcRotateCamera.
  35110. * It groups all the default supported inputs for ease of use.
  35111. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35112. */
  35113. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  35114. /**
  35115. * Instantiates a new ArcRotateCameraInputsManager.
  35116. * @param camera Defines the camera the inputs belong to
  35117. */
  35118. constructor(camera: ArcRotateCamera);
  35119. /**
  35120. * Add mouse wheel input support to the input manager.
  35121. * @returns the current input manager
  35122. */
  35123. addMouseWheel(): ArcRotateCameraInputsManager;
  35124. /**
  35125. * Add pointers input support to the input manager.
  35126. * @returns the current input manager
  35127. */
  35128. addPointers(): ArcRotateCameraInputsManager;
  35129. /**
  35130. * Add keyboard input support to the input manager.
  35131. * @returns the current input manager
  35132. */
  35133. addKeyboard(): ArcRotateCameraInputsManager;
  35134. }
  35135. }
  35136. declare module "babylonjs/Cameras/arcRotateCamera" {
  35137. import { Observable } from "babylonjs/Misc/observable";
  35138. import { Nullable } from "babylonjs/types";
  35139. import { Scene } from "babylonjs/scene";
  35140. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math";
  35141. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35142. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  35143. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  35144. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  35145. import { Camera } from "babylonjs/Cameras/camera";
  35146. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  35147. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  35148. import { Collider } from "babylonjs/Collisions/collider";
  35149. /**
  35150. * This represents an orbital type of camera.
  35151. *
  35152. * 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.
  35153. * 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.
  35154. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  35155. */
  35156. export class ArcRotateCamera extends TargetCamera {
  35157. /**
  35158. * Defines the rotation angle of the camera along the longitudinal axis.
  35159. */
  35160. alpha: number;
  35161. /**
  35162. * Defines the rotation angle of the camera along the latitudinal axis.
  35163. */
  35164. beta: number;
  35165. /**
  35166. * Defines the radius of the camera from it s target point.
  35167. */
  35168. radius: number;
  35169. protected _target: Vector3;
  35170. protected _targetHost: Nullable<AbstractMesh>;
  35171. /**
  35172. * Defines the target point of the camera.
  35173. * The camera looks towards it form the radius distance.
  35174. */
  35175. target: Vector3;
  35176. /**
  35177. * Define the current local position of the camera in the scene
  35178. */
  35179. position: Vector3;
  35180. /**
  35181. * Current inertia value on the longitudinal axis.
  35182. * The bigger this number the longer it will take for the camera to stop.
  35183. */
  35184. inertialAlphaOffset: number;
  35185. /**
  35186. * Current inertia value on the latitudinal axis.
  35187. * The bigger this number the longer it will take for the camera to stop.
  35188. */
  35189. inertialBetaOffset: number;
  35190. /**
  35191. * Current inertia value on the radius axis.
  35192. * The bigger this number the longer it will take for the camera to stop.
  35193. */
  35194. inertialRadiusOffset: number;
  35195. /**
  35196. * Minimum allowed angle on the longitudinal axis.
  35197. * This can help limiting how the Camera is able to move in the scene.
  35198. */
  35199. lowerAlphaLimit: Nullable<number>;
  35200. /**
  35201. * Maximum allowed angle on the longitudinal axis.
  35202. * This can help limiting how the Camera is able to move in the scene.
  35203. */
  35204. upperAlphaLimit: Nullable<number>;
  35205. /**
  35206. * Minimum allowed angle on the latitudinal axis.
  35207. * This can help limiting how the Camera is able to move in the scene.
  35208. */
  35209. lowerBetaLimit: number;
  35210. /**
  35211. * Maximum allowed angle on the latitudinal axis.
  35212. * This can help limiting how the Camera is able to move in the scene.
  35213. */
  35214. upperBetaLimit: number;
  35215. /**
  35216. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  35217. * This can help limiting how the Camera is able to move in the scene.
  35218. */
  35219. lowerRadiusLimit: Nullable<number>;
  35220. /**
  35221. * Maximum allowed distance of the camera to the target (The camera can not get further).
  35222. * This can help limiting how the Camera is able to move in the scene.
  35223. */
  35224. upperRadiusLimit: Nullable<number>;
  35225. /**
  35226. * Defines the current inertia value used during panning of the camera along the X axis.
  35227. */
  35228. inertialPanningX: number;
  35229. /**
  35230. * Defines the current inertia value used during panning of the camera along the Y axis.
  35231. */
  35232. inertialPanningY: number;
  35233. /**
  35234. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  35235. * Basically if your fingers moves away from more than this distance you will be considered
  35236. * in pinch mode.
  35237. */
  35238. pinchToPanMaxDistance: number;
  35239. /**
  35240. * Defines the maximum distance the camera can pan.
  35241. * This could help keeping the cammera always in your scene.
  35242. */
  35243. panningDistanceLimit: Nullable<number>;
  35244. /**
  35245. * Defines the target of the camera before paning.
  35246. */
  35247. panningOriginTarget: Vector3;
  35248. /**
  35249. * Defines the value of the inertia used during panning.
  35250. * 0 would mean stop inertia and one would mean no decelleration at all.
  35251. */
  35252. panningInertia: number;
  35253. /**
  35254. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  35255. */
  35256. angularSensibilityX: number;
  35257. /**
  35258. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  35259. */
  35260. angularSensibilityY: number;
  35261. /**
  35262. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  35263. */
  35264. pinchPrecision: number;
  35265. /**
  35266. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  35267. * It will be used instead of pinchDeltaPrecision if different from 0.
  35268. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  35269. */
  35270. pinchDeltaPercentage: number;
  35271. /**
  35272. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  35273. */
  35274. panningSensibility: number;
  35275. /**
  35276. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  35277. */
  35278. keysUp: number[];
  35279. /**
  35280. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  35281. */
  35282. keysDown: number[];
  35283. /**
  35284. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  35285. */
  35286. keysLeft: number[];
  35287. /**
  35288. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  35289. */
  35290. keysRight: number[];
  35291. /**
  35292. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  35293. */
  35294. wheelPrecision: number;
  35295. /**
  35296. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  35297. * It will be used instead of pinchDeltaPrecision if different from 0.
  35298. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  35299. */
  35300. wheelDeltaPercentage: number;
  35301. /**
  35302. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  35303. */
  35304. zoomOnFactor: number;
  35305. /**
  35306. * Defines a screen offset for the camera position.
  35307. */
  35308. targetScreenOffset: Vector2;
  35309. /**
  35310. * Allows the camera to be completely reversed.
  35311. * If false the camera can not arrive upside down.
  35312. */
  35313. allowUpsideDown: boolean;
  35314. /**
  35315. * Define if double tap/click is used to restore the previously saved state of the camera.
  35316. */
  35317. useInputToRestoreState: boolean;
  35318. /** @hidden */
  35319. _viewMatrix: Matrix;
  35320. /** @hidden */
  35321. _useCtrlForPanning: boolean;
  35322. /** @hidden */
  35323. _panningMouseButton: number;
  35324. /**
  35325. * Defines the input associated to the camera.
  35326. */
  35327. inputs: ArcRotateCameraInputsManager;
  35328. /** @hidden */
  35329. _reset: () => void;
  35330. /**
  35331. * Defines the allowed panning axis.
  35332. */
  35333. panningAxis: Vector3;
  35334. protected _localDirection: Vector3;
  35335. protected _transformedDirection: Vector3;
  35336. private _bouncingBehavior;
  35337. /**
  35338. * Gets the bouncing behavior of the camera if it has been enabled.
  35339. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35340. */
  35341. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  35342. /**
  35343. * Defines if the bouncing behavior of the camera is enabled on the camera.
  35344. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35345. */
  35346. useBouncingBehavior: boolean;
  35347. private _framingBehavior;
  35348. /**
  35349. * Gets the framing behavior of the camera if it has been enabled.
  35350. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35351. */
  35352. readonly framingBehavior: Nullable<FramingBehavior>;
  35353. /**
  35354. * Defines if the framing behavior of the camera is enabled on the camera.
  35355. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35356. */
  35357. useFramingBehavior: boolean;
  35358. private _autoRotationBehavior;
  35359. /**
  35360. * Gets the auto rotation behavior of the camera if it has been enabled.
  35361. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35362. */
  35363. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  35364. /**
  35365. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  35366. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35367. */
  35368. useAutoRotationBehavior: boolean;
  35369. /**
  35370. * Observable triggered when the mesh target has been changed on the camera.
  35371. */
  35372. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  35373. /**
  35374. * Event raised when the camera is colliding with a mesh.
  35375. */
  35376. onCollide: (collidedMesh: AbstractMesh) => void;
  35377. /**
  35378. * Defines whether the camera should check collision with the objects oh the scene.
  35379. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  35380. */
  35381. checkCollisions: boolean;
  35382. /**
  35383. * Defines the collision radius of the camera.
  35384. * This simulates a sphere around the camera.
  35385. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  35386. */
  35387. collisionRadius: Vector3;
  35388. protected _collider: Collider;
  35389. protected _previousPosition: Vector3;
  35390. protected _collisionVelocity: Vector3;
  35391. protected _newPosition: Vector3;
  35392. protected _previousAlpha: number;
  35393. protected _previousBeta: number;
  35394. protected _previousRadius: number;
  35395. protected _collisionTriggered: boolean;
  35396. protected _targetBoundingCenter: Nullable<Vector3>;
  35397. private _computationVector;
  35398. private _tempAxisVector;
  35399. private _tempAxisRotationMatrix;
  35400. /**
  35401. * Instantiates a new ArcRotateCamera in a given scene
  35402. * @param name Defines the name of the camera
  35403. * @param alpha Defines the camera rotation along the logitudinal axis
  35404. * @param beta Defines the camera rotation along the latitudinal axis
  35405. * @param radius Defines the camera distance from its target
  35406. * @param target Defines the camera target
  35407. * @param scene Defines the scene the camera belongs to
  35408. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  35409. */
  35410. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  35411. /** @hidden */
  35412. _initCache(): void;
  35413. /** @hidden */
  35414. _updateCache(ignoreParentClass?: boolean): void;
  35415. protected _getTargetPosition(): Vector3;
  35416. private _storedAlpha;
  35417. private _storedBeta;
  35418. private _storedRadius;
  35419. private _storedTarget;
  35420. /**
  35421. * Stores the current state of the camera (alpha, beta, radius and target)
  35422. * @returns the camera itself
  35423. */
  35424. storeState(): Camera;
  35425. /**
  35426. * @hidden
  35427. * Restored camera state. You must call storeState() first
  35428. */
  35429. _restoreStateValues(): boolean;
  35430. /** @hidden */
  35431. _isSynchronizedViewMatrix(): boolean;
  35432. /**
  35433. * Attached controls to the current camera.
  35434. * @param element Defines the element the controls should be listened from
  35435. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35436. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  35437. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  35438. */
  35439. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  35440. /**
  35441. * Detach the current controls from the camera.
  35442. * The camera will stop reacting to inputs.
  35443. * @param element Defines the element to stop listening the inputs from
  35444. */
  35445. detachControl(element: HTMLElement): void;
  35446. /** @hidden */
  35447. _checkInputs(): void;
  35448. protected _checkLimits(): void;
  35449. /**
  35450. * Rebuilds angles (alpha, beta) and radius from the give position and target
  35451. * @param updateView defines a boolean forcing the camera to update its position with a view matrix computation first (default is true)
  35452. */
  35453. rebuildAnglesAndRadius(updateView?: boolean): void;
  35454. /**
  35455. * Use a position to define the current camera related information like aplha, beta and radius
  35456. * @param position Defines the position to set the camera at
  35457. */
  35458. setPosition(position: Vector3): void;
  35459. /**
  35460. * Defines the target the camera should look at.
  35461. * This will automatically adapt alpha beta and radius to fit within the new target.
  35462. * @param target Defines the new target as a Vector or a mesh
  35463. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  35464. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  35465. */
  35466. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  35467. /** @hidden */
  35468. _getViewMatrix(): Matrix;
  35469. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  35470. /**
  35471. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  35472. * @param meshes Defines the mesh to zoom on
  35473. * @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)
  35474. */
  35475. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  35476. /**
  35477. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  35478. * The target will be changed but the radius
  35479. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  35480. * @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)
  35481. */
  35482. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  35483. min: Vector3;
  35484. max: Vector3;
  35485. distance: number;
  35486. }, doNotUpdateMaxZ?: boolean): void;
  35487. /**
  35488. * @override
  35489. * Override Camera.createRigCamera
  35490. */
  35491. createRigCamera(name: string, cameraIndex: number): Camera;
  35492. /**
  35493. * @hidden
  35494. * @override
  35495. * Override Camera._updateRigCameras
  35496. */
  35497. _updateRigCameras(): void;
  35498. /**
  35499. * Destroy the camera and release the current resources hold by it.
  35500. */
  35501. dispose(): void;
  35502. /**
  35503. * Gets the current object class name.
  35504. * @return the class name
  35505. */
  35506. getClassName(): string;
  35507. }
  35508. }
  35509. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  35510. import { Behavior } from "babylonjs/Behaviors/behavior";
  35511. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35512. /**
  35513. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  35514. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35515. */
  35516. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  35517. /**
  35518. * Gets the name of the behavior.
  35519. */
  35520. readonly name: string;
  35521. private _zoomStopsAnimation;
  35522. private _idleRotationSpeed;
  35523. private _idleRotationWaitTime;
  35524. private _idleRotationSpinupTime;
  35525. /**
  35526. * Sets the flag that indicates if user zooming should stop animation.
  35527. */
  35528. /**
  35529. * Gets the flag that indicates if user zooming should stop animation.
  35530. */
  35531. zoomStopsAnimation: boolean;
  35532. /**
  35533. * Sets the default speed at which the camera rotates around the model.
  35534. */
  35535. /**
  35536. * Gets the default speed at which the camera rotates around the model.
  35537. */
  35538. idleRotationSpeed: number;
  35539. /**
  35540. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  35541. */
  35542. /**
  35543. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  35544. */
  35545. idleRotationWaitTime: number;
  35546. /**
  35547. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  35548. */
  35549. /**
  35550. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  35551. */
  35552. idleRotationSpinupTime: number;
  35553. /**
  35554. * Gets a value indicating if the camera is currently rotating because of this behavior
  35555. */
  35556. readonly rotationInProgress: boolean;
  35557. private _onPrePointerObservableObserver;
  35558. private _onAfterCheckInputsObserver;
  35559. private _attachedCamera;
  35560. private _isPointerDown;
  35561. private _lastFrameTime;
  35562. private _lastInteractionTime;
  35563. private _cameraRotationSpeed;
  35564. /**
  35565. * Initializes the behavior.
  35566. */
  35567. init(): void;
  35568. /**
  35569. * Attaches the behavior to its arc rotate camera.
  35570. * @param camera Defines the camera to attach the behavior to
  35571. */
  35572. attach(camera: ArcRotateCamera): void;
  35573. /**
  35574. * Detaches the behavior from its current arc rotate camera.
  35575. */
  35576. detach(): void;
  35577. /**
  35578. * Returns true if user is scrolling.
  35579. * @return true if user is scrolling.
  35580. */
  35581. private _userIsZooming;
  35582. private _lastFrameRadius;
  35583. private _shouldAnimationStopForInteraction;
  35584. /**
  35585. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  35586. */
  35587. private _applyUserInteraction;
  35588. private _userIsMoving;
  35589. }
  35590. }
  35591. declare module "babylonjs/Behaviors/Cameras/index" {
  35592. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  35593. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  35594. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  35595. }
  35596. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  35597. import { Mesh } from "babylonjs/Meshes/mesh";
  35598. import { TransformNode } from "babylonjs/Meshes/transformNode";
  35599. import { Behavior } from "babylonjs/Behaviors/behavior";
  35600. /**
  35601. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  35602. */
  35603. export class AttachToBoxBehavior implements Behavior<Mesh> {
  35604. private ui;
  35605. /**
  35606. * The name of the behavior
  35607. */
  35608. name: string;
  35609. /**
  35610. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  35611. */
  35612. distanceAwayFromFace: number;
  35613. /**
  35614. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  35615. */
  35616. distanceAwayFromBottomOfFace: number;
  35617. private _faceVectors;
  35618. private _target;
  35619. private _scene;
  35620. private _onRenderObserver;
  35621. private _tmpMatrix;
  35622. private _tmpVector;
  35623. /**
  35624. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  35625. * @param ui The transform node that should be attched to the mesh
  35626. */
  35627. constructor(ui: TransformNode);
  35628. /**
  35629. * Initializes the behavior
  35630. */
  35631. init(): void;
  35632. private _closestFace;
  35633. private _zeroVector;
  35634. private _lookAtTmpMatrix;
  35635. private _lookAtToRef;
  35636. /**
  35637. * Attaches the AttachToBoxBehavior to the passed in mesh
  35638. * @param target The mesh that the specified node will be attached to
  35639. */
  35640. attach(target: Mesh): void;
  35641. /**
  35642. * Detaches the behavior from the mesh
  35643. */
  35644. detach(): void;
  35645. }
  35646. }
  35647. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  35648. import { Behavior } from "babylonjs/Behaviors/behavior";
  35649. import { Mesh } from "babylonjs/Meshes/mesh";
  35650. /**
  35651. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  35652. */
  35653. export class FadeInOutBehavior implements Behavior<Mesh> {
  35654. /**
  35655. * Time in milliseconds to delay before fading in (Default: 0)
  35656. */
  35657. delay: number;
  35658. /**
  35659. * Time in milliseconds for the mesh to fade in (Default: 300)
  35660. */
  35661. fadeInTime: number;
  35662. private _millisecondsPerFrame;
  35663. private _hovered;
  35664. private _hoverValue;
  35665. private _ownerNode;
  35666. /**
  35667. * Instatiates the FadeInOutBehavior
  35668. */
  35669. constructor();
  35670. /**
  35671. * The name of the behavior
  35672. */
  35673. readonly name: string;
  35674. /**
  35675. * Initializes the behavior
  35676. */
  35677. init(): void;
  35678. /**
  35679. * Attaches the fade behavior on the passed in mesh
  35680. * @param ownerNode The mesh that will be faded in/out once attached
  35681. */
  35682. attach(ownerNode: Mesh): void;
  35683. /**
  35684. * Detaches the behavior from the mesh
  35685. */
  35686. detach(): void;
  35687. /**
  35688. * Triggers the mesh to begin fading in or out
  35689. * @param value if the object should fade in or out (true to fade in)
  35690. */
  35691. fadeIn(value: boolean): void;
  35692. private _update;
  35693. private _setAllVisibility;
  35694. }
  35695. }
  35696. declare module "babylonjs/Misc/pivotTools" {
  35697. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35698. /**
  35699. * Class containing a set of static utilities functions for managing Pivots
  35700. * @hidden
  35701. */
  35702. export class PivotTools {
  35703. private static _PivotCached;
  35704. private static _OldPivotPoint;
  35705. private static _PivotTranslation;
  35706. private static _PivotTmpVector;
  35707. /** @hidden */
  35708. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  35709. /** @hidden */
  35710. static _RestorePivotPoint(mesh: AbstractMesh): void;
  35711. }
  35712. }
  35713. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  35714. import { Scene } from "babylonjs/scene";
  35715. import { Vector4, Plane } from "babylonjs/Maths/math";
  35716. import { Mesh } from "babylonjs/Meshes/mesh";
  35717. /**
  35718. * Class containing static functions to help procedurally build meshes
  35719. */
  35720. export class PlaneBuilder {
  35721. /**
  35722. * Creates a plane mesh
  35723. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  35724. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  35725. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  35726. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  35727. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  35728. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  35729. * @param name defines the name of the mesh
  35730. * @param options defines the options used to create the mesh
  35731. * @param scene defines the hosting scene
  35732. * @returns the plane mesh
  35733. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  35734. */
  35735. static CreatePlane(name: string, options: {
  35736. size?: number;
  35737. width?: number;
  35738. height?: number;
  35739. sideOrientation?: number;
  35740. frontUVs?: Vector4;
  35741. backUVs?: Vector4;
  35742. updatable?: boolean;
  35743. sourcePlane?: Plane;
  35744. }, scene: Scene): Mesh;
  35745. }
  35746. }
  35747. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  35748. import { Behavior } from "babylonjs/Behaviors/behavior";
  35749. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35750. import { Observable } from "babylonjs/Misc/observable";
  35751. import { Vector3 } from "babylonjs/Maths/math";
  35752. import { Ray } from "babylonjs/Culling/ray";
  35753. import "babylonjs/Meshes/Builders/planeBuilder";
  35754. /**
  35755. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  35756. */
  35757. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  35758. private static _AnyMouseID;
  35759. private _attachedNode;
  35760. private _dragPlane;
  35761. private _scene;
  35762. private _pointerObserver;
  35763. private _beforeRenderObserver;
  35764. private static _planeScene;
  35765. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  35766. /**
  35767. * 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)
  35768. */
  35769. maxDragAngle: number;
  35770. /**
  35771. * @hidden
  35772. */
  35773. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  35774. /**
  35775. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  35776. */
  35777. currentDraggingPointerID: number;
  35778. /**
  35779. * The last position where the pointer hit the drag plane in world space
  35780. */
  35781. lastDragPosition: Vector3;
  35782. /**
  35783. * If the behavior is currently in a dragging state
  35784. */
  35785. dragging: boolean;
  35786. /**
  35787. * 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)
  35788. */
  35789. dragDeltaRatio: number;
  35790. /**
  35791. * If the drag plane orientation should be updated during the dragging (Default: true)
  35792. */
  35793. updateDragPlane: boolean;
  35794. private _debugMode;
  35795. private _moving;
  35796. /**
  35797. * Fires each time the attached mesh is dragged with the pointer
  35798. * * delta between last drag position and current drag position in world space
  35799. * * dragDistance along the drag axis
  35800. * * dragPlaneNormal normal of the current drag plane used during the drag
  35801. * * dragPlanePoint in world space where the drag intersects the drag plane
  35802. */
  35803. onDragObservable: Observable<{
  35804. delta: Vector3;
  35805. dragPlanePoint: Vector3;
  35806. dragPlaneNormal: Vector3;
  35807. dragDistance: number;
  35808. pointerId: number;
  35809. }>;
  35810. /**
  35811. * Fires each time a drag begins (eg. mouse down on mesh)
  35812. */
  35813. onDragStartObservable: Observable<{
  35814. dragPlanePoint: Vector3;
  35815. pointerId: number;
  35816. }>;
  35817. /**
  35818. * Fires each time a drag ends (eg. mouse release after drag)
  35819. */
  35820. onDragEndObservable: Observable<{
  35821. dragPlanePoint: Vector3;
  35822. pointerId: number;
  35823. }>;
  35824. /**
  35825. * If the attached mesh should be moved when dragged
  35826. */
  35827. moveAttached: boolean;
  35828. /**
  35829. * If the drag behavior will react to drag events (Default: true)
  35830. */
  35831. enabled: boolean;
  35832. /**
  35833. * If camera controls should be detached during the drag
  35834. */
  35835. detachCameraControls: boolean;
  35836. /**
  35837. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  35838. */
  35839. useObjectOrienationForDragging: boolean;
  35840. private _options;
  35841. /**
  35842. * Creates a pointer drag behavior that can be attached to a mesh
  35843. * @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)
  35844. */
  35845. constructor(options?: {
  35846. dragAxis?: Vector3;
  35847. dragPlaneNormal?: Vector3;
  35848. });
  35849. /**
  35850. * Predicate to determine if it is valid to move the object to a new position when it is moved
  35851. */
  35852. validateDrag: (targetPosition: Vector3) => boolean;
  35853. /**
  35854. * The name of the behavior
  35855. */
  35856. readonly name: string;
  35857. /**
  35858. * Initializes the behavior
  35859. */
  35860. init(): void;
  35861. private _tmpVector;
  35862. private _alternatePickedPoint;
  35863. private _worldDragAxis;
  35864. private _targetPosition;
  35865. private _attachedElement;
  35866. /**
  35867. * Attaches the drag behavior the passed in mesh
  35868. * @param ownerNode The mesh that will be dragged around once attached
  35869. */
  35870. attach(ownerNode: AbstractMesh): void;
  35871. /**
  35872. * Force relase the drag action by code.
  35873. */
  35874. releaseDrag(): void;
  35875. private _startDragRay;
  35876. private _lastPointerRay;
  35877. /**
  35878. * Simulates the start of a pointer drag event on the behavior
  35879. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  35880. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  35881. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  35882. */
  35883. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  35884. private _startDrag;
  35885. private _dragDelta;
  35886. private _moveDrag;
  35887. private _pickWithRayOnDragPlane;
  35888. private _pointA;
  35889. private _pointB;
  35890. private _pointC;
  35891. private _lineA;
  35892. private _lineB;
  35893. private _localAxis;
  35894. private _lookAt;
  35895. private _updateDragPlanePosition;
  35896. /**
  35897. * Detaches the behavior from the mesh
  35898. */
  35899. detach(): void;
  35900. }
  35901. }
  35902. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  35903. import { Mesh } from "babylonjs/Meshes/mesh";
  35904. import { Behavior } from "babylonjs/Behaviors/behavior";
  35905. /**
  35906. * A behavior that when attached to a mesh will allow the mesh to be scaled
  35907. */
  35908. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  35909. private _dragBehaviorA;
  35910. private _dragBehaviorB;
  35911. private _startDistance;
  35912. private _initialScale;
  35913. private _targetScale;
  35914. private _ownerNode;
  35915. private _sceneRenderObserver;
  35916. /**
  35917. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  35918. */
  35919. constructor();
  35920. /**
  35921. * The name of the behavior
  35922. */
  35923. readonly name: string;
  35924. /**
  35925. * Initializes the behavior
  35926. */
  35927. init(): void;
  35928. private _getCurrentDistance;
  35929. /**
  35930. * Attaches the scale behavior the passed in mesh
  35931. * @param ownerNode The mesh that will be scaled around once attached
  35932. */
  35933. attach(ownerNode: Mesh): void;
  35934. /**
  35935. * Detaches the behavior from the mesh
  35936. */
  35937. detach(): void;
  35938. }
  35939. }
  35940. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  35941. import { Behavior } from "babylonjs/Behaviors/behavior";
  35942. import { Mesh } from "babylonjs/Meshes/mesh";
  35943. import { Observable } from "babylonjs/Misc/observable";
  35944. /**
  35945. * 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
  35946. */
  35947. export class SixDofDragBehavior implements Behavior<Mesh> {
  35948. private static _virtualScene;
  35949. private _ownerNode;
  35950. private _sceneRenderObserver;
  35951. private _scene;
  35952. private _targetPosition;
  35953. private _virtualOriginMesh;
  35954. private _virtualDragMesh;
  35955. private _pointerObserver;
  35956. private _moving;
  35957. private _startingOrientation;
  35958. /**
  35959. * 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)
  35960. */
  35961. private zDragFactor;
  35962. /**
  35963. * If the object should rotate to face the drag origin
  35964. */
  35965. rotateDraggedObject: boolean;
  35966. /**
  35967. * If the behavior is currently in a dragging state
  35968. */
  35969. dragging: boolean;
  35970. /**
  35971. * 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)
  35972. */
  35973. dragDeltaRatio: number;
  35974. /**
  35975. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  35976. */
  35977. currentDraggingPointerID: number;
  35978. /**
  35979. * If camera controls should be detached during the drag
  35980. */
  35981. detachCameraControls: boolean;
  35982. /**
  35983. * Fires each time a drag starts
  35984. */
  35985. onDragStartObservable: Observable<{}>;
  35986. /**
  35987. * Fires each time a drag ends (eg. mouse release after drag)
  35988. */
  35989. onDragEndObservable: Observable<{}>;
  35990. /**
  35991. * 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
  35992. */
  35993. constructor();
  35994. /**
  35995. * The name of the behavior
  35996. */
  35997. readonly name: string;
  35998. /**
  35999. * Initializes the behavior
  36000. */
  36001. init(): void;
  36002. /**
  36003. * Attaches the scale behavior the passed in mesh
  36004. * @param ownerNode The mesh that will be scaled around once attached
  36005. */
  36006. attach(ownerNode: Mesh): void;
  36007. /**
  36008. * Detaches the behavior from the mesh
  36009. */
  36010. detach(): void;
  36011. }
  36012. }
  36013. declare module "babylonjs/Behaviors/Meshes/index" {
  36014. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  36015. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  36016. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  36017. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  36018. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  36019. }
  36020. declare module "babylonjs/Behaviors/index" {
  36021. export * from "babylonjs/Behaviors/behavior";
  36022. export * from "babylonjs/Behaviors/Cameras/index";
  36023. export * from "babylonjs/Behaviors/Meshes/index";
  36024. }
  36025. declare module "babylonjs/Bones/boneIKController" {
  36026. import { Bone } from "babylonjs/Bones/bone";
  36027. import { Vector3 } from "babylonjs/Maths/math";
  36028. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36029. import { Nullable } from "babylonjs/types";
  36030. /**
  36031. * Class used to apply inverse kinematics to bones
  36032. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  36033. */
  36034. export class BoneIKController {
  36035. private static _tmpVecs;
  36036. private static _tmpQuat;
  36037. private static _tmpMats;
  36038. /**
  36039. * Gets or sets the target mesh
  36040. */
  36041. targetMesh: AbstractMesh;
  36042. /** Gets or sets the mesh used as pole */
  36043. poleTargetMesh: AbstractMesh;
  36044. /**
  36045. * Gets or sets the bone used as pole
  36046. */
  36047. poleTargetBone: Nullable<Bone>;
  36048. /**
  36049. * Gets or sets the target position
  36050. */
  36051. targetPosition: Vector3;
  36052. /**
  36053. * Gets or sets the pole target position
  36054. */
  36055. poleTargetPosition: Vector3;
  36056. /**
  36057. * Gets or sets the pole target local offset
  36058. */
  36059. poleTargetLocalOffset: Vector3;
  36060. /**
  36061. * Gets or sets the pole angle
  36062. */
  36063. poleAngle: number;
  36064. /**
  36065. * Gets or sets the mesh associated with the controller
  36066. */
  36067. mesh: AbstractMesh;
  36068. /**
  36069. * 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)
  36070. */
  36071. slerpAmount: number;
  36072. private _bone1Quat;
  36073. private _bone1Mat;
  36074. private _bone2Ang;
  36075. private _bone1;
  36076. private _bone2;
  36077. private _bone1Length;
  36078. private _bone2Length;
  36079. private _maxAngle;
  36080. private _maxReach;
  36081. private _rightHandedSystem;
  36082. private _bendAxis;
  36083. private _slerping;
  36084. private _adjustRoll;
  36085. /**
  36086. * Gets or sets maximum allowed angle
  36087. */
  36088. maxAngle: number;
  36089. /**
  36090. * Creates a new BoneIKController
  36091. * @param mesh defines the mesh to control
  36092. * @param bone defines the bone to control
  36093. * @param options defines options to set up the controller
  36094. */
  36095. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  36096. targetMesh?: AbstractMesh;
  36097. poleTargetMesh?: AbstractMesh;
  36098. poleTargetBone?: Bone;
  36099. poleTargetLocalOffset?: Vector3;
  36100. poleAngle?: number;
  36101. bendAxis?: Vector3;
  36102. maxAngle?: number;
  36103. slerpAmount?: number;
  36104. });
  36105. private _setMaxAngle;
  36106. /**
  36107. * Force the controller to update the bones
  36108. */
  36109. update(): void;
  36110. }
  36111. }
  36112. declare module "babylonjs/Bones/boneLookController" {
  36113. import { Vector3, Space } from "babylonjs/Maths/math";
  36114. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36115. import { Bone } from "babylonjs/Bones/bone";
  36116. /**
  36117. * Class used to make a bone look toward a point in space
  36118. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  36119. */
  36120. export class BoneLookController {
  36121. private static _tmpVecs;
  36122. private static _tmpQuat;
  36123. private static _tmpMats;
  36124. /**
  36125. * The target Vector3 that the bone will look at
  36126. */
  36127. target: Vector3;
  36128. /**
  36129. * The mesh that the bone is attached to
  36130. */
  36131. mesh: AbstractMesh;
  36132. /**
  36133. * The bone that will be looking to the target
  36134. */
  36135. bone: Bone;
  36136. /**
  36137. * The up axis of the coordinate system that is used when the bone is rotated
  36138. */
  36139. upAxis: Vector3;
  36140. /**
  36141. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  36142. */
  36143. upAxisSpace: Space;
  36144. /**
  36145. * Used to make an adjustment to the yaw of the bone
  36146. */
  36147. adjustYaw: number;
  36148. /**
  36149. * Used to make an adjustment to the pitch of the bone
  36150. */
  36151. adjustPitch: number;
  36152. /**
  36153. * Used to make an adjustment to the roll of the bone
  36154. */
  36155. adjustRoll: number;
  36156. /**
  36157. * 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)
  36158. */
  36159. slerpAmount: number;
  36160. private _minYaw;
  36161. private _maxYaw;
  36162. private _minPitch;
  36163. private _maxPitch;
  36164. private _minYawSin;
  36165. private _minYawCos;
  36166. private _maxYawSin;
  36167. private _maxYawCos;
  36168. private _midYawConstraint;
  36169. private _minPitchTan;
  36170. private _maxPitchTan;
  36171. private _boneQuat;
  36172. private _slerping;
  36173. private _transformYawPitch;
  36174. private _transformYawPitchInv;
  36175. private _firstFrameSkipped;
  36176. private _yawRange;
  36177. private _fowardAxis;
  36178. /**
  36179. * Gets or sets the minimum yaw angle that the bone can look to
  36180. */
  36181. minYaw: number;
  36182. /**
  36183. * Gets or sets the maximum yaw angle that the bone can look to
  36184. */
  36185. maxYaw: number;
  36186. /**
  36187. * Gets or sets the minimum pitch angle that the bone can look to
  36188. */
  36189. minPitch: number;
  36190. /**
  36191. * Gets or sets the maximum pitch angle that the bone can look to
  36192. */
  36193. maxPitch: number;
  36194. /**
  36195. * Create a BoneLookController
  36196. * @param mesh the mesh that the bone belongs to
  36197. * @param bone the bone that will be looking to the target
  36198. * @param target the target Vector3 to look at
  36199. * @param options optional settings:
  36200. * * maxYaw: the maximum angle the bone will yaw to
  36201. * * minYaw: the minimum angle the bone will yaw to
  36202. * * maxPitch: the maximum angle the bone will pitch to
  36203. * * minPitch: the minimum angle the bone will yaw to
  36204. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  36205. * * upAxis: the up axis of the coordinate system
  36206. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  36207. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  36208. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  36209. * * adjustYaw: used to make an adjustment to the yaw of the bone
  36210. * * adjustPitch: used to make an adjustment to the pitch of the bone
  36211. * * adjustRoll: used to make an adjustment to the roll of the bone
  36212. **/
  36213. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  36214. maxYaw?: number;
  36215. minYaw?: number;
  36216. maxPitch?: number;
  36217. minPitch?: number;
  36218. slerpAmount?: number;
  36219. upAxis?: Vector3;
  36220. upAxisSpace?: Space;
  36221. yawAxis?: Vector3;
  36222. pitchAxis?: Vector3;
  36223. adjustYaw?: number;
  36224. adjustPitch?: number;
  36225. adjustRoll?: number;
  36226. });
  36227. /**
  36228. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  36229. */
  36230. update(): void;
  36231. private _getAngleDiff;
  36232. private _getAngleBetween;
  36233. private _isAngleBetween;
  36234. }
  36235. }
  36236. declare module "babylonjs/Bones/index" {
  36237. export * from "babylonjs/Bones/bone";
  36238. export * from "babylonjs/Bones/boneIKController";
  36239. export * from "babylonjs/Bones/boneLookController";
  36240. export * from "babylonjs/Bones/skeleton";
  36241. }
  36242. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  36243. import { Nullable } from "babylonjs/types";
  36244. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36245. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36246. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  36247. /**
  36248. * Manage the gamepad inputs to control an arc rotate camera.
  36249. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36250. */
  36251. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  36252. /**
  36253. * Defines the camera the input is attached to.
  36254. */
  36255. camera: ArcRotateCamera;
  36256. /**
  36257. * Defines the gamepad the input is gathering event from.
  36258. */
  36259. gamepad: Nullable<Gamepad>;
  36260. /**
  36261. * Defines the gamepad rotation sensiblity.
  36262. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  36263. */
  36264. gamepadRotationSensibility: number;
  36265. /**
  36266. * Defines the gamepad move sensiblity.
  36267. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  36268. */
  36269. gamepadMoveSensibility: number;
  36270. private _onGamepadConnectedObserver;
  36271. private _onGamepadDisconnectedObserver;
  36272. /**
  36273. * Attach the input controls to a specific dom element to get the input from.
  36274. * @param element Defines the element the controls should be listened from
  36275. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36276. */
  36277. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36278. /**
  36279. * Detach the current controls from the specified dom element.
  36280. * @param element Defines the element to stop listening the inputs from
  36281. */
  36282. detachControl(element: Nullable<HTMLElement>): void;
  36283. /**
  36284. * Update the current camera state depending on the inputs that have been used this frame.
  36285. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36286. */
  36287. checkInputs(): void;
  36288. /**
  36289. * Gets the class name of the current intput.
  36290. * @returns the class name
  36291. */
  36292. getClassName(): string;
  36293. /**
  36294. * Get the friendly name associated with the input class.
  36295. * @returns the input friendly name
  36296. */
  36297. getSimpleName(): string;
  36298. }
  36299. }
  36300. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  36301. import { Nullable } from "babylonjs/types";
  36302. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36303. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36304. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  36305. interface ArcRotateCameraInputsManager {
  36306. /**
  36307. * Add orientation input support to the input manager.
  36308. * @returns the current input manager
  36309. */
  36310. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  36311. }
  36312. }
  36313. /**
  36314. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  36315. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36316. */
  36317. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  36318. /**
  36319. * Defines the camera the input is attached to.
  36320. */
  36321. camera: ArcRotateCamera;
  36322. /**
  36323. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  36324. */
  36325. alphaCorrection: number;
  36326. /**
  36327. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  36328. */
  36329. gammaCorrection: number;
  36330. private _alpha;
  36331. private _gamma;
  36332. private _dirty;
  36333. private _deviceOrientationHandler;
  36334. /**
  36335. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  36336. */
  36337. constructor();
  36338. /**
  36339. * Attach the input controls to a specific dom element to get the input from.
  36340. * @param element Defines the element the controls should be listened from
  36341. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36342. */
  36343. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36344. /** @hidden */
  36345. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  36346. /**
  36347. * Update the current camera state depending on the inputs that have been used this frame.
  36348. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36349. */
  36350. checkInputs(): void;
  36351. /**
  36352. * Detach the current controls from the specified dom element.
  36353. * @param element Defines the element to stop listening the inputs from
  36354. */
  36355. detachControl(element: Nullable<HTMLElement>): void;
  36356. /**
  36357. * Gets the class name of the current intput.
  36358. * @returns the class name
  36359. */
  36360. getClassName(): string;
  36361. /**
  36362. * Get the friendly name associated with the input class.
  36363. * @returns the input friendly name
  36364. */
  36365. getSimpleName(): string;
  36366. }
  36367. }
  36368. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  36369. import { Nullable } from "babylonjs/types";
  36370. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36371. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  36372. /**
  36373. * Listen to mouse events to control the camera.
  36374. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36375. */
  36376. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  36377. /**
  36378. * Defines the camera the input is attached to.
  36379. */
  36380. camera: FlyCamera;
  36381. /**
  36382. * Defines if touch is enabled. (Default is true.)
  36383. */
  36384. touchEnabled: boolean;
  36385. /**
  36386. * Defines the buttons associated with the input to handle camera rotation.
  36387. */
  36388. buttons: number[];
  36389. /**
  36390. * Assign buttons for Yaw control.
  36391. */
  36392. buttonsYaw: number[];
  36393. /**
  36394. * Assign buttons for Pitch control.
  36395. */
  36396. buttonsPitch: number[];
  36397. /**
  36398. * Assign buttons for Roll control.
  36399. */
  36400. buttonsRoll: number[];
  36401. /**
  36402. * Detect if any button is being pressed while mouse is moved.
  36403. * -1 = Mouse locked.
  36404. * 0 = Left button.
  36405. * 1 = Middle Button.
  36406. * 2 = Right Button.
  36407. */
  36408. activeButton: number;
  36409. /**
  36410. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  36411. * Higher values reduce its sensitivity.
  36412. */
  36413. angularSensibility: number;
  36414. private _mousemoveCallback;
  36415. private _observer;
  36416. private _rollObserver;
  36417. private previousPosition;
  36418. private noPreventDefault;
  36419. private element;
  36420. /**
  36421. * Listen to mouse events to control the camera.
  36422. * @param touchEnabled Define if touch is enabled. (Default is true.)
  36423. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36424. */
  36425. constructor(touchEnabled?: boolean);
  36426. /**
  36427. * Attach the mouse control to the HTML DOM element.
  36428. * @param element Defines the element that listens to the input events.
  36429. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  36430. */
  36431. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36432. /**
  36433. * Detach the current controls from the specified dom element.
  36434. * @param element Defines the element to stop listening the inputs from
  36435. */
  36436. detachControl(element: Nullable<HTMLElement>): void;
  36437. /**
  36438. * Gets the class name of the current input.
  36439. * @returns the class name.
  36440. */
  36441. getClassName(): string;
  36442. /**
  36443. * Get the friendly name associated with the input class.
  36444. * @returns the input's friendly name.
  36445. */
  36446. getSimpleName(): string;
  36447. private _pointerInput;
  36448. private _onMouseMove;
  36449. /**
  36450. * Rotate camera by mouse offset.
  36451. */
  36452. private rotateCamera;
  36453. }
  36454. }
  36455. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  36456. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  36457. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  36458. /**
  36459. * Default Inputs manager for the FlyCamera.
  36460. * It groups all the default supported inputs for ease of use.
  36461. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36462. */
  36463. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  36464. /**
  36465. * Instantiates a new FlyCameraInputsManager.
  36466. * @param camera Defines the camera the inputs belong to.
  36467. */
  36468. constructor(camera: FlyCamera);
  36469. /**
  36470. * Add keyboard input support to the input manager.
  36471. * @returns the new FlyCameraKeyboardMoveInput().
  36472. */
  36473. addKeyboard(): FlyCameraInputsManager;
  36474. /**
  36475. * Add mouse input support to the input manager.
  36476. * @param touchEnabled Enable touch screen support.
  36477. * @returns the new FlyCameraMouseInput().
  36478. */
  36479. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  36480. }
  36481. }
  36482. declare module "babylonjs/Cameras/flyCamera" {
  36483. import { Scene } from "babylonjs/scene";
  36484. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  36485. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36486. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  36487. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  36488. /**
  36489. * This is a flying camera, designed for 3D movement and rotation in all directions,
  36490. * such as in a 3D Space Shooter or a Flight Simulator.
  36491. */
  36492. export class FlyCamera extends TargetCamera {
  36493. /**
  36494. * Define the collision ellipsoid of the camera.
  36495. * This is helpful for simulating a camera body, like a player's body.
  36496. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  36497. */
  36498. ellipsoid: Vector3;
  36499. /**
  36500. * Define an offset for the position of the ellipsoid around the camera.
  36501. * This can be helpful if the camera is attached away from the player's body center,
  36502. * such as at its head.
  36503. */
  36504. ellipsoidOffset: Vector3;
  36505. /**
  36506. * Enable or disable collisions of the camera with the rest of the scene objects.
  36507. */
  36508. checkCollisions: boolean;
  36509. /**
  36510. * Enable or disable gravity on the camera.
  36511. */
  36512. applyGravity: boolean;
  36513. /**
  36514. * Define the current direction the camera is moving to.
  36515. */
  36516. cameraDirection: Vector3;
  36517. /**
  36518. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  36519. * This overrides and empties cameraRotation.
  36520. */
  36521. rotationQuaternion: Quaternion;
  36522. /**
  36523. * Track Roll to maintain the wanted Rolling when looking around.
  36524. */
  36525. _trackRoll: number;
  36526. /**
  36527. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  36528. */
  36529. rollCorrect: number;
  36530. /**
  36531. * Mimic a banked turn, Rolling the camera when Yawing.
  36532. * It's recommended to use rollCorrect = 10 for faster banking correction.
  36533. */
  36534. bankedTurn: boolean;
  36535. /**
  36536. * Limit in radians for how much Roll banking will add. (Default: 90°)
  36537. */
  36538. bankedTurnLimit: number;
  36539. /**
  36540. * Value of 0 disables the banked Roll.
  36541. * Value of 1 is equal to the Yaw angle in radians.
  36542. */
  36543. bankedTurnMultiplier: number;
  36544. /**
  36545. * The inputs manager loads all the input sources, such as keyboard and mouse.
  36546. */
  36547. inputs: FlyCameraInputsManager;
  36548. /**
  36549. * Gets the input sensibility for mouse input.
  36550. * Higher values reduce sensitivity.
  36551. */
  36552. /**
  36553. * Sets the input sensibility for a mouse input.
  36554. * Higher values reduce sensitivity.
  36555. */
  36556. angularSensibility: number;
  36557. /**
  36558. * Get the keys for camera movement forward.
  36559. */
  36560. /**
  36561. * Set the keys for camera movement forward.
  36562. */
  36563. keysForward: number[];
  36564. /**
  36565. * Get the keys for camera movement backward.
  36566. */
  36567. keysBackward: number[];
  36568. /**
  36569. * Get the keys for camera movement up.
  36570. */
  36571. /**
  36572. * Set the keys for camera movement up.
  36573. */
  36574. keysUp: number[];
  36575. /**
  36576. * Get the keys for camera movement down.
  36577. */
  36578. /**
  36579. * Set the keys for camera movement down.
  36580. */
  36581. keysDown: number[];
  36582. /**
  36583. * Get the keys for camera movement left.
  36584. */
  36585. /**
  36586. * Set the keys for camera movement left.
  36587. */
  36588. keysLeft: number[];
  36589. /**
  36590. * Set the keys for camera movement right.
  36591. */
  36592. /**
  36593. * Set the keys for camera movement right.
  36594. */
  36595. keysRight: number[];
  36596. /**
  36597. * Event raised when the camera collides with a mesh in the scene.
  36598. */
  36599. onCollide: (collidedMesh: AbstractMesh) => void;
  36600. private _collider;
  36601. private _needMoveForGravity;
  36602. private _oldPosition;
  36603. private _diffPosition;
  36604. private _newPosition;
  36605. /** @hidden */
  36606. _localDirection: Vector3;
  36607. /** @hidden */
  36608. _transformedDirection: Vector3;
  36609. /**
  36610. * Instantiates a FlyCamera.
  36611. * This is a flying camera, designed for 3D movement and rotation in all directions,
  36612. * such as in a 3D Space Shooter or a Flight Simulator.
  36613. * @param name Define the name of the camera in the scene.
  36614. * @param position Define the starting position of the camera in the scene.
  36615. * @param scene Define the scene the camera belongs to.
  36616. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  36617. */
  36618. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  36619. /**
  36620. * Attach a control to the HTML DOM element.
  36621. * @param element Defines the element that listens to the input events.
  36622. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  36623. */
  36624. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36625. /**
  36626. * Detach a control from the HTML DOM element.
  36627. * The camera will stop reacting to that input.
  36628. * @param element Defines the element that listens to the input events.
  36629. */
  36630. detachControl(element: HTMLElement): void;
  36631. private _collisionMask;
  36632. /**
  36633. * Get the mask that the camera ignores in collision events.
  36634. */
  36635. /**
  36636. * Set the mask that the camera ignores in collision events.
  36637. */
  36638. collisionMask: number;
  36639. /** @hidden */
  36640. _collideWithWorld(displacement: Vector3): void;
  36641. /** @hidden */
  36642. private _onCollisionPositionChange;
  36643. /** @hidden */
  36644. _checkInputs(): void;
  36645. /** @hidden */
  36646. _decideIfNeedsToMove(): boolean;
  36647. /** @hidden */
  36648. _updatePosition(): void;
  36649. /**
  36650. * Restore the Roll to its target value at the rate specified.
  36651. * @param rate - Higher means slower restoring.
  36652. * @hidden
  36653. */
  36654. restoreRoll(rate: number): void;
  36655. /**
  36656. * Destroy the camera and release the current resources held by it.
  36657. */
  36658. dispose(): void;
  36659. /**
  36660. * Get the current object class name.
  36661. * @returns the class name.
  36662. */
  36663. getClassName(): string;
  36664. }
  36665. }
  36666. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  36667. import { Nullable } from "babylonjs/types";
  36668. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36669. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  36670. /**
  36671. * Listen to keyboard events to control the camera.
  36672. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36673. */
  36674. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  36675. /**
  36676. * Defines the camera the input is attached to.
  36677. */
  36678. camera: FlyCamera;
  36679. /**
  36680. * The list of keyboard keys used to control the forward move of the camera.
  36681. */
  36682. keysForward: number[];
  36683. /**
  36684. * The list of keyboard keys used to control the backward move of the camera.
  36685. */
  36686. keysBackward: number[];
  36687. /**
  36688. * The list of keyboard keys used to control the forward move of the camera.
  36689. */
  36690. keysUp: number[];
  36691. /**
  36692. * The list of keyboard keys used to control the backward move of the camera.
  36693. */
  36694. keysDown: number[];
  36695. /**
  36696. * The list of keyboard keys used to control the right strafe move of the camera.
  36697. */
  36698. keysRight: number[];
  36699. /**
  36700. * The list of keyboard keys used to control the left strafe move of the camera.
  36701. */
  36702. keysLeft: number[];
  36703. private _keys;
  36704. private _onCanvasBlurObserver;
  36705. private _onKeyboardObserver;
  36706. private _engine;
  36707. private _scene;
  36708. /**
  36709. * Attach the input controls to a specific dom element to get the input from.
  36710. * @param element Defines the element the controls should be listened from
  36711. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36712. */
  36713. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36714. /**
  36715. * Detach the current controls from the specified dom element.
  36716. * @param element Defines the element to stop listening the inputs from
  36717. */
  36718. detachControl(element: Nullable<HTMLElement>): void;
  36719. /**
  36720. * Gets the class name of the current intput.
  36721. * @returns the class name
  36722. */
  36723. getClassName(): string;
  36724. /** @hidden */
  36725. _onLostFocus(e: FocusEvent): void;
  36726. /**
  36727. * Get the friendly name associated with the input class.
  36728. * @returns the input friendly name
  36729. */
  36730. getSimpleName(): string;
  36731. /**
  36732. * Update the current camera state depending on the inputs that have been used this frame.
  36733. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36734. */
  36735. checkInputs(): void;
  36736. }
  36737. }
  36738. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  36739. import { Nullable } from "babylonjs/types";
  36740. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  36741. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36742. /**
  36743. * Manage the mouse wheel inputs to control a follow camera.
  36744. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36745. */
  36746. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  36747. /**
  36748. * Defines the camera the input is attached to.
  36749. */
  36750. camera: FollowCamera;
  36751. /**
  36752. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  36753. */
  36754. axisControlRadius: boolean;
  36755. /**
  36756. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  36757. */
  36758. axisControlHeight: boolean;
  36759. /**
  36760. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  36761. */
  36762. axisControlRotation: boolean;
  36763. /**
  36764. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  36765. * relation to mouseWheel events.
  36766. */
  36767. wheelPrecision: number;
  36768. /**
  36769. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  36770. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  36771. */
  36772. wheelDeltaPercentage: number;
  36773. private _wheel;
  36774. private _observer;
  36775. /**
  36776. * Attach the input controls to a specific dom element to get the input from.
  36777. * @param element Defines the element the controls should be listened from
  36778. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36779. */
  36780. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36781. /**
  36782. * Detach the current controls from the specified dom element.
  36783. * @param element Defines the element to stop listening the inputs from
  36784. */
  36785. detachControl(element: Nullable<HTMLElement>): void;
  36786. /**
  36787. * Gets the class name of the current intput.
  36788. * @returns the class name
  36789. */
  36790. getClassName(): string;
  36791. /**
  36792. * Get the friendly name associated with the input class.
  36793. * @returns the input friendly name
  36794. */
  36795. getSimpleName(): string;
  36796. }
  36797. }
  36798. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  36799. import { Nullable } from "babylonjs/types";
  36800. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  36801. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  36802. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  36803. /**
  36804. * Manage the pointers inputs to control an follow camera.
  36805. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36806. */
  36807. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  36808. /**
  36809. * Defines the camera the input is attached to.
  36810. */
  36811. camera: FollowCamera;
  36812. /**
  36813. * Gets the class name of the current input.
  36814. * @returns the class name
  36815. */
  36816. getClassName(): string;
  36817. /**
  36818. * Defines the pointer angular sensibility along the X axis or how fast is
  36819. * the camera rotating.
  36820. * A negative number will reverse the axis direction.
  36821. */
  36822. angularSensibilityX: number;
  36823. /**
  36824. * Defines the pointer angular sensibility along the Y axis or how fast is
  36825. * the camera rotating.
  36826. * A negative number will reverse the axis direction.
  36827. */
  36828. angularSensibilityY: number;
  36829. /**
  36830. * Defines the pointer pinch precision or how fast is the camera zooming.
  36831. * A negative number will reverse the axis direction.
  36832. */
  36833. pinchPrecision: number;
  36834. /**
  36835. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  36836. * from 0.
  36837. * It defines the percentage of current camera.radius to use as delta when
  36838. * pinch zoom is used.
  36839. */
  36840. pinchDeltaPercentage: number;
  36841. /**
  36842. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  36843. */
  36844. axisXControlRadius: boolean;
  36845. /**
  36846. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  36847. */
  36848. axisXControlHeight: boolean;
  36849. /**
  36850. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  36851. */
  36852. axisXControlRotation: boolean;
  36853. /**
  36854. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  36855. */
  36856. axisYControlRadius: boolean;
  36857. /**
  36858. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  36859. */
  36860. axisYControlHeight: boolean;
  36861. /**
  36862. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  36863. */
  36864. axisYControlRotation: boolean;
  36865. /**
  36866. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  36867. */
  36868. axisPinchControlRadius: boolean;
  36869. /**
  36870. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  36871. */
  36872. axisPinchControlHeight: boolean;
  36873. /**
  36874. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  36875. */
  36876. axisPinchControlRotation: boolean;
  36877. /**
  36878. * Log error messages if basic misconfiguration has occurred.
  36879. */
  36880. warningEnable: boolean;
  36881. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  36882. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  36883. private _warningCounter;
  36884. private _warning;
  36885. }
  36886. }
  36887. declare module "babylonjs/Cameras/followCameraInputsManager" {
  36888. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  36889. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  36890. /**
  36891. * Default Inputs manager for the FollowCamera.
  36892. * It groups all the default supported inputs for ease of use.
  36893. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36894. */
  36895. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  36896. /**
  36897. * Instantiates a new FollowCameraInputsManager.
  36898. * @param camera Defines the camera the inputs belong to
  36899. */
  36900. constructor(camera: FollowCamera);
  36901. /**
  36902. * Add keyboard input support to the input manager.
  36903. * @returns the current input manager
  36904. */
  36905. addKeyboard(): FollowCameraInputsManager;
  36906. /**
  36907. * Add mouse wheel input support to the input manager.
  36908. * @returns the current input manager
  36909. */
  36910. addMouseWheel(): FollowCameraInputsManager;
  36911. /**
  36912. * Add pointers input support to the input manager.
  36913. * @returns the current input manager
  36914. */
  36915. addPointers(): FollowCameraInputsManager;
  36916. /**
  36917. * Add orientation input support to the input manager.
  36918. * @returns the current input manager
  36919. */
  36920. addVRDeviceOrientation(): FollowCameraInputsManager;
  36921. }
  36922. }
  36923. declare module "babylonjs/Cameras/followCamera" {
  36924. import { Nullable } from "babylonjs/types";
  36925. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  36926. import { Scene } from "babylonjs/scene";
  36927. import { Vector3 } from "babylonjs/Maths/math";
  36928. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36929. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  36930. /**
  36931. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  36932. * an arc rotate version arcFollowCamera are available.
  36933. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  36934. */
  36935. export class FollowCamera extends TargetCamera {
  36936. /**
  36937. * Distance the follow camera should follow an object at
  36938. */
  36939. radius: number;
  36940. /**
  36941. * Minimum allowed distance of the camera to the axis of rotation
  36942. * (The camera can not get closer).
  36943. * This can help limiting how the Camera is able to move in the scene.
  36944. */
  36945. lowerRadiusLimit: Nullable<number>;
  36946. /**
  36947. * Maximum allowed distance of the camera to the axis of rotation
  36948. * (The camera can not get further).
  36949. * This can help limiting how the Camera is able to move in the scene.
  36950. */
  36951. upperRadiusLimit: Nullable<number>;
  36952. /**
  36953. * Define a rotation offset between the camera and the object it follows
  36954. */
  36955. rotationOffset: number;
  36956. /**
  36957. * Minimum allowed angle to camera position relative to target object.
  36958. * This can help limiting how the Camera is able to move in the scene.
  36959. */
  36960. lowerRotationOffsetLimit: Nullable<number>;
  36961. /**
  36962. * Maximum allowed angle to camera position relative to target object.
  36963. * This can help limiting how the Camera is able to move in the scene.
  36964. */
  36965. upperRotationOffsetLimit: Nullable<number>;
  36966. /**
  36967. * Define a height offset between the camera and the object it follows.
  36968. * It can help following an object from the top (like a car chaing a plane)
  36969. */
  36970. heightOffset: number;
  36971. /**
  36972. * Minimum allowed height of camera position relative to target object.
  36973. * This can help limiting how the Camera is able to move in the scene.
  36974. */
  36975. lowerHeightOffsetLimit: Nullable<number>;
  36976. /**
  36977. * Maximum allowed height of camera position relative to target object.
  36978. * This can help limiting how the Camera is able to move in the scene.
  36979. */
  36980. upperHeightOffsetLimit: Nullable<number>;
  36981. /**
  36982. * Define how fast the camera can accelerate to follow it s target.
  36983. */
  36984. cameraAcceleration: number;
  36985. /**
  36986. * Define the speed limit of the camera following an object.
  36987. */
  36988. maxCameraSpeed: number;
  36989. /**
  36990. * Define the target of the camera.
  36991. */
  36992. lockedTarget: Nullable<AbstractMesh>;
  36993. /**
  36994. * Defines the input associated with the camera.
  36995. */
  36996. inputs: FollowCameraInputsManager;
  36997. /**
  36998. * Instantiates the follow camera.
  36999. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37000. * @param name Define the name of the camera in the scene
  37001. * @param position Define the position of the camera
  37002. * @param scene Define the scene the camera belong to
  37003. * @param lockedTarget Define the target of the camera
  37004. */
  37005. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  37006. private _follow;
  37007. /**
  37008. * Attached controls to the current camera.
  37009. * @param element Defines the element the controls should be listened from
  37010. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37011. */
  37012. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37013. /**
  37014. * Detach the current controls from the camera.
  37015. * The camera will stop reacting to inputs.
  37016. * @param element Defines the element to stop listening the inputs from
  37017. */
  37018. detachControl(element: HTMLElement): void;
  37019. /** @hidden */
  37020. _checkInputs(): void;
  37021. private _checkLimits;
  37022. /**
  37023. * Gets the camera class name.
  37024. * @returns the class name
  37025. */
  37026. getClassName(): string;
  37027. }
  37028. /**
  37029. * Arc Rotate version of the follow camera.
  37030. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  37031. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37032. */
  37033. export class ArcFollowCamera extends TargetCamera {
  37034. /** The longitudinal angle of the camera */
  37035. alpha: number;
  37036. /** The latitudinal angle of the camera */
  37037. beta: number;
  37038. /** The radius of the camera from its target */
  37039. radius: number;
  37040. /** Define the camera target (the messh it should follow) */
  37041. target: Nullable<AbstractMesh>;
  37042. private _cartesianCoordinates;
  37043. /**
  37044. * Instantiates a new ArcFollowCamera
  37045. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37046. * @param name Define the name of the camera
  37047. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  37048. * @param beta Define the rotation angle of the camera around the elevation axis
  37049. * @param radius Define the radius of the camera from its target point
  37050. * @param target Define the target of the camera
  37051. * @param scene Define the scene the camera belongs to
  37052. */
  37053. constructor(name: string,
  37054. /** The longitudinal angle of the camera */
  37055. alpha: number,
  37056. /** The latitudinal angle of the camera */
  37057. beta: number,
  37058. /** The radius of the camera from its target */
  37059. radius: number,
  37060. /** Define the camera target (the messh it should follow) */
  37061. target: Nullable<AbstractMesh>, scene: Scene);
  37062. private _follow;
  37063. /** @hidden */
  37064. _checkInputs(): void;
  37065. /**
  37066. * Returns the class name of the object.
  37067. * It is mostly used internally for serialization purposes.
  37068. */
  37069. getClassName(): string;
  37070. }
  37071. }
  37072. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  37073. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37074. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  37075. import { Nullable } from "babylonjs/types";
  37076. /**
  37077. * Manage the keyboard inputs to control the movement of a follow camera.
  37078. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37079. */
  37080. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  37081. /**
  37082. * Defines the camera the input is attached to.
  37083. */
  37084. camera: FollowCamera;
  37085. /**
  37086. * Defines the list of key codes associated with the up action (increase heightOffset)
  37087. */
  37088. keysHeightOffsetIncr: number[];
  37089. /**
  37090. * Defines the list of key codes associated with the down action (decrease heightOffset)
  37091. */
  37092. keysHeightOffsetDecr: number[];
  37093. /**
  37094. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  37095. */
  37096. keysHeightOffsetModifierAlt: boolean;
  37097. /**
  37098. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  37099. */
  37100. keysHeightOffsetModifierCtrl: boolean;
  37101. /**
  37102. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  37103. */
  37104. keysHeightOffsetModifierShift: boolean;
  37105. /**
  37106. * Defines the list of key codes associated with the left action (increase rotationOffset)
  37107. */
  37108. keysRotationOffsetIncr: number[];
  37109. /**
  37110. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  37111. */
  37112. keysRotationOffsetDecr: number[];
  37113. /**
  37114. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  37115. */
  37116. keysRotationOffsetModifierAlt: boolean;
  37117. /**
  37118. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  37119. */
  37120. keysRotationOffsetModifierCtrl: boolean;
  37121. /**
  37122. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  37123. */
  37124. keysRotationOffsetModifierShift: boolean;
  37125. /**
  37126. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  37127. */
  37128. keysRadiusIncr: number[];
  37129. /**
  37130. * Defines the list of key codes associated with the zoom-out action (increase radius)
  37131. */
  37132. keysRadiusDecr: number[];
  37133. /**
  37134. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  37135. */
  37136. keysRadiusModifierAlt: boolean;
  37137. /**
  37138. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  37139. */
  37140. keysRadiusModifierCtrl: boolean;
  37141. /**
  37142. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  37143. */
  37144. keysRadiusModifierShift: boolean;
  37145. /**
  37146. * Defines the rate of change of heightOffset.
  37147. */
  37148. heightSensibility: number;
  37149. /**
  37150. * Defines the rate of change of rotationOffset.
  37151. */
  37152. rotationSensibility: number;
  37153. /**
  37154. * Defines the rate of change of radius.
  37155. */
  37156. radiusSensibility: number;
  37157. private _keys;
  37158. private _ctrlPressed;
  37159. private _altPressed;
  37160. private _shiftPressed;
  37161. private _onCanvasBlurObserver;
  37162. private _onKeyboardObserver;
  37163. private _engine;
  37164. private _scene;
  37165. /**
  37166. * Attach the input controls to a specific dom element to get the input from.
  37167. * @param element Defines the element the controls should be listened from
  37168. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37169. */
  37170. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37171. /**
  37172. * Detach the current controls from the specified dom element.
  37173. * @param element Defines the element to stop listening the inputs from
  37174. */
  37175. detachControl(element: Nullable<HTMLElement>): void;
  37176. /**
  37177. * Update the current camera state depending on the inputs that have been used this frame.
  37178. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37179. */
  37180. checkInputs(): void;
  37181. /**
  37182. * Gets the class name of the current input.
  37183. * @returns the class name
  37184. */
  37185. getClassName(): string;
  37186. /**
  37187. * Get the friendly name associated with the input class.
  37188. * @returns the input friendly name
  37189. */
  37190. getSimpleName(): string;
  37191. /**
  37192. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37193. * allow modification of the heightOffset value.
  37194. */
  37195. private _modifierHeightOffset;
  37196. /**
  37197. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37198. * allow modification of the rotationOffset value.
  37199. */
  37200. private _modifierRotationOffset;
  37201. /**
  37202. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37203. * allow modification of the radius value.
  37204. */
  37205. private _modifierRadius;
  37206. }
  37207. }
  37208. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  37209. import { Nullable } from "babylonjs/types";
  37210. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37211. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37212. module "babylonjs/Cameras/freeCameraInputsManager" {
  37213. interface FreeCameraInputsManager {
  37214. /**
  37215. * Add orientation input support to the input manager.
  37216. * @returns the current input manager
  37217. */
  37218. addDeviceOrientation(): FreeCameraInputsManager;
  37219. }
  37220. }
  37221. /**
  37222. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  37223. * Screen rotation is taken into account.
  37224. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37225. */
  37226. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  37227. private _camera;
  37228. private _screenOrientationAngle;
  37229. private _constantTranform;
  37230. private _screenQuaternion;
  37231. private _alpha;
  37232. private _beta;
  37233. private _gamma;
  37234. /**
  37235. * Instantiates a new input
  37236. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37237. */
  37238. constructor();
  37239. /**
  37240. * Define the camera controlled by the input.
  37241. */
  37242. camera: FreeCamera;
  37243. /**
  37244. * Attach the input controls to a specific dom element to get the input from.
  37245. * @param element Defines the element the controls should be listened from
  37246. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37247. */
  37248. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37249. private _orientationChanged;
  37250. private _deviceOrientation;
  37251. /**
  37252. * Detach the current controls from the specified dom element.
  37253. * @param element Defines the element to stop listening the inputs from
  37254. */
  37255. detachControl(element: Nullable<HTMLElement>): void;
  37256. /**
  37257. * Update the current camera state depending on the inputs that have been used this frame.
  37258. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37259. */
  37260. checkInputs(): void;
  37261. /**
  37262. * Gets the class name of the current intput.
  37263. * @returns the class name
  37264. */
  37265. getClassName(): string;
  37266. /**
  37267. * Get the friendly name associated with the input class.
  37268. * @returns the input friendly name
  37269. */
  37270. getSimpleName(): string;
  37271. }
  37272. }
  37273. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  37274. import { Nullable } from "babylonjs/types";
  37275. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37276. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37277. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  37278. /**
  37279. * Manage the gamepad inputs to control a free camera.
  37280. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37281. */
  37282. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  37283. /**
  37284. * Define the camera the input is attached to.
  37285. */
  37286. camera: FreeCamera;
  37287. /**
  37288. * Define the Gamepad controlling the input
  37289. */
  37290. gamepad: Nullable<Gamepad>;
  37291. /**
  37292. * Defines the gamepad rotation sensiblity.
  37293. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37294. */
  37295. gamepadAngularSensibility: number;
  37296. /**
  37297. * Defines the gamepad move sensiblity.
  37298. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37299. */
  37300. gamepadMoveSensibility: number;
  37301. private _onGamepadConnectedObserver;
  37302. private _onGamepadDisconnectedObserver;
  37303. private _cameraTransform;
  37304. private _deltaTransform;
  37305. private _vector3;
  37306. private _vector2;
  37307. /**
  37308. * Attach the input controls to a specific dom element to get the input from.
  37309. * @param element Defines the element the controls should be listened from
  37310. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37311. */
  37312. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37313. /**
  37314. * Detach the current controls from the specified dom element.
  37315. * @param element Defines the element to stop listening the inputs from
  37316. */
  37317. detachControl(element: Nullable<HTMLElement>): void;
  37318. /**
  37319. * Update the current camera state depending on the inputs that have been used this frame.
  37320. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37321. */
  37322. checkInputs(): void;
  37323. /**
  37324. * Gets the class name of the current intput.
  37325. * @returns the class name
  37326. */
  37327. getClassName(): string;
  37328. /**
  37329. * Get the friendly name associated with the input class.
  37330. * @returns the input friendly name
  37331. */
  37332. getSimpleName(): string;
  37333. }
  37334. }
  37335. declare module "babylonjs/Misc/virtualJoystick" {
  37336. import { Nullable } from "babylonjs/types";
  37337. import { Vector3 } from "babylonjs/Maths/math";
  37338. /**
  37339. * Defines the potential axis of a Joystick
  37340. */
  37341. export enum JoystickAxis {
  37342. /** X axis */
  37343. X = 0,
  37344. /** Y axis */
  37345. Y = 1,
  37346. /** Z axis */
  37347. Z = 2
  37348. }
  37349. /**
  37350. * Class used to define virtual joystick (used in touch mode)
  37351. */
  37352. export class VirtualJoystick {
  37353. /**
  37354. * Gets or sets a boolean indicating that left and right values must be inverted
  37355. */
  37356. reverseLeftRight: boolean;
  37357. /**
  37358. * Gets or sets a boolean indicating that up and down values must be inverted
  37359. */
  37360. reverseUpDown: boolean;
  37361. /**
  37362. * Gets the offset value for the position (ie. the change of the position value)
  37363. */
  37364. deltaPosition: Vector3;
  37365. /**
  37366. * Gets a boolean indicating if the virtual joystick was pressed
  37367. */
  37368. pressed: boolean;
  37369. /**
  37370. * Canvas the virtual joystick will render onto, default z-index of this is 5
  37371. */
  37372. static Canvas: Nullable<HTMLCanvasElement>;
  37373. private static _globalJoystickIndex;
  37374. private static vjCanvasContext;
  37375. private static vjCanvasWidth;
  37376. private static vjCanvasHeight;
  37377. private static halfWidth;
  37378. private _action;
  37379. private _axisTargetedByLeftAndRight;
  37380. private _axisTargetedByUpAndDown;
  37381. private _joystickSensibility;
  37382. private _inversedSensibility;
  37383. private _joystickPointerID;
  37384. private _joystickColor;
  37385. private _joystickPointerPos;
  37386. private _joystickPreviousPointerPos;
  37387. private _joystickPointerStartPos;
  37388. private _deltaJoystickVector;
  37389. private _leftJoystick;
  37390. private _touches;
  37391. private _onPointerDownHandlerRef;
  37392. private _onPointerMoveHandlerRef;
  37393. private _onPointerUpHandlerRef;
  37394. private _onResize;
  37395. /**
  37396. * Creates a new virtual joystick
  37397. * @param leftJoystick defines that the joystick is for left hand (false by default)
  37398. */
  37399. constructor(leftJoystick?: boolean);
  37400. /**
  37401. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  37402. * @param newJoystickSensibility defines the new sensibility
  37403. */
  37404. setJoystickSensibility(newJoystickSensibility: number): void;
  37405. private _onPointerDown;
  37406. private _onPointerMove;
  37407. private _onPointerUp;
  37408. /**
  37409. * Change the color of the virtual joystick
  37410. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  37411. */
  37412. setJoystickColor(newColor: string): void;
  37413. /**
  37414. * Defines a callback to call when the joystick is touched
  37415. * @param action defines the callback
  37416. */
  37417. setActionOnTouch(action: () => any): void;
  37418. /**
  37419. * Defines which axis you'd like to control for left & right
  37420. * @param axis defines the axis to use
  37421. */
  37422. setAxisForLeftRight(axis: JoystickAxis): void;
  37423. /**
  37424. * Defines which axis you'd like to control for up & down
  37425. * @param axis defines the axis to use
  37426. */
  37427. setAxisForUpDown(axis: JoystickAxis): void;
  37428. private _drawVirtualJoystick;
  37429. /**
  37430. * Release internal HTML canvas
  37431. */
  37432. releaseCanvas(): void;
  37433. }
  37434. }
  37435. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  37436. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  37437. import { Nullable } from "babylonjs/types";
  37438. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37439. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37440. module "babylonjs/Cameras/freeCameraInputsManager" {
  37441. interface FreeCameraInputsManager {
  37442. /**
  37443. * Add virtual joystick input support to the input manager.
  37444. * @returns the current input manager
  37445. */
  37446. addVirtualJoystick(): FreeCameraInputsManager;
  37447. }
  37448. }
  37449. /**
  37450. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  37451. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37452. */
  37453. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  37454. /**
  37455. * Defines the camera the input is attached to.
  37456. */
  37457. camera: FreeCamera;
  37458. private _leftjoystick;
  37459. private _rightjoystick;
  37460. /**
  37461. * Gets the left stick of the virtual joystick.
  37462. * @returns The virtual Joystick
  37463. */
  37464. getLeftJoystick(): VirtualJoystick;
  37465. /**
  37466. * Gets the right stick of the virtual joystick.
  37467. * @returns The virtual Joystick
  37468. */
  37469. getRightJoystick(): VirtualJoystick;
  37470. /**
  37471. * Update the current camera state depending on the inputs that have been used this frame.
  37472. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37473. */
  37474. checkInputs(): void;
  37475. /**
  37476. * Attach the input controls to a specific dom element to get the input from.
  37477. * @param element Defines the element the controls should be listened from
  37478. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37479. */
  37480. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37481. /**
  37482. * Detach the current controls from the specified dom element.
  37483. * @param element Defines the element to stop listening the inputs from
  37484. */
  37485. detachControl(element: Nullable<HTMLElement>): void;
  37486. /**
  37487. * Gets the class name of the current intput.
  37488. * @returns the class name
  37489. */
  37490. getClassName(): string;
  37491. /**
  37492. * Get the friendly name associated with the input class.
  37493. * @returns the input friendly name
  37494. */
  37495. getSimpleName(): string;
  37496. }
  37497. }
  37498. declare module "babylonjs/Cameras/Inputs/index" {
  37499. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  37500. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  37501. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  37502. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  37503. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  37504. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  37505. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  37506. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  37507. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  37508. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  37509. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  37510. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  37511. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  37512. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  37513. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  37514. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  37515. }
  37516. declare module "babylonjs/Cameras/touchCamera" {
  37517. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37518. import { Scene } from "babylonjs/scene";
  37519. import { Vector3 } from "babylonjs/Maths/math";
  37520. /**
  37521. * This represents a FPS type of camera controlled by touch.
  37522. * This is like a universal camera minus the Gamepad controls.
  37523. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37524. */
  37525. export class TouchCamera extends FreeCamera {
  37526. /**
  37527. * Defines the touch sensibility for rotation.
  37528. * The higher the faster.
  37529. */
  37530. touchAngularSensibility: number;
  37531. /**
  37532. * Defines the touch sensibility for move.
  37533. * The higher the faster.
  37534. */
  37535. touchMoveSensibility: number;
  37536. /**
  37537. * Instantiates a new touch camera.
  37538. * This represents a FPS type of camera controlled by touch.
  37539. * This is like a universal camera minus the Gamepad controls.
  37540. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37541. * @param name Define the name of the camera in the scene
  37542. * @param position Define the start position of the camera in the scene
  37543. * @param scene Define the scene the camera belongs to
  37544. */
  37545. constructor(name: string, position: Vector3, scene: Scene);
  37546. /**
  37547. * Gets the current object class name.
  37548. * @return the class name
  37549. */
  37550. getClassName(): string;
  37551. /** @hidden */
  37552. _setupInputs(): void;
  37553. }
  37554. }
  37555. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  37556. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37557. import { Scene } from "babylonjs/scene";
  37558. import { Vector3, Axis } from "babylonjs/Maths/math";
  37559. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  37560. /**
  37561. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  37562. * being tilted forward or back and left or right.
  37563. */
  37564. export class DeviceOrientationCamera extends FreeCamera {
  37565. private _initialQuaternion;
  37566. private _quaternionCache;
  37567. /**
  37568. * Creates a new device orientation camera
  37569. * @param name The name of the camera
  37570. * @param position The start position camera
  37571. * @param scene The scene the camera belongs to
  37572. */
  37573. constructor(name: string, position: Vector3, scene: Scene);
  37574. /**
  37575. * Gets the current instance class name ("DeviceOrientationCamera").
  37576. * This helps avoiding instanceof at run time.
  37577. * @returns the class name
  37578. */
  37579. getClassName(): string;
  37580. /**
  37581. * @hidden
  37582. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  37583. */
  37584. _checkInputs(): void;
  37585. /**
  37586. * Reset the camera to its default orientation on the specified axis only.
  37587. * @param axis The axis to reset
  37588. */
  37589. resetToCurrentRotation(axis?: Axis): void;
  37590. }
  37591. }
  37592. declare module "babylonjs/Cameras/universalCamera" {
  37593. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  37594. import { Scene } from "babylonjs/scene";
  37595. import { Vector3 } from "babylonjs/Maths/math";
  37596. /**
  37597. * 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,
  37598. * which still works and will still be found in many Playgrounds.
  37599. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37600. */
  37601. export class UniversalCamera extends TouchCamera {
  37602. /**
  37603. * Defines the gamepad rotation sensiblity.
  37604. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37605. */
  37606. gamepadAngularSensibility: number;
  37607. /**
  37608. * Defines the gamepad move sensiblity.
  37609. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37610. */
  37611. gamepadMoveSensibility: number;
  37612. /**
  37613. * 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,
  37614. * which still works and will still be found in many Playgrounds.
  37615. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37616. * @param name Define the name of the camera in the scene
  37617. * @param position Define the start position of the camera in the scene
  37618. * @param scene Define the scene the camera belongs to
  37619. */
  37620. constructor(name: string, position: Vector3, scene: Scene);
  37621. /**
  37622. * Gets the current object class name.
  37623. * @return the class name
  37624. */
  37625. getClassName(): string;
  37626. }
  37627. }
  37628. declare module "babylonjs/Cameras/gamepadCamera" {
  37629. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  37630. import { Scene } from "babylonjs/scene";
  37631. import { Vector3 } from "babylonjs/Maths/math";
  37632. /**
  37633. * This represents a FPS type of camera. This is only here for back compat purpose.
  37634. * Please use the UniversalCamera instead as both are identical.
  37635. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37636. */
  37637. export class GamepadCamera extends UniversalCamera {
  37638. /**
  37639. * Instantiates a new Gamepad Camera
  37640. * This represents a FPS type of camera. This is only here for back compat purpose.
  37641. * Please use the UniversalCamera instead as both are identical.
  37642. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37643. * @param name Define the name of the camera in the scene
  37644. * @param position Define the start position of the camera in the scene
  37645. * @param scene Define the scene the camera belongs to
  37646. */
  37647. constructor(name: string, position: Vector3, scene: Scene);
  37648. /**
  37649. * Gets the current object class name.
  37650. * @return the class name
  37651. */
  37652. getClassName(): string;
  37653. }
  37654. }
  37655. declare module "babylonjs/Shaders/pass.fragment" {
  37656. /** @hidden */
  37657. export var passPixelShader: {
  37658. name: string;
  37659. shader: string;
  37660. };
  37661. }
  37662. declare module "babylonjs/Shaders/passCube.fragment" {
  37663. /** @hidden */
  37664. export var passCubePixelShader: {
  37665. name: string;
  37666. shader: string;
  37667. };
  37668. }
  37669. declare module "babylonjs/PostProcesses/passPostProcess" {
  37670. import { Nullable } from "babylonjs/types";
  37671. import { Camera } from "babylonjs/Cameras/camera";
  37672. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  37673. import { Engine } from "babylonjs/Engines/engine";
  37674. import "babylonjs/Shaders/pass.fragment";
  37675. import "babylonjs/Shaders/passCube.fragment";
  37676. /**
  37677. * PassPostProcess which produces an output the same as it's input
  37678. */
  37679. export class PassPostProcess extends PostProcess {
  37680. /**
  37681. * Creates the PassPostProcess
  37682. * @param name The name of the effect.
  37683. * @param options The required width/height ratio to downsize to before computing the render pass.
  37684. * @param camera The camera to apply the render pass to.
  37685. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  37686. * @param engine The engine which the post process will be applied. (default: current engine)
  37687. * @param reusable If the post process can be reused on the same frame. (default: false)
  37688. * @param textureType The type of texture to be used when performing the post processing.
  37689. * @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)
  37690. */
  37691. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  37692. }
  37693. /**
  37694. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  37695. */
  37696. export class PassCubePostProcess extends PostProcess {
  37697. private _face;
  37698. /**
  37699. * Gets or sets the cube face to display.
  37700. * * 0 is +X
  37701. * * 1 is -X
  37702. * * 2 is +Y
  37703. * * 3 is -Y
  37704. * * 4 is +Z
  37705. * * 5 is -Z
  37706. */
  37707. face: number;
  37708. /**
  37709. * Creates the PassCubePostProcess
  37710. * @param name The name of the effect.
  37711. * @param options The required width/height ratio to downsize to before computing the render pass.
  37712. * @param camera The camera to apply the render pass to.
  37713. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  37714. * @param engine The engine which the post process will be applied. (default: current engine)
  37715. * @param reusable If the post process can be reused on the same frame. (default: false)
  37716. * @param textureType The type of texture to be used when performing the post processing.
  37717. * @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)
  37718. */
  37719. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  37720. }
  37721. }
  37722. declare module "babylonjs/Shaders/anaglyph.fragment" {
  37723. /** @hidden */
  37724. export var anaglyphPixelShader: {
  37725. name: string;
  37726. shader: string;
  37727. };
  37728. }
  37729. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  37730. import { Engine } from "babylonjs/Engines/engine";
  37731. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  37732. import { Camera } from "babylonjs/Cameras/camera";
  37733. import "babylonjs/Shaders/anaglyph.fragment";
  37734. /**
  37735. * Postprocess used to generate anaglyphic rendering
  37736. */
  37737. export class AnaglyphPostProcess extends PostProcess {
  37738. private _passedProcess;
  37739. /**
  37740. * Creates a new AnaglyphPostProcess
  37741. * @param name defines postprocess name
  37742. * @param options defines creation options or target ratio scale
  37743. * @param rigCameras defines cameras using this postprocess
  37744. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  37745. * @param engine defines hosting engine
  37746. * @param reusable defines if the postprocess will be reused multiple times per frame
  37747. */
  37748. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  37749. }
  37750. }
  37751. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  37752. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  37753. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37754. import { Scene } from "babylonjs/scene";
  37755. import { Vector3 } from "babylonjs/Maths/math";
  37756. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  37757. /**
  37758. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  37759. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37760. */
  37761. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  37762. /**
  37763. * Creates a new AnaglyphArcRotateCamera
  37764. * @param name defines camera name
  37765. * @param alpha defines alpha angle (in radians)
  37766. * @param beta defines beta angle (in radians)
  37767. * @param radius defines radius
  37768. * @param target defines camera target
  37769. * @param interaxialDistance defines distance between each color axis
  37770. * @param scene defines the hosting scene
  37771. */
  37772. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  37773. /**
  37774. * Gets camera class name
  37775. * @returns AnaglyphArcRotateCamera
  37776. */
  37777. getClassName(): string;
  37778. }
  37779. }
  37780. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  37781. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37782. import { Scene } from "babylonjs/scene";
  37783. import { Vector3 } from "babylonjs/Maths/math";
  37784. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  37785. /**
  37786. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  37787. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37788. */
  37789. export class AnaglyphFreeCamera extends FreeCamera {
  37790. /**
  37791. * Creates a new AnaglyphFreeCamera
  37792. * @param name defines camera name
  37793. * @param position defines initial position
  37794. * @param interaxialDistance defines distance between each color axis
  37795. * @param scene defines the hosting scene
  37796. */
  37797. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  37798. /**
  37799. * Gets camera class name
  37800. * @returns AnaglyphFreeCamera
  37801. */
  37802. getClassName(): string;
  37803. }
  37804. }
  37805. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  37806. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  37807. import { Scene } from "babylonjs/scene";
  37808. import { Vector3 } from "babylonjs/Maths/math";
  37809. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  37810. /**
  37811. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  37812. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37813. */
  37814. export class AnaglyphGamepadCamera extends GamepadCamera {
  37815. /**
  37816. * Creates a new AnaglyphGamepadCamera
  37817. * @param name defines camera name
  37818. * @param position defines initial position
  37819. * @param interaxialDistance defines distance between each color axis
  37820. * @param scene defines the hosting scene
  37821. */
  37822. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  37823. /**
  37824. * Gets camera class name
  37825. * @returns AnaglyphGamepadCamera
  37826. */
  37827. getClassName(): string;
  37828. }
  37829. }
  37830. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  37831. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  37832. import { Scene } from "babylonjs/scene";
  37833. import { Vector3 } from "babylonjs/Maths/math";
  37834. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  37835. /**
  37836. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  37837. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37838. */
  37839. export class AnaglyphUniversalCamera extends UniversalCamera {
  37840. /**
  37841. * Creates a new AnaglyphUniversalCamera
  37842. * @param name defines camera name
  37843. * @param position defines initial position
  37844. * @param interaxialDistance defines distance between each color axis
  37845. * @param scene defines the hosting scene
  37846. */
  37847. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  37848. /**
  37849. * Gets camera class name
  37850. * @returns AnaglyphUniversalCamera
  37851. */
  37852. getClassName(): string;
  37853. }
  37854. }
  37855. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  37856. /** @hidden */
  37857. export var stereoscopicInterlacePixelShader: {
  37858. name: string;
  37859. shader: string;
  37860. };
  37861. }
  37862. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  37863. import { Camera } from "babylonjs/Cameras/camera";
  37864. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  37865. import { Engine } from "babylonjs/Engines/engine";
  37866. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  37867. /**
  37868. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  37869. */
  37870. export class StereoscopicInterlacePostProcess extends PostProcess {
  37871. private _stepSize;
  37872. private _passedProcess;
  37873. /**
  37874. * Initializes a StereoscopicInterlacePostProcess
  37875. * @param name The name of the effect.
  37876. * @param rigCameras The rig cameras to be appled to the post process
  37877. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  37878. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  37879. * @param engine The engine which the post process will be applied. (default: current engine)
  37880. * @param reusable If the post process can be reused on the same frame. (default: false)
  37881. */
  37882. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  37883. }
  37884. }
  37885. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  37886. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  37887. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37888. import { Scene } from "babylonjs/scene";
  37889. import { Vector3 } from "babylonjs/Maths/math";
  37890. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  37891. /**
  37892. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  37893. * @see http://doc.babylonjs.com/features/cameras
  37894. */
  37895. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  37896. /**
  37897. * Creates a new StereoscopicArcRotateCamera
  37898. * @param name defines camera name
  37899. * @param alpha defines alpha angle (in radians)
  37900. * @param beta defines beta angle (in radians)
  37901. * @param radius defines radius
  37902. * @param target defines camera target
  37903. * @param interaxialDistance defines distance between each color axis
  37904. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37905. * @param scene defines the hosting scene
  37906. */
  37907. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37908. /**
  37909. * Gets camera class name
  37910. * @returns StereoscopicArcRotateCamera
  37911. */
  37912. getClassName(): string;
  37913. }
  37914. }
  37915. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  37916. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37917. import { Scene } from "babylonjs/scene";
  37918. import { Vector3 } from "babylonjs/Maths/math";
  37919. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  37920. /**
  37921. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  37922. * @see http://doc.babylonjs.com/features/cameras
  37923. */
  37924. export class StereoscopicFreeCamera extends FreeCamera {
  37925. /**
  37926. * Creates a new StereoscopicFreeCamera
  37927. * @param name defines camera name
  37928. * @param position defines initial position
  37929. * @param interaxialDistance defines distance between each color axis
  37930. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37931. * @param scene defines the hosting scene
  37932. */
  37933. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37934. /**
  37935. * Gets camera class name
  37936. * @returns StereoscopicFreeCamera
  37937. */
  37938. getClassName(): string;
  37939. }
  37940. }
  37941. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  37942. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  37943. import { Scene } from "babylonjs/scene";
  37944. import { Vector3 } from "babylonjs/Maths/math";
  37945. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  37946. /**
  37947. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  37948. * @see http://doc.babylonjs.com/features/cameras
  37949. */
  37950. export class StereoscopicGamepadCamera extends GamepadCamera {
  37951. /**
  37952. * Creates a new StereoscopicGamepadCamera
  37953. * @param name defines camera name
  37954. * @param position defines initial position
  37955. * @param interaxialDistance defines distance between each color axis
  37956. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37957. * @param scene defines the hosting scene
  37958. */
  37959. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37960. /**
  37961. * Gets camera class name
  37962. * @returns StereoscopicGamepadCamera
  37963. */
  37964. getClassName(): string;
  37965. }
  37966. }
  37967. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  37968. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  37969. import { Scene } from "babylonjs/scene";
  37970. import { Vector3 } from "babylonjs/Maths/math";
  37971. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  37972. /**
  37973. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  37974. * @see http://doc.babylonjs.com/features/cameras
  37975. */
  37976. export class StereoscopicUniversalCamera extends UniversalCamera {
  37977. /**
  37978. * Creates a new StereoscopicUniversalCamera
  37979. * @param name defines camera name
  37980. * @param position defines initial position
  37981. * @param interaxialDistance defines distance between each color axis
  37982. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37983. * @param scene defines the hosting scene
  37984. */
  37985. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37986. /**
  37987. * Gets camera class name
  37988. * @returns StereoscopicUniversalCamera
  37989. */
  37990. getClassName(): string;
  37991. }
  37992. }
  37993. declare module "babylonjs/Cameras/Stereoscopic/index" {
  37994. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  37995. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  37996. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  37997. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  37998. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  37999. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  38000. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  38001. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  38002. }
  38003. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  38004. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38005. import { Scene } from "babylonjs/scene";
  38006. import { Vector3 } from "babylonjs/Maths/math";
  38007. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  38008. /**
  38009. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  38010. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  38011. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  38012. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  38013. */
  38014. export class VirtualJoysticksCamera extends FreeCamera {
  38015. /**
  38016. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  38017. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  38018. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  38019. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  38020. * @param name Define the name of the camera in the scene
  38021. * @param position Define the start position of the camera in the scene
  38022. * @param scene Define the scene the camera belongs to
  38023. */
  38024. constructor(name: string, position: Vector3, scene: Scene);
  38025. /**
  38026. * Gets the current object class name.
  38027. * @return the class name
  38028. */
  38029. getClassName(): string;
  38030. }
  38031. }
  38032. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  38033. import { Matrix } from "babylonjs/Maths/math";
  38034. /**
  38035. * This represents all the required metrics to create a VR camera.
  38036. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  38037. */
  38038. export class VRCameraMetrics {
  38039. /**
  38040. * Define the horizontal resolution off the screen.
  38041. */
  38042. hResolution: number;
  38043. /**
  38044. * Define the vertical resolution off the screen.
  38045. */
  38046. vResolution: number;
  38047. /**
  38048. * Define the horizontal screen size.
  38049. */
  38050. hScreenSize: number;
  38051. /**
  38052. * Define the vertical screen size.
  38053. */
  38054. vScreenSize: number;
  38055. /**
  38056. * Define the vertical screen center position.
  38057. */
  38058. vScreenCenter: number;
  38059. /**
  38060. * Define the distance of the eyes to the screen.
  38061. */
  38062. eyeToScreenDistance: number;
  38063. /**
  38064. * Define the distance between both lenses
  38065. */
  38066. lensSeparationDistance: number;
  38067. /**
  38068. * Define the distance between both viewer's eyes.
  38069. */
  38070. interpupillaryDistance: number;
  38071. /**
  38072. * Define the distortion factor of the VR postprocess.
  38073. * Please, touch with care.
  38074. */
  38075. distortionK: number[];
  38076. /**
  38077. * Define the chromatic aberration correction factors for the VR post process.
  38078. */
  38079. chromaAbCorrection: number[];
  38080. /**
  38081. * Define the scale factor of the post process.
  38082. * The smaller the better but the slower.
  38083. */
  38084. postProcessScaleFactor: number;
  38085. /**
  38086. * Define an offset for the lens center.
  38087. */
  38088. lensCenterOffset: number;
  38089. /**
  38090. * Define if the current vr camera should compensate the distortion of the lense or not.
  38091. */
  38092. compensateDistortion: boolean;
  38093. /**
  38094. * Gets the rendering aspect ratio based on the provided resolutions.
  38095. */
  38096. readonly aspectRatio: number;
  38097. /**
  38098. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  38099. */
  38100. readonly aspectRatioFov: number;
  38101. /**
  38102. * @hidden
  38103. */
  38104. readonly leftHMatrix: Matrix;
  38105. /**
  38106. * @hidden
  38107. */
  38108. readonly rightHMatrix: Matrix;
  38109. /**
  38110. * @hidden
  38111. */
  38112. readonly leftPreViewMatrix: Matrix;
  38113. /**
  38114. * @hidden
  38115. */
  38116. readonly rightPreViewMatrix: Matrix;
  38117. /**
  38118. * Get the default VRMetrics based on the most generic setup.
  38119. * @returns the default vr metrics
  38120. */
  38121. static GetDefault(): VRCameraMetrics;
  38122. }
  38123. }
  38124. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  38125. /** @hidden */
  38126. export var vrDistortionCorrectionPixelShader: {
  38127. name: string;
  38128. shader: string;
  38129. };
  38130. }
  38131. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  38132. import { Camera } from "babylonjs/Cameras/camera";
  38133. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  38134. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  38135. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  38136. /**
  38137. * VRDistortionCorrectionPostProcess used for mobile VR
  38138. */
  38139. export class VRDistortionCorrectionPostProcess extends PostProcess {
  38140. private _isRightEye;
  38141. private _distortionFactors;
  38142. private _postProcessScaleFactor;
  38143. private _lensCenterOffset;
  38144. private _scaleIn;
  38145. private _scaleFactor;
  38146. private _lensCenter;
  38147. /**
  38148. * Initializes the VRDistortionCorrectionPostProcess
  38149. * @param name The name of the effect.
  38150. * @param camera The camera to apply the render pass to.
  38151. * @param isRightEye If this is for the right eye distortion
  38152. * @param vrMetrics All the required metrics for the VR camera
  38153. */
  38154. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  38155. }
  38156. }
  38157. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  38158. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  38159. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38160. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  38161. import { Scene } from "babylonjs/scene";
  38162. import { Vector3 } from "babylonjs/Maths/math";
  38163. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  38164. import "babylonjs/Cameras/RigModes/vrRigMode";
  38165. /**
  38166. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  38167. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38168. */
  38169. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  38170. /**
  38171. * Creates a new VRDeviceOrientationArcRotateCamera
  38172. * @param name defines camera name
  38173. * @param alpha defines the camera rotation along the logitudinal axis
  38174. * @param beta defines the camera rotation along the latitudinal axis
  38175. * @param radius defines the camera distance from its target
  38176. * @param target defines the camera target
  38177. * @param scene defines the scene the camera belongs to
  38178. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38179. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38180. */
  38181. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38182. /**
  38183. * Gets camera class name
  38184. * @returns VRDeviceOrientationArcRotateCamera
  38185. */
  38186. getClassName(): string;
  38187. }
  38188. }
  38189. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  38190. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  38191. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  38192. import { Scene } from "babylonjs/scene";
  38193. import { Vector3 } from "babylonjs/Maths/math";
  38194. import "babylonjs/Cameras/RigModes/vrRigMode";
  38195. /**
  38196. * Camera used to simulate VR rendering (based on FreeCamera)
  38197. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38198. */
  38199. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  38200. /**
  38201. * Creates a new VRDeviceOrientationFreeCamera
  38202. * @param name defines camera name
  38203. * @param position defines the start position of the camera
  38204. * @param scene defines the scene the camera belongs to
  38205. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38206. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38207. */
  38208. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38209. /**
  38210. * Gets camera class name
  38211. * @returns VRDeviceOrientationFreeCamera
  38212. */
  38213. getClassName(): string;
  38214. }
  38215. }
  38216. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  38217. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  38218. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  38219. import { Scene } from "babylonjs/scene";
  38220. import { Vector3 } from "babylonjs/Maths/math";
  38221. /**
  38222. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  38223. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38224. */
  38225. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  38226. /**
  38227. * Creates a new VRDeviceOrientationGamepadCamera
  38228. * @param name defines camera name
  38229. * @param position defines the start position of the camera
  38230. * @param scene defines the scene the camera belongs to
  38231. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38232. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38233. */
  38234. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38235. /**
  38236. * Gets camera class name
  38237. * @returns VRDeviceOrientationGamepadCamera
  38238. */
  38239. getClassName(): string;
  38240. }
  38241. }
  38242. declare module "babylonjs/Gamepads/xboxGamepad" {
  38243. import { Observable } from "babylonjs/Misc/observable";
  38244. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  38245. /**
  38246. * Defines supported buttons for XBox360 compatible gamepads
  38247. */
  38248. export enum Xbox360Button {
  38249. /** A */
  38250. A = 0,
  38251. /** B */
  38252. B = 1,
  38253. /** X */
  38254. X = 2,
  38255. /** Y */
  38256. Y = 3,
  38257. /** Start */
  38258. Start = 4,
  38259. /** Back */
  38260. Back = 5,
  38261. /** Left button */
  38262. LB = 6,
  38263. /** Right button */
  38264. RB = 7,
  38265. /** Left stick */
  38266. LeftStick = 8,
  38267. /** Right stick */
  38268. RightStick = 9
  38269. }
  38270. /** Defines values for XBox360 DPad */
  38271. export enum Xbox360Dpad {
  38272. /** Up */
  38273. Up = 0,
  38274. /** Down */
  38275. Down = 1,
  38276. /** Left */
  38277. Left = 2,
  38278. /** Right */
  38279. Right = 3
  38280. }
  38281. /**
  38282. * Defines a XBox360 gamepad
  38283. */
  38284. export class Xbox360Pad extends Gamepad {
  38285. private _leftTrigger;
  38286. private _rightTrigger;
  38287. private _onlefttriggerchanged;
  38288. private _onrighttriggerchanged;
  38289. private _onbuttondown;
  38290. private _onbuttonup;
  38291. private _ondpaddown;
  38292. private _ondpadup;
  38293. /** Observable raised when a button is pressed */
  38294. onButtonDownObservable: Observable<Xbox360Button>;
  38295. /** Observable raised when a button is released */
  38296. onButtonUpObservable: Observable<Xbox360Button>;
  38297. /** Observable raised when a pad is pressed */
  38298. onPadDownObservable: Observable<Xbox360Dpad>;
  38299. /** Observable raised when a pad is released */
  38300. onPadUpObservable: Observable<Xbox360Dpad>;
  38301. private _buttonA;
  38302. private _buttonB;
  38303. private _buttonX;
  38304. private _buttonY;
  38305. private _buttonBack;
  38306. private _buttonStart;
  38307. private _buttonLB;
  38308. private _buttonRB;
  38309. private _buttonLeftStick;
  38310. private _buttonRightStick;
  38311. private _dPadUp;
  38312. private _dPadDown;
  38313. private _dPadLeft;
  38314. private _dPadRight;
  38315. private _isXboxOnePad;
  38316. /**
  38317. * Creates a new XBox360 gamepad object
  38318. * @param id defines the id of this gamepad
  38319. * @param index defines its index
  38320. * @param gamepad defines the internal HTML gamepad object
  38321. * @param xboxOne defines if it is a XBox One gamepad
  38322. */
  38323. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  38324. /**
  38325. * Defines the callback to call when left trigger is pressed
  38326. * @param callback defines the callback to use
  38327. */
  38328. onlefttriggerchanged(callback: (value: number) => void): void;
  38329. /**
  38330. * Defines the callback to call when right trigger is pressed
  38331. * @param callback defines the callback to use
  38332. */
  38333. onrighttriggerchanged(callback: (value: number) => void): void;
  38334. /**
  38335. * Gets the left trigger value
  38336. */
  38337. /**
  38338. * Sets the left trigger value
  38339. */
  38340. leftTrigger: number;
  38341. /**
  38342. * Gets the right trigger value
  38343. */
  38344. /**
  38345. * Sets the right trigger value
  38346. */
  38347. rightTrigger: number;
  38348. /**
  38349. * Defines the callback to call when a button is pressed
  38350. * @param callback defines the callback to use
  38351. */
  38352. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  38353. /**
  38354. * Defines the callback to call when a button is released
  38355. * @param callback defines the callback to use
  38356. */
  38357. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  38358. /**
  38359. * Defines the callback to call when a pad is pressed
  38360. * @param callback defines the callback to use
  38361. */
  38362. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  38363. /**
  38364. * Defines the callback to call when a pad is released
  38365. * @param callback defines the callback to use
  38366. */
  38367. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  38368. private _setButtonValue;
  38369. private _setDPadValue;
  38370. /**
  38371. * Gets the value of the `A` button
  38372. */
  38373. /**
  38374. * Sets the value of the `A` button
  38375. */
  38376. buttonA: number;
  38377. /**
  38378. * Gets the value of the `B` button
  38379. */
  38380. /**
  38381. * Sets the value of the `B` button
  38382. */
  38383. buttonB: number;
  38384. /**
  38385. * Gets the value of the `X` button
  38386. */
  38387. /**
  38388. * Sets the value of the `X` button
  38389. */
  38390. buttonX: number;
  38391. /**
  38392. * Gets the value of the `Y` button
  38393. */
  38394. /**
  38395. * Sets the value of the `Y` button
  38396. */
  38397. buttonY: number;
  38398. /**
  38399. * Gets the value of the `Start` button
  38400. */
  38401. /**
  38402. * Sets the value of the `Start` button
  38403. */
  38404. buttonStart: number;
  38405. /**
  38406. * Gets the value of the `Back` button
  38407. */
  38408. /**
  38409. * Sets the value of the `Back` button
  38410. */
  38411. buttonBack: number;
  38412. /**
  38413. * Gets the value of the `Left` button
  38414. */
  38415. /**
  38416. * Sets the value of the `Left` button
  38417. */
  38418. buttonLB: number;
  38419. /**
  38420. * Gets the value of the `Right` button
  38421. */
  38422. /**
  38423. * Sets the value of the `Right` button
  38424. */
  38425. buttonRB: number;
  38426. /**
  38427. * Gets the value of the Left joystick
  38428. */
  38429. /**
  38430. * Sets the value of the Left joystick
  38431. */
  38432. buttonLeftStick: number;
  38433. /**
  38434. * Gets the value of the Right joystick
  38435. */
  38436. /**
  38437. * Sets the value of the Right joystick
  38438. */
  38439. buttonRightStick: number;
  38440. /**
  38441. * Gets the value of D-pad up
  38442. */
  38443. /**
  38444. * Sets the value of D-pad up
  38445. */
  38446. dPadUp: number;
  38447. /**
  38448. * Gets the value of D-pad down
  38449. */
  38450. /**
  38451. * Sets the value of D-pad down
  38452. */
  38453. dPadDown: number;
  38454. /**
  38455. * Gets the value of D-pad left
  38456. */
  38457. /**
  38458. * Sets the value of D-pad left
  38459. */
  38460. dPadLeft: number;
  38461. /**
  38462. * Gets the value of D-pad right
  38463. */
  38464. /**
  38465. * Sets the value of D-pad right
  38466. */
  38467. dPadRight: number;
  38468. /**
  38469. * Force the gamepad to synchronize with device values
  38470. */
  38471. update(): void;
  38472. /**
  38473. * Disposes the gamepad
  38474. */
  38475. dispose(): void;
  38476. }
  38477. }
  38478. declare module "babylonjs/Materials/pushMaterial" {
  38479. import { Nullable } from "babylonjs/types";
  38480. import { Scene } from "babylonjs/scene";
  38481. import { Matrix } from "babylonjs/Maths/math";
  38482. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38483. import { Mesh } from "babylonjs/Meshes/mesh";
  38484. import { Material } from "babylonjs/Materials/material";
  38485. import { Effect } from "babylonjs/Materials/effect";
  38486. /**
  38487. * Base class of materials working in push mode in babylon JS
  38488. * @hidden
  38489. */
  38490. export class PushMaterial extends Material {
  38491. protected _activeEffect: Effect;
  38492. protected _normalMatrix: Matrix;
  38493. /**
  38494. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  38495. * This means that the material can keep using a previous shader while a new one is being compiled.
  38496. * This is mostly used when shader parallel compilation is supported (true by default)
  38497. */
  38498. allowShaderHotSwapping: boolean;
  38499. constructor(name: string, scene: Scene);
  38500. getEffect(): Effect;
  38501. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  38502. /**
  38503. * Binds the given world matrix to the active effect
  38504. *
  38505. * @param world the matrix to bind
  38506. */
  38507. bindOnlyWorldMatrix(world: Matrix): void;
  38508. /**
  38509. * Binds the given normal matrix to the active effect
  38510. *
  38511. * @param normalMatrix the matrix to bind
  38512. */
  38513. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  38514. bind(world: Matrix, mesh?: Mesh): void;
  38515. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  38516. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  38517. }
  38518. }
  38519. declare module "babylonjs/Materials/materialFlags" {
  38520. /**
  38521. * This groups all the flags used to control the materials channel.
  38522. */
  38523. export class MaterialFlags {
  38524. private static _DiffuseTextureEnabled;
  38525. /**
  38526. * Are diffuse textures enabled in the application.
  38527. */
  38528. static DiffuseTextureEnabled: boolean;
  38529. private static _AmbientTextureEnabled;
  38530. /**
  38531. * Are ambient textures enabled in the application.
  38532. */
  38533. static AmbientTextureEnabled: boolean;
  38534. private static _OpacityTextureEnabled;
  38535. /**
  38536. * Are opacity textures enabled in the application.
  38537. */
  38538. static OpacityTextureEnabled: boolean;
  38539. private static _ReflectionTextureEnabled;
  38540. /**
  38541. * Are reflection textures enabled in the application.
  38542. */
  38543. static ReflectionTextureEnabled: boolean;
  38544. private static _EmissiveTextureEnabled;
  38545. /**
  38546. * Are emissive textures enabled in the application.
  38547. */
  38548. static EmissiveTextureEnabled: boolean;
  38549. private static _SpecularTextureEnabled;
  38550. /**
  38551. * Are specular textures enabled in the application.
  38552. */
  38553. static SpecularTextureEnabled: boolean;
  38554. private static _BumpTextureEnabled;
  38555. /**
  38556. * Are bump textures enabled in the application.
  38557. */
  38558. static BumpTextureEnabled: boolean;
  38559. private static _LightmapTextureEnabled;
  38560. /**
  38561. * Are lightmap textures enabled in the application.
  38562. */
  38563. static LightmapTextureEnabled: boolean;
  38564. private static _RefractionTextureEnabled;
  38565. /**
  38566. * Are refraction textures enabled in the application.
  38567. */
  38568. static RefractionTextureEnabled: boolean;
  38569. private static _ColorGradingTextureEnabled;
  38570. /**
  38571. * Are color grading textures enabled in the application.
  38572. */
  38573. static ColorGradingTextureEnabled: boolean;
  38574. private static _FresnelEnabled;
  38575. /**
  38576. * Are fresnels enabled in the application.
  38577. */
  38578. static FresnelEnabled: boolean;
  38579. private static _ClearCoatTextureEnabled;
  38580. /**
  38581. * Are clear coat textures enabled in the application.
  38582. */
  38583. static ClearCoatTextureEnabled: boolean;
  38584. private static _ClearCoatBumpTextureEnabled;
  38585. /**
  38586. * Are clear coat bump textures enabled in the application.
  38587. */
  38588. static ClearCoatBumpTextureEnabled: boolean;
  38589. private static _ClearCoatTintTextureEnabled;
  38590. /**
  38591. * Are clear coat tint textures enabled in the application.
  38592. */
  38593. static ClearCoatTintTextureEnabled: boolean;
  38594. private static _SheenTextureEnabled;
  38595. /**
  38596. * Are sheen textures enabled in the application.
  38597. */
  38598. static SheenTextureEnabled: boolean;
  38599. private static _AnisotropicTextureEnabled;
  38600. /**
  38601. * Are anisotropic textures enabled in the application.
  38602. */
  38603. static AnisotropicTextureEnabled: boolean;
  38604. }
  38605. }
  38606. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  38607. /** @hidden */
  38608. export var defaultFragmentDeclaration: {
  38609. name: string;
  38610. shader: string;
  38611. };
  38612. }
  38613. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  38614. /** @hidden */
  38615. export var defaultUboDeclaration: {
  38616. name: string;
  38617. shader: string;
  38618. };
  38619. }
  38620. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  38621. /** @hidden */
  38622. export var lightFragmentDeclaration: {
  38623. name: string;
  38624. shader: string;
  38625. };
  38626. }
  38627. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  38628. /** @hidden */
  38629. export var lightUboDeclaration: {
  38630. name: string;
  38631. shader: string;
  38632. };
  38633. }
  38634. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  38635. /** @hidden */
  38636. export var lightsFragmentFunctions: {
  38637. name: string;
  38638. shader: string;
  38639. };
  38640. }
  38641. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  38642. /** @hidden */
  38643. export var shadowsFragmentFunctions: {
  38644. name: string;
  38645. shader: string;
  38646. };
  38647. }
  38648. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  38649. /** @hidden */
  38650. export var fresnelFunction: {
  38651. name: string;
  38652. shader: string;
  38653. };
  38654. }
  38655. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  38656. /** @hidden */
  38657. export var reflectionFunction: {
  38658. name: string;
  38659. shader: string;
  38660. };
  38661. }
  38662. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  38663. /** @hidden */
  38664. export var bumpFragmentFunctions: {
  38665. name: string;
  38666. shader: string;
  38667. };
  38668. }
  38669. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  38670. /** @hidden */
  38671. export var logDepthDeclaration: {
  38672. name: string;
  38673. shader: string;
  38674. };
  38675. }
  38676. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  38677. /** @hidden */
  38678. export var bumpFragment: {
  38679. name: string;
  38680. shader: string;
  38681. };
  38682. }
  38683. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  38684. /** @hidden */
  38685. export var depthPrePass: {
  38686. name: string;
  38687. shader: string;
  38688. };
  38689. }
  38690. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  38691. /** @hidden */
  38692. export var lightFragment: {
  38693. name: string;
  38694. shader: string;
  38695. };
  38696. }
  38697. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  38698. /** @hidden */
  38699. export var logDepthFragment: {
  38700. name: string;
  38701. shader: string;
  38702. };
  38703. }
  38704. declare module "babylonjs/Shaders/default.fragment" {
  38705. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  38706. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  38707. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  38708. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  38709. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  38710. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  38711. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  38712. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  38713. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  38714. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  38715. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  38716. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  38717. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  38718. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  38719. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  38720. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  38721. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  38722. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  38723. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  38724. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  38725. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  38726. /** @hidden */
  38727. export var defaultPixelShader: {
  38728. name: string;
  38729. shader: string;
  38730. };
  38731. }
  38732. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  38733. /** @hidden */
  38734. export var defaultVertexDeclaration: {
  38735. name: string;
  38736. shader: string;
  38737. };
  38738. }
  38739. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  38740. /** @hidden */
  38741. export var bumpVertexDeclaration: {
  38742. name: string;
  38743. shader: string;
  38744. };
  38745. }
  38746. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  38747. /** @hidden */
  38748. export var bumpVertex: {
  38749. name: string;
  38750. shader: string;
  38751. };
  38752. }
  38753. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  38754. /** @hidden */
  38755. export var fogVertex: {
  38756. name: string;
  38757. shader: string;
  38758. };
  38759. }
  38760. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  38761. /** @hidden */
  38762. export var shadowsVertex: {
  38763. name: string;
  38764. shader: string;
  38765. };
  38766. }
  38767. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  38768. /** @hidden */
  38769. export var pointCloudVertex: {
  38770. name: string;
  38771. shader: string;
  38772. };
  38773. }
  38774. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  38775. /** @hidden */
  38776. export var logDepthVertex: {
  38777. name: string;
  38778. shader: string;
  38779. };
  38780. }
  38781. declare module "babylonjs/Shaders/default.vertex" {
  38782. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  38783. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  38784. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  38785. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  38786. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  38787. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  38788. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  38789. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  38790. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  38791. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  38792. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  38793. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  38794. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  38795. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  38796. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  38797. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  38798. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  38799. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  38800. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  38801. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  38802. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  38803. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  38804. /** @hidden */
  38805. export var defaultVertexShader: {
  38806. name: string;
  38807. shader: string;
  38808. };
  38809. }
  38810. declare module "babylonjs/Materials/standardMaterial" {
  38811. import { SmartArray } from "babylonjs/Misc/smartArray";
  38812. import { IAnimatable } from "babylonjs/Misc/tools";
  38813. import { Nullable } from "babylonjs/types";
  38814. import { Scene } from "babylonjs/scene";
  38815. import { Matrix, Color3 } from "babylonjs/Maths/math";
  38816. import { SubMesh } from "babylonjs/Meshes/subMesh";
  38817. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38818. import { Mesh } from "babylonjs/Meshes/mesh";
  38819. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  38820. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  38821. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  38822. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  38823. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  38824. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  38825. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  38826. import "babylonjs/Shaders/default.fragment";
  38827. import "babylonjs/Shaders/default.vertex";
  38828. /** @hidden */
  38829. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  38830. MAINUV1: boolean;
  38831. MAINUV2: boolean;
  38832. DIFFUSE: boolean;
  38833. DIFFUSEDIRECTUV: number;
  38834. AMBIENT: boolean;
  38835. AMBIENTDIRECTUV: number;
  38836. OPACITY: boolean;
  38837. OPACITYDIRECTUV: number;
  38838. OPACITYRGB: boolean;
  38839. REFLECTION: boolean;
  38840. EMISSIVE: boolean;
  38841. EMISSIVEDIRECTUV: number;
  38842. SPECULAR: boolean;
  38843. SPECULARDIRECTUV: number;
  38844. BUMP: boolean;
  38845. BUMPDIRECTUV: number;
  38846. PARALLAX: boolean;
  38847. PARALLAXOCCLUSION: boolean;
  38848. SPECULAROVERALPHA: boolean;
  38849. CLIPPLANE: boolean;
  38850. CLIPPLANE2: boolean;
  38851. CLIPPLANE3: boolean;
  38852. CLIPPLANE4: boolean;
  38853. ALPHATEST: boolean;
  38854. DEPTHPREPASS: boolean;
  38855. ALPHAFROMDIFFUSE: boolean;
  38856. POINTSIZE: boolean;
  38857. FOG: boolean;
  38858. SPECULARTERM: boolean;
  38859. DIFFUSEFRESNEL: boolean;
  38860. OPACITYFRESNEL: boolean;
  38861. REFLECTIONFRESNEL: boolean;
  38862. REFRACTIONFRESNEL: boolean;
  38863. EMISSIVEFRESNEL: boolean;
  38864. FRESNEL: boolean;
  38865. NORMAL: boolean;
  38866. UV1: boolean;
  38867. UV2: boolean;
  38868. VERTEXCOLOR: boolean;
  38869. VERTEXALPHA: boolean;
  38870. NUM_BONE_INFLUENCERS: number;
  38871. BonesPerMesh: number;
  38872. BONETEXTURE: boolean;
  38873. INSTANCES: boolean;
  38874. GLOSSINESS: boolean;
  38875. ROUGHNESS: boolean;
  38876. EMISSIVEASILLUMINATION: boolean;
  38877. LINKEMISSIVEWITHDIFFUSE: boolean;
  38878. REFLECTIONFRESNELFROMSPECULAR: boolean;
  38879. LIGHTMAP: boolean;
  38880. LIGHTMAPDIRECTUV: number;
  38881. OBJECTSPACE_NORMALMAP: boolean;
  38882. USELIGHTMAPASSHADOWMAP: boolean;
  38883. REFLECTIONMAP_3D: boolean;
  38884. REFLECTIONMAP_SPHERICAL: boolean;
  38885. REFLECTIONMAP_PLANAR: boolean;
  38886. REFLECTIONMAP_CUBIC: boolean;
  38887. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  38888. REFLECTIONMAP_PROJECTION: boolean;
  38889. REFLECTIONMAP_SKYBOX: boolean;
  38890. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  38891. REFLECTIONMAP_EXPLICIT: boolean;
  38892. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  38893. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  38894. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  38895. INVERTCUBICMAP: boolean;
  38896. LOGARITHMICDEPTH: boolean;
  38897. REFRACTION: boolean;
  38898. REFRACTIONMAP_3D: boolean;
  38899. REFLECTIONOVERALPHA: boolean;
  38900. TWOSIDEDLIGHTING: boolean;
  38901. SHADOWFLOAT: boolean;
  38902. MORPHTARGETS: boolean;
  38903. MORPHTARGETS_NORMAL: boolean;
  38904. MORPHTARGETS_TANGENT: boolean;
  38905. NUM_MORPH_INFLUENCERS: number;
  38906. NONUNIFORMSCALING: boolean;
  38907. PREMULTIPLYALPHA: boolean;
  38908. IMAGEPROCESSING: boolean;
  38909. VIGNETTE: boolean;
  38910. VIGNETTEBLENDMODEMULTIPLY: boolean;
  38911. VIGNETTEBLENDMODEOPAQUE: boolean;
  38912. TONEMAPPING: boolean;
  38913. TONEMAPPING_ACES: boolean;
  38914. CONTRAST: boolean;
  38915. COLORCURVES: boolean;
  38916. COLORGRADING: boolean;
  38917. COLORGRADING3D: boolean;
  38918. SAMPLER3DGREENDEPTH: boolean;
  38919. SAMPLER3DBGRMAP: boolean;
  38920. IMAGEPROCESSINGPOSTPROCESS: boolean;
  38921. /**
  38922. * If the reflection texture on this material is in linear color space
  38923. * @hidden
  38924. */
  38925. IS_REFLECTION_LINEAR: boolean;
  38926. /**
  38927. * If the refraction texture on this material is in linear color space
  38928. * @hidden
  38929. */
  38930. IS_REFRACTION_LINEAR: boolean;
  38931. EXPOSURE: boolean;
  38932. constructor();
  38933. setReflectionMode(modeToEnable: string): void;
  38934. }
  38935. /**
  38936. * This is the default material used in Babylon. It is the best trade off between quality
  38937. * and performances.
  38938. * @see http://doc.babylonjs.com/babylon101/materials
  38939. */
  38940. export class StandardMaterial extends PushMaterial {
  38941. private _diffuseTexture;
  38942. /**
  38943. * The basic texture of the material as viewed under a light.
  38944. */
  38945. diffuseTexture: Nullable<BaseTexture>;
  38946. private _ambientTexture;
  38947. /**
  38948. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  38949. */
  38950. ambientTexture: Nullable<BaseTexture>;
  38951. private _opacityTexture;
  38952. /**
  38953. * Define the transparency of the material from a texture.
  38954. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  38955. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  38956. */
  38957. opacityTexture: Nullable<BaseTexture>;
  38958. private _reflectionTexture;
  38959. /**
  38960. * Define the texture used to display the reflection.
  38961. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  38962. */
  38963. reflectionTexture: Nullable<BaseTexture>;
  38964. private _emissiveTexture;
  38965. /**
  38966. * Define texture of the material as if self lit.
  38967. * This will be mixed in the final result even in the absence of light.
  38968. */
  38969. emissiveTexture: Nullable<BaseTexture>;
  38970. private _specularTexture;
  38971. /**
  38972. * Define how the color and intensity of the highlight given by the light in the material.
  38973. */
  38974. specularTexture: Nullable<BaseTexture>;
  38975. private _bumpTexture;
  38976. /**
  38977. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  38978. * 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.
  38979. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  38980. */
  38981. bumpTexture: Nullable<BaseTexture>;
  38982. private _lightmapTexture;
  38983. /**
  38984. * Complex lighting can be computationally expensive to compute at runtime.
  38985. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  38986. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  38987. */
  38988. lightmapTexture: Nullable<BaseTexture>;
  38989. private _refractionTexture;
  38990. /**
  38991. * Define the texture used to display the refraction.
  38992. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  38993. */
  38994. refractionTexture: Nullable<BaseTexture>;
  38995. /**
  38996. * The color of the material lit by the environmental background lighting.
  38997. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  38998. */
  38999. ambientColor: Color3;
  39000. /**
  39001. * The basic color of the material as viewed under a light.
  39002. */
  39003. diffuseColor: Color3;
  39004. /**
  39005. * Define how the color and intensity of the highlight given by the light in the material.
  39006. */
  39007. specularColor: Color3;
  39008. /**
  39009. * Define the color of the material as if self lit.
  39010. * This will be mixed in the final result even in the absence of light.
  39011. */
  39012. emissiveColor: Color3;
  39013. /**
  39014. * Defines how sharp are the highlights in the material.
  39015. * The bigger the value the sharper giving a more glossy feeling to the result.
  39016. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  39017. */
  39018. specularPower: number;
  39019. private _useAlphaFromDiffuseTexture;
  39020. /**
  39021. * Does the transparency come from the diffuse texture alpha channel.
  39022. */
  39023. useAlphaFromDiffuseTexture: boolean;
  39024. private _useEmissiveAsIllumination;
  39025. /**
  39026. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  39027. */
  39028. useEmissiveAsIllumination: boolean;
  39029. private _linkEmissiveWithDiffuse;
  39030. /**
  39031. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  39032. * the emissive level when the final color is close to one.
  39033. */
  39034. linkEmissiveWithDiffuse: boolean;
  39035. private _useSpecularOverAlpha;
  39036. /**
  39037. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  39038. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  39039. */
  39040. useSpecularOverAlpha: boolean;
  39041. private _useReflectionOverAlpha;
  39042. /**
  39043. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  39044. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  39045. */
  39046. useReflectionOverAlpha: boolean;
  39047. private _disableLighting;
  39048. /**
  39049. * Does lights from the scene impacts this material.
  39050. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  39051. */
  39052. disableLighting: boolean;
  39053. private _useObjectSpaceNormalMap;
  39054. /**
  39055. * Allows using an object space normal map (instead of tangent space).
  39056. */
  39057. useObjectSpaceNormalMap: boolean;
  39058. private _useParallax;
  39059. /**
  39060. * Is parallax enabled or not.
  39061. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  39062. */
  39063. useParallax: boolean;
  39064. private _useParallaxOcclusion;
  39065. /**
  39066. * Is parallax occlusion enabled or not.
  39067. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  39068. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  39069. */
  39070. useParallaxOcclusion: boolean;
  39071. /**
  39072. * 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.
  39073. */
  39074. parallaxScaleBias: number;
  39075. private _roughness;
  39076. /**
  39077. * Helps to define how blurry the reflections should appears in the material.
  39078. */
  39079. roughness: number;
  39080. /**
  39081. * In case of refraction, define the value of the indice of refraction.
  39082. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39083. */
  39084. indexOfRefraction: number;
  39085. /**
  39086. * Invert the refraction texture alongside the y axis.
  39087. * It can be useful with procedural textures or probe for instance.
  39088. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39089. */
  39090. invertRefractionY: boolean;
  39091. /**
  39092. * Defines the alpha limits in alpha test mode.
  39093. */
  39094. alphaCutOff: number;
  39095. private _useLightmapAsShadowmap;
  39096. /**
  39097. * In case of light mapping, define whether the map contains light or shadow informations.
  39098. */
  39099. useLightmapAsShadowmap: boolean;
  39100. private _diffuseFresnelParameters;
  39101. /**
  39102. * Define the diffuse fresnel parameters of the material.
  39103. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39104. */
  39105. diffuseFresnelParameters: FresnelParameters;
  39106. private _opacityFresnelParameters;
  39107. /**
  39108. * Define the opacity fresnel parameters of the material.
  39109. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39110. */
  39111. opacityFresnelParameters: FresnelParameters;
  39112. private _reflectionFresnelParameters;
  39113. /**
  39114. * Define the reflection fresnel parameters of the material.
  39115. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39116. */
  39117. reflectionFresnelParameters: FresnelParameters;
  39118. private _refractionFresnelParameters;
  39119. /**
  39120. * Define the refraction fresnel parameters of the material.
  39121. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39122. */
  39123. refractionFresnelParameters: FresnelParameters;
  39124. private _emissiveFresnelParameters;
  39125. /**
  39126. * Define the emissive fresnel parameters of the material.
  39127. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39128. */
  39129. emissiveFresnelParameters: FresnelParameters;
  39130. private _useReflectionFresnelFromSpecular;
  39131. /**
  39132. * If true automatically deducts the fresnels values from the material specularity.
  39133. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39134. */
  39135. useReflectionFresnelFromSpecular: boolean;
  39136. private _useGlossinessFromSpecularMapAlpha;
  39137. /**
  39138. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  39139. */
  39140. useGlossinessFromSpecularMapAlpha: boolean;
  39141. private _maxSimultaneousLights;
  39142. /**
  39143. * Defines the maximum number of lights that can be used in the material
  39144. */
  39145. maxSimultaneousLights: number;
  39146. private _invertNormalMapX;
  39147. /**
  39148. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  39149. */
  39150. invertNormalMapX: boolean;
  39151. private _invertNormalMapY;
  39152. /**
  39153. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  39154. */
  39155. invertNormalMapY: boolean;
  39156. private _twoSidedLighting;
  39157. /**
  39158. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  39159. */
  39160. twoSidedLighting: boolean;
  39161. /**
  39162. * Default configuration related to image processing available in the standard Material.
  39163. */
  39164. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39165. /**
  39166. * Gets the image processing configuration used either in this material.
  39167. */
  39168. /**
  39169. * Sets the Default image processing configuration used either in the this material.
  39170. *
  39171. * If sets to null, the scene one is in use.
  39172. */
  39173. imageProcessingConfiguration: ImageProcessingConfiguration;
  39174. /**
  39175. * Keep track of the image processing observer to allow dispose and replace.
  39176. */
  39177. private _imageProcessingObserver;
  39178. /**
  39179. * Attaches a new image processing configuration to the Standard Material.
  39180. * @param configuration
  39181. */
  39182. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  39183. /**
  39184. * Gets wether the color curves effect is enabled.
  39185. */
  39186. /**
  39187. * Sets wether the color curves effect is enabled.
  39188. */
  39189. cameraColorCurvesEnabled: boolean;
  39190. /**
  39191. * Gets wether the color grading effect is enabled.
  39192. */
  39193. /**
  39194. * Gets wether the color grading effect is enabled.
  39195. */
  39196. cameraColorGradingEnabled: boolean;
  39197. /**
  39198. * Gets wether tonemapping is enabled or not.
  39199. */
  39200. /**
  39201. * Sets wether tonemapping is enabled or not
  39202. */
  39203. cameraToneMappingEnabled: boolean;
  39204. /**
  39205. * The camera exposure used on this material.
  39206. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  39207. * This corresponds to a photographic exposure.
  39208. */
  39209. /**
  39210. * The camera exposure used on this material.
  39211. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  39212. * This corresponds to a photographic exposure.
  39213. */
  39214. cameraExposure: number;
  39215. /**
  39216. * Gets The camera contrast used on this material.
  39217. */
  39218. /**
  39219. * Sets The camera contrast used on this material.
  39220. */
  39221. cameraContrast: number;
  39222. /**
  39223. * Gets the Color Grading 2D Lookup Texture.
  39224. */
  39225. /**
  39226. * Sets the Color Grading 2D Lookup Texture.
  39227. */
  39228. cameraColorGradingTexture: Nullable<BaseTexture>;
  39229. /**
  39230. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  39231. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  39232. * 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;
  39233. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  39234. */
  39235. /**
  39236. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  39237. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  39238. * 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;
  39239. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  39240. */
  39241. cameraColorCurves: Nullable<ColorCurves>;
  39242. /**
  39243. * Custom callback helping to override the default shader used in the material.
  39244. */
  39245. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  39246. protected _renderTargets: SmartArray<RenderTargetTexture>;
  39247. protected _worldViewProjectionMatrix: Matrix;
  39248. protected _globalAmbientColor: Color3;
  39249. protected _useLogarithmicDepth: boolean;
  39250. /**
  39251. * Instantiates a new standard material.
  39252. * This is the default material used in Babylon. It is the best trade off between quality
  39253. * and performances.
  39254. * @see http://doc.babylonjs.com/babylon101/materials
  39255. * @param name Define the name of the material in the scene
  39256. * @param scene Define the scene the material belong to
  39257. */
  39258. constructor(name: string, scene: Scene);
  39259. /**
  39260. * Gets a boolean indicating that current material needs to register RTT
  39261. */
  39262. readonly hasRenderTargetTextures: boolean;
  39263. /**
  39264. * Gets the current class name of the material e.g. "StandardMaterial"
  39265. * Mainly use in serialization.
  39266. * @returns the class name
  39267. */
  39268. getClassName(): string;
  39269. /**
  39270. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  39271. * You can try switching to logarithmic depth.
  39272. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  39273. */
  39274. useLogarithmicDepth: boolean;
  39275. /**
  39276. * Specifies if the material will require alpha blending
  39277. * @returns a boolean specifying if alpha blending is needed
  39278. */
  39279. needAlphaBlending(): boolean;
  39280. /**
  39281. * Specifies if this material should be rendered in alpha test mode
  39282. * @returns a boolean specifying if an alpha test is needed.
  39283. */
  39284. needAlphaTesting(): boolean;
  39285. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  39286. /**
  39287. * Get the texture used for alpha test purpose.
  39288. * @returns the diffuse texture in case of the standard material.
  39289. */
  39290. getAlphaTestTexture(): Nullable<BaseTexture>;
  39291. /**
  39292. * Get if the submesh is ready to be used and all its information available.
  39293. * Child classes can use it to update shaders
  39294. * @param mesh defines the mesh to check
  39295. * @param subMesh defines which submesh to check
  39296. * @param useInstances specifies that instances should be used
  39297. * @returns a boolean indicating that the submesh is ready or not
  39298. */
  39299. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  39300. /**
  39301. * Builds the material UBO layouts.
  39302. * Used internally during the effect preparation.
  39303. */
  39304. buildUniformLayout(): void;
  39305. /**
  39306. * Unbinds the material from the mesh
  39307. */
  39308. unbind(): void;
  39309. /**
  39310. * Binds the submesh to this material by preparing the effect and shader to draw
  39311. * @param world defines the world transformation matrix
  39312. * @param mesh defines the mesh containing the submesh
  39313. * @param subMesh defines the submesh to bind the material to
  39314. */
  39315. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  39316. /**
  39317. * Get the list of animatables in the material.
  39318. * @returns the list of animatables object used in the material
  39319. */
  39320. getAnimatables(): IAnimatable[];
  39321. /**
  39322. * Gets the active textures from the material
  39323. * @returns an array of textures
  39324. */
  39325. getActiveTextures(): BaseTexture[];
  39326. /**
  39327. * Specifies if the material uses a texture
  39328. * @param texture defines the texture to check against the material
  39329. * @returns a boolean specifying if the material uses the texture
  39330. */
  39331. hasTexture(texture: BaseTexture): boolean;
  39332. /**
  39333. * Disposes the material
  39334. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  39335. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  39336. */
  39337. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  39338. /**
  39339. * Makes a duplicate of the material, and gives it a new name
  39340. * @param name defines the new name for the duplicated material
  39341. * @returns the cloned material
  39342. */
  39343. clone(name: string): StandardMaterial;
  39344. /**
  39345. * Serializes this material in a JSON representation
  39346. * @returns the serialized material object
  39347. */
  39348. serialize(): any;
  39349. /**
  39350. * Creates a standard material from parsed material data
  39351. * @param source defines the JSON representation of the material
  39352. * @param scene defines the hosting scene
  39353. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  39354. * @returns a new standard material
  39355. */
  39356. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  39357. /**
  39358. * Are diffuse textures enabled in the application.
  39359. */
  39360. static DiffuseTextureEnabled: boolean;
  39361. /**
  39362. * Are ambient textures enabled in the application.
  39363. */
  39364. static AmbientTextureEnabled: boolean;
  39365. /**
  39366. * Are opacity textures enabled in the application.
  39367. */
  39368. static OpacityTextureEnabled: boolean;
  39369. /**
  39370. * Are reflection textures enabled in the application.
  39371. */
  39372. static ReflectionTextureEnabled: boolean;
  39373. /**
  39374. * Are emissive textures enabled in the application.
  39375. */
  39376. static EmissiveTextureEnabled: boolean;
  39377. /**
  39378. * Are specular textures enabled in the application.
  39379. */
  39380. static SpecularTextureEnabled: boolean;
  39381. /**
  39382. * Are bump textures enabled in the application.
  39383. */
  39384. static BumpTextureEnabled: boolean;
  39385. /**
  39386. * Are lightmap textures enabled in the application.
  39387. */
  39388. static LightmapTextureEnabled: boolean;
  39389. /**
  39390. * Are refraction textures enabled in the application.
  39391. */
  39392. static RefractionTextureEnabled: boolean;
  39393. /**
  39394. * Are color grading textures enabled in the application.
  39395. */
  39396. static ColorGradingTextureEnabled: boolean;
  39397. /**
  39398. * Are fresnels enabled in the application.
  39399. */
  39400. static FresnelEnabled: boolean;
  39401. }
  39402. }
  39403. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  39404. import { Scene } from "babylonjs/scene";
  39405. import { Texture } from "babylonjs/Materials/Textures/texture";
  39406. /**
  39407. * A class extending Texture allowing drawing on a texture
  39408. * @see http://doc.babylonjs.com/how_to/dynamictexture
  39409. */
  39410. export class DynamicTexture extends Texture {
  39411. private _generateMipMaps;
  39412. private _canvas;
  39413. private _context;
  39414. private _engine;
  39415. /**
  39416. * Creates a DynamicTexture
  39417. * @param name defines the name of the texture
  39418. * @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
  39419. * @param scene defines the scene where you want the texture
  39420. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  39421. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  39422. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  39423. */
  39424. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  39425. /**
  39426. * Get the current class name of the texture useful for serialization or dynamic coding.
  39427. * @returns "DynamicTexture"
  39428. */
  39429. getClassName(): string;
  39430. /**
  39431. * Gets the current state of canRescale
  39432. */
  39433. readonly canRescale: boolean;
  39434. private _recreate;
  39435. /**
  39436. * Scales the texture
  39437. * @param ratio the scale factor to apply to both width and height
  39438. */
  39439. scale(ratio: number): void;
  39440. /**
  39441. * Resizes the texture
  39442. * @param width the new width
  39443. * @param height the new height
  39444. */
  39445. scaleTo(width: number, height: number): void;
  39446. /**
  39447. * Gets the context of the canvas used by the texture
  39448. * @returns the canvas context of the dynamic texture
  39449. */
  39450. getContext(): CanvasRenderingContext2D;
  39451. /**
  39452. * Clears the texture
  39453. */
  39454. clear(): void;
  39455. /**
  39456. * Updates the texture
  39457. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  39458. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  39459. */
  39460. update(invertY?: boolean, premulAlpha?: boolean): void;
  39461. /**
  39462. * Draws text onto the texture
  39463. * @param text defines the text to be drawn
  39464. * @param x defines the placement of the text from the left
  39465. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  39466. * @param font defines the font to be used with font-style, font-size, font-name
  39467. * @param color defines the color used for the text
  39468. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  39469. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  39470. * @param update defines whether texture is immediately update (default is true)
  39471. */
  39472. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  39473. /**
  39474. * Clones the texture
  39475. * @returns the clone of the texture.
  39476. */
  39477. clone(): DynamicTexture;
  39478. /**
  39479. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  39480. * @returns a serialized dynamic texture object
  39481. */
  39482. serialize(): any;
  39483. /** @hidden */
  39484. _rebuild(): void;
  39485. }
  39486. }
  39487. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  39488. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  39489. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  39490. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  39491. /** @hidden */
  39492. export var imageProcessingPixelShader: {
  39493. name: string;
  39494. shader: string;
  39495. };
  39496. }
  39497. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  39498. import { Nullable } from "babylonjs/types";
  39499. import { Color4 } from "babylonjs/Maths/math";
  39500. import { Camera } from "babylonjs/Cameras/camera";
  39501. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  39502. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  39503. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  39504. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  39505. import { Engine } from "babylonjs/Engines/engine";
  39506. import "babylonjs/Shaders/imageProcessing.fragment";
  39507. import "babylonjs/Shaders/postprocess.vertex";
  39508. /**
  39509. * ImageProcessingPostProcess
  39510. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  39511. */
  39512. export class ImageProcessingPostProcess extends PostProcess {
  39513. /**
  39514. * Default configuration related to image processing available in the PBR Material.
  39515. */
  39516. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39517. /**
  39518. * Gets the image processing configuration used either in this material.
  39519. */
  39520. /**
  39521. * Sets the Default image processing configuration used either in the this material.
  39522. *
  39523. * If sets to null, the scene one is in use.
  39524. */
  39525. imageProcessingConfiguration: ImageProcessingConfiguration;
  39526. /**
  39527. * Keep track of the image processing observer to allow dispose and replace.
  39528. */
  39529. private _imageProcessingObserver;
  39530. /**
  39531. * Attaches a new image processing configuration to the PBR Material.
  39532. * @param configuration
  39533. */
  39534. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  39535. /**
  39536. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  39537. */
  39538. /**
  39539. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  39540. */
  39541. colorCurves: Nullable<ColorCurves>;
  39542. /**
  39543. * Gets wether the color curves effect is enabled.
  39544. */
  39545. /**
  39546. * Sets wether the color curves effect is enabled.
  39547. */
  39548. colorCurvesEnabled: boolean;
  39549. /**
  39550. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  39551. */
  39552. /**
  39553. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  39554. */
  39555. colorGradingTexture: Nullable<BaseTexture>;
  39556. /**
  39557. * Gets wether the color grading effect is enabled.
  39558. */
  39559. /**
  39560. * Gets wether the color grading effect is enabled.
  39561. */
  39562. colorGradingEnabled: boolean;
  39563. /**
  39564. * Gets exposure used in the effect.
  39565. */
  39566. /**
  39567. * Sets exposure used in the effect.
  39568. */
  39569. exposure: number;
  39570. /**
  39571. * Gets wether tonemapping is enabled or not.
  39572. */
  39573. /**
  39574. * Sets wether tonemapping is enabled or not
  39575. */
  39576. toneMappingEnabled: boolean;
  39577. /**
  39578. * Gets the type of tone mapping effect.
  39579. */
  39580. /**
  39581. * Sets the type of tone mapping effect.
  39582. */
  39583. toneMappingType: number;
  39584. /**
  39585. * Gets contrast used in the effect.
  39586. */
  39587. /**
  39588. * Sets contrast used in the effect.
  39589. */
  39590. contrast: number;
  39591. /**
  39592. * Gets Vignette stretch size.
  39593. */
  39594. /**
  39595. * Sets Vignette stretch size.
  39596. */
  39597. vignetteStretch: number;
  39598. /**
  39599. * Gets Vignette centre X Offset.
  39600. */
  39601. /**
  39602. * Sets Vignette centre X Offset.
  39603. */
  39604. vignetteCentreX: number;
  39605. /**
  39606. * Gets Vignette centre Y Offset.
  39607. */
  39608. /**
  39609. * Sets Vignette centre Y Offset.
  39610. */
  39611. vignetteCentreY: number;
  39612. /**
  39613. * Gets Vignette weight or intensity of the vignette effect.
  39614. */
  39615. /**
  39616. * Sets Vignette weight or intensity of the vignette effect.
  39617. */
  39618. vignetteWeight: number;
  39619. /**
  39620. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  39621. * if vignetteEnabled is set to true.
  39622. */
  39623. /**
  39624. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  39625. * if vignetteEnabled is set to true.
  39626. */
  39627. vignetteColor: Color4;
  39628. /**
  39629. * Gets Camera field of view used by the Vignette effect.
  39630. */
  39631. /**
  39632. * Sets Camera field of view used by the Vignette effect.
  39633. */
  39634. vignetteCameraFov: number;
  39635. /**
  39636. * Gets the vignette blend mode allowing different kind of effect.
  39637. */
  39638. /**
  39639. * Sets the vignette blend mode allowing different kind of effect.
  39640. */
  39641. vignetteBlendMode: number;
  39642. /**
  39643. * Gets wether the vignette effect is enabled.
  39644. */
  39645. /**
  39646. * Sets wether the vignette effect is enabled.
  39647. */
  39648. vignetteEnabled: boolean;
  39649. private _fromLinearSpace;
  39650. /**
  39651. * Gets wether the input of the processing is in Gamma or Linear Space.
  39652. */
  39653. /**
  39654. * Sets wether the input of the processing is in Gamma or Linear Space.
  39655. */
  39656. fromLinearSpace: boolean;
  39657. /**
  39658. * Defines cache preventing GC.
  39659. */
  39660. private _defines;
  39661. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  39662. /**
  39663. * "ImageProcessingPostProcess"
  39664. * @returns "ImageProcessingPostProcess"
  39665. */
  39666. getClassName(): string;
  39667. protected _updateParameters(): void;
  39668. dispose(camera?: Camera): void;
  39669. }
  39670. }
  39671. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  39672. import { Scene } from "babylonjs/scene";
  39673. import { Color3 } from "babylonjs/Maths/math";
  39674. import { Mesh } from "babylonjs/Meshes/mesh";
  39675. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  39676. /**
  39677. * Class containing static functions to help procedurally build meshes
  39678. */
  39679. export class GroundBuilder {
  39680. /**
  39681. * Creates a ground mesh
  39682. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  39683. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  39684. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  39685. * @param name defines the name of the mesh
  39686. * @param options defines the options used to create the mesh
  39687. * @param scene defines the hosting scene
  39688. * @returns the ground mesh
  39689. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  39690. */
  39691. static CreateGround(name: string, options: {
  39692. width?: number;
  39693. height?: number;
  39694. subdivisions?: number;
  39695. subdivisionsX?: number;
  39696. subdivisionsY?: number;
  39697. updatable?: boolean;
  39698. }, scene: any): Mesh;
  39699. /**
  39700. * Creates a tiled ground mesh
  39701. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  39702. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  39703. * * 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
  39704. * * 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
  39705. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39706. * @param name defines the name of the mesh
  39707. * @param options defines the options used to create the mesh
  39708. * @param scene defines the hosting scene
  39709. * @returns the tiled ground mesh
  39710. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  39711. */
  39712. static CreateTiledGround(name: string, options: {
  39713. xmin: number;
  39714. zmin: number;
  39715. xmax: number;
  39716. zmax: number;
  39717. subdivisions?: {
  39718. w: number;
  39719. h: number;
  39720. };
  39721. precision?: {
  39722. w: number;
  39723. h: number;
  39724. };
  39725. updatable?: boolean;
  39726. }, scene: Scene): Mesh;
  39727. /**
  39728. * Creates a ground mesh from a height map
  39729. * * The parameter `url` sets the URL of the height map image resource.
  39730. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  39731. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  39732. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  39733. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  39734. * * 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.
  39735. * * 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).
  39736. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  39737. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39738. * @param name defines the name of the mesh
  39739. * @param url defines the url to the height map
  39740. * @param options defines the options used to create the mesh
  39741. * @param scene defines the hosting scene
  39742. * @returns the ground mesh
  39743. * @see https://doc.babylonjs.com/babylon101/height_map
  39744. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  39745. */
  39746. static CreateGroundFromHeightMap(name: string, url: string, options: {
  39747. width?: number;
  39748. height?: number;
  39749. subdivisions?: number;
  39750. minHeight?: number;
  39751. maxHeight?: number;
  39752. colorFilter?: Color3;
  39753. alphaFilter?: number;
  39754. updatable?: boolean;
  39755. onReady?: (mesh: GroundMesh) => void;
  39756. }, scene: Scene): GroundMesh;
  39757. }
  39758. }
  39759. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  39760. import { Vector4 } from "babylonjs/Maths/math";
  39761. import { Mesh } from "babylonjs/Meshes/mesh";
  39762. /**
  39763. * Class containing static functions to help procedurally build meshes
  39764. */
  39765. export class TorusBuilder {
  39766. /**
  39767. * Creates a torus mesh
  39768. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  39769. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  39770. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  39771. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  39772. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  39773. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39774. * @param name defines the name of the mesh
  39775. * @param options defines the options used to create the mesh
  39776. * @param scene defines the hosting scene
  39777. * @returns the torus mesh
  39778. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  39779. */
  39780. static CreateTorus(name: string, options: {
  39781. diameter?: number;
  39782. thickness?: number;
  39783. tessellation?: number;
  39784. updatable?: boolean;
  39785. sideOrientation?: number;
  39786. frontUVs?: Vector4;
  39787. backUVs?: Vector4;
  39788. }, scene: any): Mesh;
  39789. }
  39790. }
  39791. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  39792. import { Color4, Vector4 } from "babylonjs/Maths/math";
  39793. import { Mesh } from "babylonjs/Meshes/mesh";
  39794. /**
  39795. * Class containing static functions to help procedurally build meshes
  39796. */
  39797. export class CylinderBuilder {
  39798. /**
  39799. * Creates a cylinder or a cone mesh
  39800. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  39801. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  39802. * * 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.
  39803. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  39804. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  39805. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  39806. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  39807. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  39808. * * 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).
  39809. * * 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
  39810. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  39811. * * 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
  39812. * * 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.
  39813. * * If `enclose` is false, a ring surface is one element.
  39814. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  39815. * * 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
  39816. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  39817. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  39818. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39819. * @param name defines the name of the mesh
  39820. * @param options defines the options used to create the mesh
  39821. * @param scene defines the hosting scene
  39822. * @returns the cylinder mesh
  39823. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  39824. */
  39825. static CreateCylinder(name: string, options: {
  39826. height?: number;
  39827. diameterTop?: number;
  39828. diameterBottom?: number;
  39829. diameter?: number;
  39830. tessellation?: number;
  39831. subdivisions?: number;
  39832. arc?: number;
  39833. faceColors?: Color4[];
  39834. faceUV?: Vector4[];
  39835. updatable?: boolean;
  39836. hasRings?: boolean;
  39837. enclose?: boolean;
  39838. sideOrientation?: number;
  39839. frontUVs?: Vector4;
  39840. backUVs?: Vector4;
  39841. }, scene: any): Mesh;
  39842. }
  39843. }
  39844. declare module "babylonjs/Gamepads/gamepadManager" {
  39845. import { Observable } from "babylonjs/Misc/observable";
  39846. import { Nullable } from "babylonjs/types";
  39847. import { Scene } from "babylonjs/scene";
  39848. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39849. /**
  39850. * Manager for handling gamepads
  39851. */
  39852. export class GamepadManager {
  39853. private _scene?;
  39854. private _babylonGamepads;
  39855. private _oneGamepadConnected;
  39856. /** @hidden */
  39857. _isMonitoring: boolean;
  39858. private _gamepadEventSupported;
  39859. private _gamepadSupport;
  39860. /**
  39861. * observable to be triggered when the gamepad controller has been connected
  39862. */
  39863. onGamepadConnectedObservable: Observable<Gamepad>;
  39864. /**
  39865. * observable to be triggered when the gamepad controller has been disconnected
  39866. */
  39867. onGamepadDisconnectedObservable: Observable<Gamepad>;
  39868. private _onGamepadConnectedEvent;
  39869. private _onGamepadDisconnectedEvent;
  39870. /**
  39871. * Initializes the gamepad manager
  39872. * @param _scene BabylonJS scene
  39873. */
  39874. constructor(_scene?: Scene | undefined);
  39875. /**
  39876. * The gamepads in the game pad manager
  39877. */
  39878. readonly gamepads: Gamepad[];
  39879. /**
  39880. * Get the gamepad controllers based on type
  39881. * @param type The type of gamepad controller
  39882. * @returns Nullable gamepad
  39883. */
  39884. getGamepadByType(type?: number): Nullable<Gamepad>;
  39885. /**
  39886. * Disposes the gamepad manager
  39887. */
  39888. dispose(): void;
  39889. private _addNewGamepad;
  39890. private _startMonitoringGamepads;
  39891. private _stopMonitoringGamepads;
  39892. /** @hidden */
  39893. _checkGamepadsStatus(): void;
  39894. private _updateGamepadObjects;
  39895. }
  39896. }
  39897. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  39898. import { Nullable } from "babylonjs/types";
  39899. import { Scene } from "babylonjs/scene";
  39900. import { ISceneComponent } from "babylonjs/sceneComponent";
  39901. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  39902. module "babylonjs/scene" {
  39903. interface Scene {
  39904. /** @hidden */
  39905. _gamepadManager: Nullable<GamepadManager>;
  39906. /**
  39907. * Gets the gamepad manager associated with the scene
  39908. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  39909. */
  39910. gamepadManager: GamepadManager;
  39911. }
  39912. }
  39913. module "babylonjs/Cameras/freeCameraInputsManager" {
  39914. /**
  39915. * Interface representing a free camera inputs manager
  39916. */
  39917. interface FreeCameraInputsManager {
  39918. /**
  39919. * Adds gamepad input support to the FreeCameraInputsManager.
  39920. * @returns the FreeCameraInputsManager
  39921. */
  39922. addGamepad(): FreeCameraInputsManager;
  39923. }
  39924. }
  39925. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  39926. /**
  39927. * Interface representing an arc rotate camera inputs manager
  39928. */
  39929. interface ArcRotateCameraInputsManager {
  39930. /**
  39931. * Adds gamepad input support to the ArcRotateCamera InputManager.
  39932. * @returns the camera inputs manager
  39933. */
  39934. addGamepad(): ArcRotateCameraInputsManager;
  39935. }
  39936. }
  39937. /**
  39938. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  39939. */
  39940. export class GamepadSystemSceneComponent implements ISceneComponent {
  39941. /**
  39942. * The component name helpfull to identify the component in the list of scene components.
  39943. */
  39944. readonly name: string;
  39945. /**
  39946. * The scene the component belongs to.
  39947. */
  39948. scene: Scene;
  39949. /**
  39950. * Creates a new instance of the component for the given scene
  39951. * @param scene Defines the scene to register the component in
  39952. */
  39953. constructor(scene: Scene);
  39954. /**
  39955. * Registers the component in a given scene
  39956. */
  39957. register(): void;
  39958. /**
  39959. * Rebuilds the elements related to this component in case of
  39960. * context lost for instance.
  39961. */
  39962. rebuild(): void;
  39963. /**
  39964. * Disposes the component and the associated ressources
  39965. */
  39966. dispose(): void;
  39967. private _beforeCameraUpdate;
  39968. }
  39969. }
  39970. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  39971. import { Observable } from "babylonjs/Misc/observable";
  39972. import { Nullable } from "babylonjs/types";
  39973. import { Camera } from "babylonjs/Cameras/camera";
  39974. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  39975. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  39976. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  39977. import { Scene } from "babylonjs/scene";
  39978. import { Vector3, Color3 } from "babylonjs/Maths/math";
  39979. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  39980. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39981. import { Mesh } from "babylonjs/Meshes/mesh";
  39982. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  39983. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  39984. import "babylonjs/Meshes/Builders/groundBuilder";
  39985. import "babylonjs/Meshes/Builders/torusBuilder";
  39986. import "babylonjs/Meshes/Builders/cylinderBuilder";
  39987. import "babylonjs/Gamepads/gamepadSceneComponent";
  39988. import "babylonjs/Animations/animatable";
  39989. /**
  39990. * Options to modify the vr teleportation behavior.
  39991. */
  39992. export interface VRTeleportationOptions {
  39993. /**
  39994. * The name of the mesh which should be used as the teleportation floor. (default: null)
  39995. */
  39996. floorMeshName?: string;
  39997. /**
  39998. * A list of meshes to be used as the teleportation floor. (default: empty)
  39999. */
  40000. floorMeshes?: Mesh[];
  40001. }
  40002. /**
  40003. * Options to modify the vr experience helper's behavior.
  40004. */
  40005. export interface VRExperienceHelperOptions extends WebVROptions {
  40006. /**
  40007. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  40008. */
  40009. createDeviceOrientationCamera?: boolean;
  40010. /**
  40011. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  40012. */
  40013. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  40014. /**
  40015. * Uses the main button on the controller to toggle the laser casted. (default: true)
  40016. */
  40017. laserToggle?: boolean;
  40018. /**
  40019. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  40020. */
  40021. floorMeshes?: Mesh[];
  40022. /**
  40023. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  40024. */
  40025. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  40026. }
  40027. /**
  40028. * Event containing information after VR has been entered
  40029. */
  40030. export class OnAfterEnteringVRObservableEvent {
  40031. /**
  40032. * If entering vr was successful
  40033. */
  40034. success: boolean;
  40035. }
  40036. /**
  40037. * Helps to quickly add VR support to an existing scene.
  40038. * See http://doc.babylonjs.com/how_to/webvr_helper
  40039. */
  40040. export class VRExperienceHelper {
  40041. /** Options to modify the vr experience helper's behavior. */
  40042. webVROptions: VRExperienceHelperOptions;
  40043. private _scene;
  40044. private _position;
  40045. private _btnVR;
  40046. private _btnVRDisplayed;
  40047. private _webVRsupported;
  40048. private _webVRready;
  40049. private _webVRrequesting;
  40050. private _webVRpresenting;
  40051. private _hasEnteredVR;
  40052. private _fullscreenVRpresenting;
  40053. private _canvas;
  40054. private _webVRCamera;
  40055. private _vrDeviceOrientationCamera;
  40056. private _deviceOrientationCamera;
  40057. private _existingCamera;
  40058. private _onKeyDown;
  40059. private _onVrDisplayPresentChange;
  40060. private _onVRDisplayChanged;
  40061. private _onVRRequestPresentStart;
  40062. private _onVRRequestPresentComplete;
  40063. /**
  40064. * Observable raised right before entering VR.
  40065. */
  40066. onEnteringVRObservable: Observable<VRExperienceHelper>;
  40067. /**
  40068. * Observable raised when entering VR has completed.
  40069. */
  40070. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  40071. /**
  40072. * Observable raised when exiting VR.
  40073. */
  40074. onExitingVRObservable: Observable<VRExperienceHelper>;
  40075. /**
  40076. * Observable raised when controller mesh is loaded.
  40077. */
  40078. onControllerMeshLoadedObservable: Observable<WebVRController>;
  40079. /** Return this.onEnteringVRObservable
  40080. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  40081. */
  40082. readonly onEnteringVR: Observable<VRExperienceHelper>;
  40083. /** Return this.onExitingVRObservable
  40084. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  40085. */
  40086. readonly onExitingVR: Observable<VRExperienceHelper>;
  40087. /** Return this.onControllerMeshLoadedObservable
  40088. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  40089. */
  40090. readonly onControllerMeshLoaded: Observable<WebVRController>;
  40091. private _rayLength;
  40092. private _useCustomVRButton;
  40093. private _teleportationRequested;
  40094. private _teleportActive;
  40095. private _floorMeshName;
  40096. private _floorMeshesCollection;
  40097. private _rotationAllowed;
  40098. private _teleportBackwardsVector;
  40099. private _teleportationTarget;
  40100. private _isDefaultTeleportationTarget;
  40101. private _postProcessMove;
  40102. private _teleportationFillColor;
  40103. private _teleportationBorderColor;
  40104. private _rotationAngle;
  40105. private _haloCenter;
  40106. private _cameraGazer;
  40107. private _padSensibilityUp;
  40108. private _padSensibilityDown;
  40109. private _leftController;
  40110. private _rightController;
  40111. /**
  40112. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  40113. */
  40114. onNewMeshSelected: Observable<AbstractMesh>;
  40115. /**
  40116. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  40117. */
  40118. onNewMeshPicked: Observable<PickingInfo>;
  40119. private _circleEase;
  40120. /**
  40121. * Observable raised before camera teleportation
  40122. */
  40123. onBeforeCameraTeleport: Observable<Vector3>;
  40124. /**
  40125. * Observable raised after camera teleportation
  40126. */
  40127. onAfterCameraTeleport: Observable<Vector3>;
  40128. /**
  40129. * Observable raised when current selected mesh gets unselected
  40130. */
  40131. onSelectedMeshUnselected: Observable<AbstractMesh>;
  40132. private _raySelectionPredicate;
  40133. /**
  40134. * To be optionaly changed by user to define custom ray selection
  40135. */
  40136. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  40137. /**
  40138. * To be optionaly changed by user to define custom selection logic (after ray selection)
  40139. */
  40140. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  40141. /**
  40142. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  40143. */
  40144. teleportationEnabled: boolean;
  40145. private _defaultHeight;
  40146. private _teleportationInitialized;
  40147. private _interactionsEnabled;
  40148. private _interactionsRequested;
  40149. private _displayGaze;
  40150. private _displayLaserPointer;
  40151. /**
  40152. * The mesh used to display where the user is going to teleport.
  40153. */
  40154. /**
  40155. * Sets the mesh to be used to display where the user is going to teleport.
  40156. */
  40157. teleportationTarget: Mesh;
  40158. /**
  40159. * 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
  40160. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  40161. * See http://doc.babylonjs.com/resources/baking_transformations
  40162. */
  40163. gazeTrackerMesh: Mesh;
  40164. /**
  40165. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  40166. */
  40167. updateGazeTrackerScale: boolean;
  40168. /**
  40169. * If the gaze trackers color should be updated when selecting meshes
  40170. */
  40171. updateGazeTrackerColor: boolean;
  40172. /**
  40173. * The gaze tracking mesh corresponding to the left controller
  40174. */
  40175. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  40176. /**
  40177. * The gaze tracking mesh corresponding to the right controller
  40178. */
  40179. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  40180. /**
  40181. * If the ray of the gaze should be displayed.
  40182. */
  40183. /**
  40184. * Sets if the ray of the gaze should be displayed.
  40185. */
  40186. displayGaze: boolean;
  40187. /**
  40188. * If the ray of the LaserPointer should be displayed.
  40189. */
  40190. /**
  40191. * Sets if the ray of the LaserPointer should be displayed.
  40192. */
  40193. displayLaserPointer: boolean;
  40194. /**
  40195. * The deviceOrientationCamera used as the camera when not in VR.
  40196. */
  40197. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  40198. /**
  40199. * Based on the current WebVR support, returns the current VR camera used.
  40200. */
  40201. readonly currentVRCamera: Nullable<Camera>;
  40202. /**
  40203. * The webVRCamera which is used when in VR.
  40204. */
  40205. readonly webVRCamera: WebVRFreeCamera;
  40206. /**
  40207. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  40208. */
  40209. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  40210. private readonly _teleportationRequestInitiated;
  40211. /**
  40212. * Defines wether or not Pointer lock should be requested when switching to
  40213. * full screen.
  40214. */
  40215. requestPointerLockOnFullScreen: boolean;
  40216. /**
  40217. * Instantiates a VRExperienceHelper.
  40218. * Helps to quickly add VR support to an existing scene.
  40219. * @param scene The scene the VRExperienceHelper belongs to.
  40220. * @param webVROptions Options to modify the vr experience helper's behavior.
  40221. */
  40222. constructor(scene: Scene,
  40223. /** Options to modify the vr experience helper's behavior. */
  40224. webVROptions?: VRExperienceHelperOptions);
  40225. private _onDefaultMeshLoaded;
  40226. private _onResize;
  40227. private _onFullscreenChange;
  40228. /**
  40229. * Gets a value indicating if we are currently in VR mode.
  40230. */
  40231. readonly isInVRMode: boolean;
  40232. private onVrDisplayPresentChange;
  40233. private onVRDisplayChanged;
  40234. private moveButtonToBottomRight;
  40235. private displayVRButton;
  40236. private updateButtonVisibility;
  40237. private _cachedAngularSensibility;
  40238. /**
  40239. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  40240. * Otherwise, will use the fullscreen API.
  40241. */
  40242. enterVR(): void;
  40243. /**
  40244. * Attempt to exit VR, or fullscreen.
  40245. */
  40246. exitVR(): void;
  40247. /**
  40248. * The position of the vr experience helper.
  40249. */
  40250. /**
  40251. * Sets the position of the vr experience helper.
  40252. */
  40253. position: Vector3;
  40254. /**
  40255. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  40256. */
  40257. enableInteractions(): void;
  40258. private readonly _noControllerIsActive;
  40259. private beforeRender;
  40260. private _isTeleportationFloor;
  40261. /**
  40262. * Adds a floor mesh to be used for teleportation.
  40263. * @param floorMesh the mesh to be used for teleportation.
  40264. */
  40265. addFloorMesh(floorMesh: Mesh): void;
  40266. /**
  40267. * Removes a floor mesh from being used for teleportation.
  40268. * @param floorMesh the mesh to be removed.
  40269. */
  40270. removeFloorMesh(floorMesh: Mesh): void;
  40271. /**
  40272. * Enables interactions and teleportation using the VR controllers and gaze.
  40273. * @param vrTeleportationOptions options to modify teleportation behavior.
  40274. */
  40275. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  40276. private _onNewGamepadConnected;
  40277. private _tryEnableInteractionOnController;
  40278. private _onNewGamepadDisconnected;
  40279. private _enableInteractionOnController;
  40280. private _checkTeleportWithRay;
  40281. private _checkRotate;
  40282. private _checkTeleportBackwards;
  40283. private _enableTeleportationOnController;
  40284. private _createTeleportationCircles;
  40285. private _displayTeleportationTarget;
  40286. private _hideTeleportationTarget;
  40287. private _rotateCamera;
  40288. private _moveTeleportationSelectorTo;
  40289. private _workingVector;
  40290. private _workingQuaternion;
  40291. private _workingMatrix;
  40292. /**
  40293. * Teleports the users feet to the desired location
  40294. * @param location The location where the user's feet should be placed
  40295. */
  40296. teleportCamera(location: Vector3): void;
  40297. private _convertNormalToDirectionOfRay;
  40298. private _castRayAndSelectObject;
  40299. private _notifySelectedMeshUnselected;
  40300. /**
  40301. * Sets the color of the laser ray from the vr controllers.
  40302. * @param color new color for the ray.
  40303. */
  40304. changeLaserColor(color: Color3): void;
  40305. /**
  40306. * Sets the color of the ray from the vr headsets gaze.
  40307. * @param color new color for the ray.
  40308. */
  40309. changeGazeColor(color: Color3): void;
  40310. /**
  40311. * Exits VR and disposes of the vr experience helper
  40312. */
  40313. dispose(): void;
  40314. /**
  40315. * Gets the name of the VRExperienceHelper class
  40316. * @returns "VRExperienceHelper"
  40317. */
  40318. getClassName(): string;
  40319. }
  40320. }
  40321. declare module "babylonjs/Cameras/VR/index" {
  40322. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  40323. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  40324. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  40325. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  40326. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  40327. export * from "babylonjs/Cameras/VR/webVRCamera";
  40328. }
  40329. declare module "babylonjs/Cameras/XR/webXRSessionManager" {
  40330. import { Observable } from "babylonjs/Misc/observable";
  40331. import { Nullable } from "babylonjs/types";
  40332. import { IDisposable, Scene } from "babylonjs/scene";
  40333. import { Vector3 } from "babylonjs/Maths/math";
  40334. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  40335. import { Ray } from "babylonjs/Culling/ray";
  40336. /**
  40337. * Manages an XRSession
  40338. * @see https://doc.babylonjs.com/how_to/webxr
  40339. */
  40340. export class WebXRSessionManager implements IDisposable {
  40341. private scene;
  40342. /**
  40343. * Fires every time a new xrFrame arrives which can be used to update the camera
  40344. */
  40345. onXRFrameObservable: Observable<any>;
  40346. /**
  40347. * Fires when the xr session is ended either by the device or manually done
  40348. */
  40349. onXRSessionEnded: Observable<any>;
  40350. /** @hidden */
  40351. _xrSession: XRSession;
  40352. /** @hidden */
  40353. _frameOfReference: XRFrameOfReference;
  40354. /** @hidden */
  40355. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  40356. /** @hidden */
  40357. _currentXRFrame: Nullable<XRFrame>;
  40358. private _xrNavigator;
  40359. private _xrDevice;
  40360. private _tmpMatrix;
  40361. /**
  40362. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  40363. * @param scene The scene which the session should be created for
  40364. */
  40365. constructor(scene: Scene);
  40366. /**
  40367. * Initializes the manager
  40368. * After initialization enterXR can be called to start an XR session
  40369. * @returns Promise which resolves after it is initialized
  40370. */
  40371. initializeAsync(): Promise<void>;
  40372. /**
  40373. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  40374. * @param sessionCreationOptions xr options to create the session with
  40375. * @param frameOfReferenceType option to configure how the xr pose is expressed
  40376. * @returns Promise which resolves after it enters XR
  40377. */
  40378. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  40379. /**
  40380. * Stops the xrSession and restores the renderloop
  40381. * @returns Promise which resolves after it exits XR
  40382. */
  40383. exitXRAsync(): Promise<void>;
  40384. /**
  40385. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  40386. * @param ray ray to cast into the environment
  40387. * @returns Promise which resolves with a collision point in the environment if it exists
  40388. */
  40389. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  40390. /**
  40391. * Checks if a session would be supported for the creation options specified
  40392. * @param options creation options to check if they are supported
  40393. * @returns true if supported
  40394. */
  40395. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  40396. /**
  40397. * @hidden
  40398. * Converts the render layer of xrSession to a render target
  40399. * @param session session to create render target for
  40400. * @param scene scene the new render target should be created for
  40401. */
  40402. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  40403. /**
  40404. * Disposes of the session manager
  40405. */
  40406. dispose(): void;
  40407. }
  40408. }
  40409. declare module "babylonjs/Cameras/XR/webXRCamera" {
  40410. import { Scene } from "babylonjs/scene";
  40411. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40412. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  40413. /**
  40414. * WebXR Camera which holds the views for the xrSession
  40415. * @see https://doc.babylonjs.com/how_to/webxr
  40416. */
  40417. export class WebXRCamera extends FreeCamera {
  40418. private static _TmpMatrix;
  40419. /**
  40420. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  40421. * @param name the name of the camera
  40422. * @param scene the scene to add the camera to
  40423. */
  40424. constructor(name: string, scene: Scene);
  40425. private _updateNumberOfRigCameras;
  40426. /** @hidden */
  40427. _updateForDualEyeDebugging(pupilDistance?: number): void;
  40428. /**
  40429. * Updates the cameras position from the current pose information of the XR session
  40430. * @param xrSessionManager the session containing pose information
  40431. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  40432. */
  40433. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  40434. }
  40435. }
  40436. declare module "babylonjs/Cameras/XR/webXRExperienceHelper" {
  40437. import { Nullable } from "babylonjs/types";
  40438. import { Observable } from "babylonjs/Misc/observable";
  40439. import { IDisposable, Scene } from "babylonjs/scene";
  40440. import { Quaternion, Vector3 } from "babylonjs/Maths/math";
  40441. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40442. import { Ray } from "babylonjs/Culling/ray";
  40443. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  40444. import { WebXRCamera } from "babylonjs/Cameras/XR/webXRCamera";
  40445. /**
  40446. * States of the webXR experience
  40447. */
  40448. export enum WebXRState {
  40449. /**
  40450. * Transitioning to being in XR mode
  40451. */
  40452. ENTERING_XR = 0,
  40453. /**
  40454. * Transitioning to non XR mode
  40455. */
  40456. EXITING_XR = 1,
  40457. /**
  40458. * In XR mode and presenting
  40459. */
  40460. IN_XR = 2,
  40461. /**
  40462. * Not entered XR mode
  40463. */
  40464. NOT_IN_XR = 3
  40465. }
  40466. /**
  40467. * Helper class used to enable XR
  40468. * @see https://doc.babylonjs.com/how_to/webxr
  40469. */
  40470. export class WebXRExperienceHelper implements IDisposable {
  40471. private scene;
  40472. /**
  40473. * 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
  40474. */
  40475. container: AbstractMesh;
  40476. /**
  40477. * Camera used to render xr content
  40478. */
  40479. camera: WebXRCamera;
  40480. /**
  40481. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  40482. */
  40483. state: WebXRState;
  40484. private _setState;
  40485. private static _TmpVector;
  40486. /**
  40487. * Fires when the state of the experience helper has changed
  40488. */
  40489. onStateChangedObservable: Observable<WebXRState>;
  40490. /** @hidden */
  40491. _sessionManager: WebXRSessionManager;
  40492. private _nonVRCamera;
  40493. private _originalSceneAutoClear;
  40494. private _supported;
  40495. /**
  40496. * Creates the experience helper
  40497. * @param scene the scene to attach the experience helper to
  40498. * @returns a promise for the experience helper
  40499. */
  40500. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  40501. /**
  40502. * Creates a WebXRExperienceHelper
  40503. * @param scene The scene the helper should be created in
  40504. */
  40505. private constructor();
  40506. /**
  40507. * Exits XR mode and returns the scene to its original state
  40508. * @returns promise that resolves after xr mode has exited
  40509. */
  40510. exitXRAsync(): Promise<void>;
  40511. /**
  40512. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  40513. * @param sessionCreationOptions options for the XR session
  40514. * @param frameOfReference frame of reference of the XR session
  40515. * @returns promise that resolves after xr mode has entered
  40516. */
  40517. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  40518. /**
  40519. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  40520. * @param ray ray to cast into the environment
  40521. * @returns Promise which resolves with a collision point in the environment if it exists
  40522. */
  40523. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  40524. /**
  40525. * Updates the global position of the camera by moving the camera's container
  40526. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  40527. * @param position The desired global position of the camera
  40528. */
  40529. setPositionOfCameraUsingContainer(position: Vector3): void;
  40530. /**
  40531. * Rotates the xr camera by rotating the camera's container around the camera's position
  40532. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  40533. * @param rotation the desired quaternion rotation to apply to the camera
  40534. */
  40535. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  40536. /**
  40537. * Checks if the creation options are supported by the xr session
  40538. * @param options creation options
  40539. * @returns true if supported
  40540. */
  40541. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  40542. /**
  40543. * Disposes of the experience helper
  40544. */
  40545. dispose(): void;
  40546. }
  40547. }
  40548. declare module "babylonjs/Cameras/XR/webXREnterExitUI" {
  40549. import { Nullable } from "babylonjs/types";
  40550. import { Observable } from "babylonjs/Misc/observable";
  40551. import { IDisposable, Scene } from "babylonjs/scene";
  40552. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  40553. /**
  40554. * Button which can be used to enter a different mode of XR
  40555. */
  40556. export class WebXREnterExitUIButton {
  40557. /** button element */
  40558. element: HTMLElement;
  40559. /** XR initialization options for the button */
  40560. initializationOptions: XRSessionCreationOptions;
  40561. /**
  40562. * Creates a WebXREnterExitUIButton
  40563. * @param element button element
  40564. * @param initializationOptions XR initialization options for the button
  40565. */
  40566. constructor(
  40567. /** button element */
  40568. element: HTMLElement,
  40569. /** XR initialization options for the button */
  40570. initializationOptions: XRSessionCreationOptions);
  40571. /**
  40572. * Overwritable function which can be used to update the button's visuals when the state changes
  40573. * @param activeButton the current active button in the UI
  40574. */
  40575. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  40576. }
  40577. /**
  40578. * Options to create the webXR UI
  40579. */
  40580. export class WebXREnterExitUIOptions {
  40581. /**
  40582. * Context to enter xr with
  40583. */
  40584. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  40585. /**
  40586. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  40587. */
  40588. customButtons?: Array<WebXREnterExitUIButton>;
  40589. }
  40590. /**
  40591. * UI to allow the user to enter/exit XR mode
  40592. */
  40593. export class WebXREnterExitUI implements IDisposable {
  40594. private scene;
  40595. private _overlay;
  40596. private _buttons;
  40597. private _activeButton;
  40598. /**
  40599. * Fired every time the active button is changed.
  40600. *
  40601. * When xr is entered via a button that launches xr that button will be the callback parameter
  40602. *
  40603. * When exiting xr the callback parameter will be null)
  40604. */
  40605. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  40606. /**
  40607. * Creates UI to allow the user to enter/exit XR mode
  40608. * @param scene the scene to add the ui to
  40609. * @param helper the xr experience helper to enter/exit xr with
  40610. * @param options options to configure the UI
  40611. * @returns the created ui
  40612. */
  40613. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  40614. private constructor();
  40615. private _updateButtons;
  40616. /**
  40617. * Disposes of the object
  40618. */
  40619. dispose(): void;
  40620. }
  40621. }
  40622. declare module "babylonjs/Cameras/XR/webXRInput" {
  40623. import { IDisposable, Scene } from "babylonjs/scene";
  40624. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40625. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  40626. /**
  40627. * Represents an XR input
  40628. */
  40629. export class WebXRController {
  40630. /**
  40631. * 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
  40632. */
  40633. grip?: AbstractMesh;
  40634. /**
  40635. * Pointer which can be used to select objects or attach a visible laser to
  40636. */
  40637. pointer: AbstractMesh;
  40638. /**
  40639. * Creates the controller
  40640. * @see https://doc.babylonjs.com/how_to/webxr
  40641. * @param scene the scene which the controller should be associated to
  40642. */
  40643. constructor(scene: Scene);
  40644. /**
  40645. * Disposes of the object
  40646. */
  40647. dispose(): void;
  40648. }
  40649. /**
  40650. * XR input used to track XR inputs such as controllers/rays
  40651. */
  40652. export class WebXRInput implements IDisposable {
  40653. private helper;
  40654. /**
  40655. * XR controllers being tracked
  40656. */
  40657. controllers: Array<WebXRController>;
  40658. private _tmpMatrix;
  40659. private _frameObserver;
  40660. /**
  40661. * Initializes the WebXRInput
  40662. * @param helper experience helper which the input should be created for
  40663. */
  40664. constructor(helper: WebXRExperienceHelper);
  40665. /**
  40666. * Disposes of the object
  40667. */
  40668. dispose(): void;
  40669. }
  40670. }
  40671. declare module "babylonjs/Cameras/XR/webXRManagedOutputCanvas" {
  40672. import { Nullable } from "babylonjs/types";
  40673. import { IDisposable } from "babylonjs/scene";
  40674. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  40675. /**
  40676. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  40677. */
  40678. export class WebXRManagedOutputCanvas implements IDisposable {
  40679. private _canvas;
  40680. /**
  40681. * xrpresent context of the canvas which can be used to display/mirror xr content
  40682. */
  40683. canvasContext: Nullable<WebGLRenderingContext>;
  40684. /**
  40685. * Initializes the canvas to be added/removed upon entering/exiting xr
  40686. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  40687. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  40688. */
  40689. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  40690. /**
  40691. * Disposes of the object
  40692. */
  40693. dispose(): void;
  40694. private _setManagedOutputCanvas;
  40695. private _addCanvas;
  40696. private _removeCanvas;
  40697. }
  40698. }
  40699. declare module "babylonjs/Cameras/XR/index" {
  40700. export * from "babylonjs/Cameras/XR/webXRCamera";
  40701. export * from "babylonjs/Cameras/XR/webXREnterExitUI";
  40702. export * from "babylonjs/Cameras/XR/webXRExperienceHelper";
  40703. export * from "babylonjs/Cameras/XR/webXRInput";
  40704. export * from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  40705. export * from "babylonjs/Cameras/XR/webXRSessionManager";
  40706. }
  40707. declare module "babylonjs/Cameras/RigModes/index" {
  40708. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40709. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40710. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  40711. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  40712. }
  40713. declare module "babylonjs/Cameras/index" {
  40714. export * from "babylonjs/Cameras/Inputs/index";
  40715. export * from "babylonjs/Cameras/cameraInputsManager";
  40716. export * from "babylonjs/Cameras/camera";
  40717. export * from "babylonjs/Cameras/targetCamera";
  40718. export * from "babylonjs/Cameras/freeCamera";
  40719. export * from "babylonjs/Cameras/freeCameraInputsManager";
  40720. export * from "babylonjs/Cameras/touchCamera";
  40721. export * from "babylonjs/Cameras/arcRotateCamera";
  40722. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  40723. export * from "babylonjs/Cameras/deviceOrientationCamera";
  40724. export * from "babylonjs/Cameras/flyCamera";
  40725. export * from "babylonjs/Cameras/flyCameraInputsManager";
  40726. export * from "babylonjs/Cameras/followCamera";
  40727. export * from "babylonjs/Cameras/gamepadCamera";
  40728. export * from "babylonjs/Cameras/Stereoscopic/index";
  40729. export * from "babylonjs/Cameras/universalCamera";
  40730. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  40731. export * from "babylonjs/Cameras/VR/index";
  40732. export * from "babylonjs/Cameras/XR/index";
  40733. export * from "babylonjs/Cameras/RigModes/index";
  40734. }
  40735. declare module "babylonjs/Collisions/index" {
  40736. export * from "babylonjs/Collisions/collider";
  40737. export * from "babylonjs/Collisions/collisionCoordinator";
  40738. export * from "babylonjs/Collisions/pickingInfo";
  40739. export * from "babylonjs/Collisions/intersectionInfo";
  40740. }
  40741. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  40742. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  40743. import { Vector3, Plane } from "babylonjs/Maths/math";
  40744. import { Ray } from "babylonjs/Culling/ray";
  40745. /**
  40746. * Contains an array of blocks representing the octree
  40747. */
  40748. export interface IOctreeContainer<T> {
  40749. /**
  40750. * Blocks within the octree
  40751. */
  40752. blocks: Array<OctreeBlock<T>>;
  40753. }
  40754. /**
  40755. * Class used to store a cell in an octree
  40756. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40757. */
  40758. export class OctreeBlock<T> {
  40759. /**
  40760. * Gets the content of the current block
  40761. */
  40762. entries: T[];
  40763. /**
  40764. * Gets the list of block children
  40765. */
  40766. blocks: Array<OctreeBlock<T>>;
  40767. private _depth;
  40768. private _maxDepth;
  40769. private _capacity;
  40770. private _minPoint;
  40771. private _maxPoint;
  40772. private _boundingVectors;
  40773. private _creationFunc;
  40774. /**
  40775. * Creates a new block
  40776. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  40777. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  40778. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  40779. * @param depth defines the current depth of this block in the octree
  40780. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  40781. * @param creationFunc defines a callback to call when an element is added to the block
  40782. */
  40783. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  40784. /**
  40785. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  40786. */
  40787. readonly capacity: number;
  40788. /**
  40789. * Gets the minimum vector (in world space) of the block's bounding box
  40790. */
  40791. readonly minPoint: Vector3;
  40792. /**
  40793. * Gets the maximum vector (in world space) of the block's bounding box
  40794. */
  40795. readonly maxPoint: Vector3;
  40796. /**
  40797. * Add a new element to this block
  40798. * @param entry defines the element to add
  40799. */
  40800. addEntry(entry: T): void;
  40801. /**
  40802. * Remove an element from this block
  40803. * @param entry defines the element to remove
  40804. */
  40805. removeEntry(entry: T): void;
  40806. /**
  40807. * Add an array of elements to this block
  40808. * @param entries defines the array of elements to add
  40809. */
  40810. addEntries(entries: T[]): void;
  40811. /**
  40812. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  40813. * @param frustumPlanes defines the frustum planes to test
  40814. * @param selection defines the array to store current content if selection is positive
  40815. * @param allowDuplicate defines if the selection array can contains duplicated entries
  40816. */
  40817. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  40818. /**
  40819. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  40820. * @param sphereCenter defines the bounding sphere center
  40821. * @param sphereRadius defines the bounding sphere radius
  40822. * @param selection defines the array to store current content if selection is positive
  40823. * @param allowDuplicate defines if the selection array can contains duplicated entries
  40824. */
  40825. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  40826. /**
  40827. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  40828. * @param ray defines the ray to test with
  40829. * @param selection defines the array to store current content if selection is positive
  40830. */
  40831. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  40832. /**
  40833. * Subdivide the content into child blocks (this block will then be empty)
  40834. */
  40835. createInnerBlocks(): void;
  40836. /**
  40837. * @hidden
  40838. */
  40839. 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;
  40840. }
  40841. }
  40842. declare module "babylonjs/Culling/Octrees/octree" {
  40843. import { SmartArray } from "babylonjs/Misc/smartArray";
  40844. import { Vector3, Plane } from "babylonjs/Maths/math";
  40845. import { SubMesh } from "babylonjs/Meshes/subMesh";
  40846. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40847. import { Ray } from "babylonjs/Culling/ray";
  40848. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  40849. /**
  40850. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  40851. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40852. */
  40853. export class Octree<T> {
  40854. /** 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.) */
  40855. maxDepth: number;
  40856. /**
  40857. * Blocks within the octree containing objects
  40858. */
  40859. blocks: Array<OctreeBlock<T>>;
  40860. /**
  40861. * Content stored in the octree
  40862. */
  40863. dynamicContent: T[];
  40864. private _maxBlockCapacity;
  40865. private _selectionContent;
  40866. private _creationFunc;
  40867. /**
  40868. * Creates a octree
  40869. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40870. * @param creationFunc function to be used to instatiate the octree
  40871. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  40872. * @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.)
  40873. */
  40874. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  40875. /** 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.) */
  40876. maxDepth?: number);
  40877. /**
  40878. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  40879. * @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);
  40880. * @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);
  40881. * @param entries meshes to be added to the octree blocks
  40882. */
  40883. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  40884. /**
  40885. * Adds a mesh to the octree
  40886. * @param entry Mesh to add to the octree
  40887. */
  40888. addMesh(entry: T): void;
  40889. /**
  40890. * Remove an element from the octree
  40891. * @param entry defines the element to remove
  40892. */
  40893. removeMesh(entry: T): void;
  40894. /**
  40895. * Selects an array of meshes within the frustum
  40896. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  40897. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  40898. * @returns array of meshes within the frustum
  40899. */
  40900. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  40901. /**
  40902. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  40903. * @param sphereCenter defines the bounding sphere center
  40904. * @param sphereRadius defines the bounding sphere radius
  40905. * @param allowDuplicate defines if the selection array can contains duplicated entries
  40906. * @returns an array of objects that intersect the sphere
  40907. */
  40908. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  40909. /**
  40910. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  40911. * @param ray defines the ray to test with
  40912. * @returns array of intersected objects
  40913. */
  40914. intersectsRay(ray: Ray): SmartArray<T>;
  40915. /**
  40916. * Adds a mesh into the octree block if it intersects the block
  40917. */
  40918. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  40919. /**
  40920. * Adds a submesh into the octree block if it intersects the block
  40921. */
  40922. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  40923. }
  40924. }
  40925. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  40926. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  40927. import { Scene } from "babylonjs/scene";
  40928. import { SubMesh } from "babylonjs/Meshes/subMesh";
  40929. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40930. import { Ray } from "babylonjs/Culling/ray";
  40931. import { Octree } from "babylonjs/Culling/Octrees/octree";
  40932. import { Collider } from "babylonjs/Collisions/collider";
  40933. module "babylonjs/scene" {
  40934. interface Scene {
  40935. /**
  40936. * @hidden
  40937. * Backing Filed
  40938. */
  40939. _selectionOctree: Octree<AbstractMesh>;
  40940. /**
  40941. * Gets the octree used to boost mesh selection (picking)
  40942. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40943. */
  40944. selectionOctree: Octree<AbstractMesh>;
  40945. /**
  40946. * Creates or updates the octree used to boost selection (picking)
  40947. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40948. * @param maxCapacity defines the maximum capacity per leaf
  40949. * @param maxDepth defines the maximum depth of the octree
  40950. * @returns an octree of AbstractMesh
  40951. */
  40952. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  40953. }
  40954. }
  40955. module "babylonjs/Meshes/abstractMesh" {
  40956. interface AbstractMesh {
  40957. /**
  40958. * @hidden
  40959. * Backing Field
  40960. */
  40961. _submeshesOctree: Octree<SubMesh>;
  40962. /**
  40963. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  40964. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  40965. * @param maxCapacity defines the maximum size of each block (64 by default)
  40966. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  40967. * @returns the new octree
  40968. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  40969. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40970. */
  40971. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  40972. }
  40973. }
  40974. /**
  40975. * Defines the octree scene component responsible to manage any octrees
  40976. * in a given scene.
  40977. */
  40978. export class OctreeSceneComponent {
  40979. /**
  40980. * The component name helpfull to identify the component in the list of scene components.
  40981. */
  40982. readonly name: string;
  40983. /**
  40984. * The scene the component belongs to.
  40985. */
  40986. scene: Scene;
  40987. /**
  40988. * Indicates if the meshes have been checked to make sure they are isEnabled()
  40989. */
  40990. readonly checksIsEnabled: boolean;
  40991. /**
  40992. * Creates a new instance of the component for the given scene
  40993. * @param scene Defines the scene to register the component in
  40994. */
  40995. constructor(scene: Scene);
  40996. /**
  40997. * Registers the component in a given scene
  40998. */
  40999. register(): void;
  41000. /**
  41001. * Return the list of active meshes
  41002. * @returns the list of active meshes
  41003. */
  41004. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  41005. /**
  41006. * Return the list of active sub meshes
  41007. * @param mesh The mesh to get the candidates sub meshes from
  41008. * @returns the list of active sub meshes
  41009. */
  41010. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  41011. private _tempRay;
  41012. /**
  41013. * Return the list of sub meshes intersecting with a given local ray
  41014. * @param mesh defines the mesh to find the submesh for
  41015. * @param localRay defines the ray in local space
  41016. * @returns the list of intersecting sub meshes
  41017. */
  41018. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  41019. /**
  41020. * Return the list of sub meshes colliding with a collider
  41021. * @param mesh defines the mesh to find the submesh for
  41022. * @param collider defines the collider to evaluate the collision against
  41023. * @returns the list of colliding sub meshes
  41024. */
  41025. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  41026. /**
  41027. * Rebuilds the elements related to this component in case of
  41028. * context lost for instance.
  41029. */
  41030. rebuild(): void;
  41031. /**
  41032. * Disposes the component and the associated ressources.
  41033. */
  41034. dispose(): void;
  41035. }
  41036. }
  41037. declare module "babylonjs/Culling/Octrees/index" {
  41038. export * from "babylonjs/Culling/Octrees/octree";
  41039. export * from "babylonjs/Culling/Octrees/octreeBlock";
  41040. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  41041. }
  41042. declare module "babylonjs/Culling/index" {
  41043. export * from "babylonjs/Culling/boundingBox";
  41044. export * from "babylonjs/Culling/boundingInfo";
  41045. export * from "babylonjs/Culling/boundingSphere";
  41046. export * from "babylonjs/Culling/Octrees/index";
  41047. export * from "babylonjs/Culling/ray";
  41048. }
  41049. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  41050. import { Vector3, Color4 } from "babylonjs/Maths/math";
  41051. import { Nullable } from "babylonjs/types";
  41052. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  41053. import { Scene } from "babylonjs/scene";
  41054. /**
  41055. * Class containing static functions to help procedurally build meshes
  41056. */
  41057. export class LinesBuilder {
  41058. /**
  41059. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  41060. * * 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
  41061. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  41062. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  41063. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  41064. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  41065. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  41066. * * 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
  41067. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  41068. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41069. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  41070. * @param name defines the name of the new line system
  41071. * @param options defines the options used to create the line system
  41072. * @param scene defines the hosting scene
  41073. * @returns a new line system mesh
  41074. */
  41075. static CreateLineSystem(name: string, options: {
  41076. lines: Vector3[][];
  41077. updatable?: boolean;
  41078. instance?: Nullable<LinesMesh>;
  41079. colors?: Nullable<Color4[][]>;
  41080. useVertexAlpha?: boolean;
  41081. }, scene: Nullable<Scene>): LinesMesh;
  41082. /**
  41083. * Creates a line mesh
  41084. * 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
  41085. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  41086. * * The parameter `points` is an array successive Vector3
  41087. * * 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
  41088. * * The optional parameter `colors` is an array of successive Color4, one per line point
  41089. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  41090. * * When updating an instance, remember that only point positions can change, not the number of points
  41091. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41092. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  41093. * @param name defines the name of the new line system
  41094. * @param options defines the options used to create the line system
  41095. * @param scene defines the hosting scene
  41096. * @returns a new line mesh
  41097. */
  41098. static CreateLines(name: string, options: {
  41099. points: Vector3[];
  41100. updatable?: boolean;
  41101. instance?: Nullable<LinesMesh>;
  41102. colors?: Color4[];
  41103. useVertexAlpha?: boolean;
  41104. }, scene?: Nullable<Scene>): LinesMesh;
  41105. /**
  41106. * Creates a dashed line mesh
  41107. * * 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
  41108. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  41109. * * The parameter `points` is an array successive Vector3
  41110. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  41111. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  41112. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  41113. * * 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
  41114. * * When updating an instance, remember that only point positions can change, not the number of points
  41115. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41116. * @param name defines the name of the mesh
  41117. * @param options defines the options used to create the mesh
  41118. * @param scene defines the hosting scene
  41119. * @returns the dashed line mesh
  41120. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  41121. */
  41122. static CreateDashedLines(name: string, options: {
  41123. points: Vector3[];
  41124. dashSize?: number;
  41125. gapSize?: number;
  41126. dashNb?: number;
  41127. updatable?: boolean;
  41128. instance?: LinesMesh;
  41129. }, scene?: Nullable<Scene>): LinesMesh;
  41130. }
  41131. }
  41132. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  41133. import { IDisposable, Scene } from "babylonjs/scene";
  41134. import { Nullable } from "babylonjs/types";
  41135. import { Observable } from "babylonjs/Misc/observable";
  41136. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41137. /**
  41138. * Renders a layer on top of an existing scene
  41139. */
  41140. export class UtilityLayerRenderer implements IDisposable {
  41141. /** the original scene that will be rendered on top of */
  41142. originalScene: Scene;
  41143. private _pointerCaptures;
  41144. private _lastPointerEvents;
  41145. private static _DefaultUtilityLayer;
  41146. private static _DefaultKeepDepthUtilityLayer;
  41147. /**
  41148. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  41149. */
  41150. pickUtilitySceneFirst: boolean;
  41151. /**
  41152. * 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)
  41153. */
  41154. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  41155. /**
  41156. * 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)
  41157. */
  41158. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  41159. /**
  41160. * The scene that is rendered on top of the original scene
  41161. */
  41162. utilityLayerScene: Scene;
  41163. /**
  41164. * If the utility layer should automatically be rendered on top of existing scene
  41165. */
  41166. shouldRender: boolean;
  41167. /**
  41168. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  41169. */
  41170. onlyCheckPointerDownEvents: boolean;
  41171. /**
  41172. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  41173. */
  41174. processAllEvents: boolean;
  41175. /**
  41176. * Observable raised when the pointer move from the utility layer scene to the main scene
  41177. */
  41178. onPointerOutObservable: Observable<number>;
  41179. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  41180. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  41181. private _afterRenderObserver;
  41182. private _sceneDisposeObserver;
  41183. private _originalPointerObserver;
  41184. /**
  41185. * Instantiates a UtilityLayerRenderer
  41186. * @param originalScene the original scene that will be rendered on top of
  41187. * @param handleEvents boolean indicating if the utility layer should handle events
  41188. */
  41189. constructor(
  41190. /** the original scene that will be rendered on top of */
  41191. originalScene: Scene, handleEvents?: boolean);
  41192. private _notifyObservers;
  41193. /**
  41194. * Renders the utility layers scene on top of the original scene
  41195. */
  41196. render(): void;
  41197. /**
  41198. * Disposes of the renderer
  41199. */
  41200. dispose(): void;
  41201. private _updateCamera;
  41202. }
  41203. }
  41204. declare module "babylonjs/Gizmos/gizmo" {
  41205. import { Nullable } from "babylonjs/types";
  41206. import { IDisposable } from "babylonjs/scene";
  41207. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41208. import { Mesh } from "babylonjs/Meshes/mesh";
  41209. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  41210. /**
  41211. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  41212. */
  41213. export class Gizmo implements IDisposable {
  41214. /** The utility layer the gizmo will be added to */
  41215. gizmoLayer: UtilityLayerRenderer;
  41216. /**
  41217. * The root mesh of the gizmo
  41218. */
  41219. _rootMesh: Mesh;
  41220. private _attachedMesh;
  41221. /**
  41222. * Ratio for the scale of the gizmo (Default: 1)
  41223. */
  41224. scaleRatio: number;
  41225. private _tmpMatrix;
  41226. /**
  41227. * If a custom mesh has been set (Default: false)
  41228. */
  41229. protected _customMeshSet: boolean;
  41230. /**
  41231. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  41232. * * When set, interactions will be enabled
  41233. */
  41234. attachedMesh: Nullable<AbstractMesh>;
  41235. /**
  41236. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  41237. * @param mesh The mesh to replace the default mesh of the gizmo
  41238. */
  41239. setCustomMesh(mesh: Mesh): void;
  41240. /**
  41241. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  41242. */
  41243. updateGizmoRotationToMatchAttachedMesh: boolean;
  41244. /**
  41245. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  41246. */
  41247. updateGizmoPositionToMatchAttachedMesh: boolean;
  41248. /**
  41249. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  41250. */
  41251. protected _updateScale: boolean;
  41252. protected _interactionsEnabled: boolean;
  41253. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41254. private _beforeRenderObserver;
  41255. /**
  41256. * Creates a gizmo
  41257. * @param gizmoLayer The utility layer the gizmo will be added to
  41258. */
  41259. constructor(
  41260. /** The utility layer the gizmo will be added to */
  41261. gizmoLayer?: UtilityLayerRenderer);
  41262. private _tempVector;
  41263. /**
  41264. * @hidden
  41265. * Updates the gizmo to match the attached mesh's position/rotation
  41266. */
  41267. protected _update(): void;
  41268. /**
  41269. * Disposes of the gizmo
  41270. */
  41271. dispose(): void;
  41272. }
  41273. }
  41274. declare module "babylonjs/Gizmos/axisDragGizmo" {
  41275. import { Observable } from "babylonjs/Misc/observable";
  41276. import { Nullable } from "babylonjs/types";
  41277. import { Vector3, Color3 } from "babylonjs/Maths/math";
  41278. import { TransformNode } from "babylonjs/Meshes/transformNode";
  41279. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41280. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  41281. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  41282. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  41283. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  41284. import { Scene } from "babylonjs/scene";
  41285. /**
  41286. * Single axis drag gizmo
  41287. */
  41288. export class AxisDragGizmo extends Gizmo {
  41289. /**
  41290. * Drag behavior responsible for the gizmos dragging interactions
  41291. */
  41292. dragBehavior: PointerDragBehavior;
  41293. private _pointerObserver;
  41294. /**
  41295. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  41296. */
  41297. snapDistance: number;
  41298. /**
  41299. * Event that fires each time the gizmo snaps to a new location.
  41300. * * snapDistance is the the change in distance
  41301. */
  41302. onSnapObservable: Observable<{
  41303. snapDistance: number;
  41304. }>;
  41305. /** @hidden */
  41306. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  41307. /** @hidden */
  41308. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  41309. /**
  41310. * Creates an AxisDragGizmo
  41311. * @param gizmoLayer The utility layer the gizmo will be added to
  41312. * @param dragAxis The axis which the gizmo will be able to drag on
  41313. * @param color The color of the gizmo
  41314. */
  41315. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  41316. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41317. /**
  41318. * Disposes of the gizmo
  41319. */
  41320. dispose(): void;
  41321. }
  41322. }
  41323. declare module "babylonjs/Debug/axesViewer" {
  41324. import { Vector3 } from "babylonjs/Maths/math";
  41325. import { Nullable } from "babylonjs/types";
  41326. import { Scene } from "babylonjs/scene";
  41327. import { TransformNode } from "babylonjs/Meshes/transformNode";
  41328. /**
  41329. * The Axes viewer will show 3 axes in a specific point in space
  41330. */
  41331. export class AxesViewer {
  41332. private _xAxis;
  41333. private _yAxis;
  41334. private _zAxis;
  41335. private _scaleLinesFactor;
  41336. private _instanced;
  41337. /**
  41338. * Gets the hosting scene
  41339. */
  41340. scene: Scene;
  41341. /**
  41342. * Gets or sets a number used to scale line length
  41343. */
  41344. scaleLines: number;
  41345. /** Gets the node hierarchy used to render x-axis */
  41346. readonly xAxis: TransformNode;
  41347. /** Gets the node hierarchy used to render y-axis */
  41348. readonly yAxis: TransformNode;
  41349. /** Gets the node hierarchy used to render z-axis */
  41350. readonly zAxis: TransformNode;
  41351. /**
  41352. * Creates a new AxesViewer
  41353. * @param scene defines the hosting scene
  41354. * @param scaleLines defines a number used to scale line length (1 by default)
  41355. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  41356. * @param xAxis defines the node hierarchy used to render the x-axis
  41357. * @param yAxis defines the node hierarchy used to render the y-axis
  41358. * @param zAxis defines the node hierarchy used to render the z-axis
  41359. */
  41360. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  41361. /**
  41362. * Force the viewer to update
  41363. * @param position defines the position of the viewer
  41364. * @param xaxis defines the x axis of the viewer
  41365. * @param yaxis defines the y axis of the viewer
  41366. * @param zaxis defines the z axis of the viewer
  41367. */
  41368. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  41369. /**
  41370. * Creates an instance of this axes viewer.
  41371. * @returns a new axes viewer with instanced meshes
  41372. */
  41373. createInstance(): AxesViewer;
  41374. /** Releases resources */
  41375. dispose(): void;
  41376. private static _SetRenderingGroupId;
  41377. }
  41378. }
  41379. declare module "babylonjs/Debug/boneAxesViewer" {
  41380. import { Nullable } from "babylonjs/types";
  41381. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  41382. import { Vector3 } from "babylonjs/Maths/math";
  41383. import { Mesh } from "babylonjs/Meshes/mesh";
  41384. import { Bone } from "babylonjs/Bones/bone";
  41385. import { Scene } from "babylonjs/scene";
  41386. /**
  41387. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  41388. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  41389. */
  41390. export class BoneAxesViewer extends AxesViewer {
  41391. /**
  41392. * Gets or sets the target mesh where to display the axes viewer
  41393. */
  41394. mesh: Nullable<Mesh>;
  41395. /**
  41396. * Gets or sets the target bone where to display the axes viewer
  41397. */
  41398. bone: Nullable<Bone>;
  41399. /** Gets current position */
  41400. pos: Vector3;
  41401. /** Gets direction of X axis */
  41402. xaxis: Vector3;
  41403. /** Gets direction of Y axis */
  41404. yaxis: Vector3;
  41405. /** Gets direction of Z axis */
  41406. zaxis: Vector3;
  41407. /**
  41408. * Creates a new BoneAxesViewer
  41409. * @param scene defines the hosting scene
  41410. * @param bone defines the target bone
  41411. * @param mesh defines the target mesh
  41412. * @param scaleLines defines a scaling factor for line length (1 by default)
  41413. */
  41414. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  41415. /**
  41416. * Force the viewer to update
  41417. */
  41418. update(): void;
  41419. /** Releases resources */
  41420. dispose(): void;
  41421. }
  41422. }
  41423. declare module "babylonjs/Debug/debugLayer" {
  41424. import { Observable } from "babylonjs/Misc/observable";
  41425. import { Scene } from "babylonjs/scene";
  41426. /**
  41427. * Interface used to define scene explorer extensibility option
  41428. */
  41429. export interface IExplorerExtensibilityOption {
  41430. /**
  41431. * Define the option label
  41432. */
  41433. label: string;
  41434. /**
  41435. * Defines the action to execute on click
  41436. */
  41437. action: (entity: any) => void;
  41438. }
  41439. /**
  41440. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  41441. */
  41442. export interface IExplorerExtensibilityGroup {
  41443. /**
  41444. * Defines a predicate to test if a given type mut be extended
  41445. */
  41446. predicate: (entity: any) => boolean;
  41447. /**
  41448. * Gets the list of options added to a type
  41449. */
  41450. entries: IExplorerExtensibilityOption[];
  41451. }
  41452. /**
  41453. * Interface used to define the options to use to create the Inspector
  41454. */
  41455. export interface IInspectorOptions {
  41456. /**
  41457. * Display in overlay mode (default: false)
  41458. */
  41459. overlay?: boolean;
  41460. /**
  41461. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  41462. */
  41463. globalRoot?: HTMLElement;
  41464. /**
  41465. * Display the Scene explorer
  41466. */
  41467. showExplorer?: boolean;
  41468. /**
  41469. * Display the property inspector
  41470. */
  41471. showInspector?: boolean;
  41472. /**
  41473. * Display in embed mode (both panes on the right)
  41474. */
  41475. embedMode?: boolean;
  41476. /**
  41477. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  41478. */
  41479. handleResize?: boolean;
  41480. /**
  41481. * Allow the panes to popup (default: true)
  41482. */
  41483. enablePopup?: boolean;
  41484. /**
  41485. * Allow the panes to be closed by users (default: true)
  41486. */
  41487. enableClose?: boolean;
  41488. /**
  41489. * Optional list of extensibility entries
  41490. */
  41491. explorerExtensibility?: IExplorerExtensibilityGroup[];
  41492. /**
  41493. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  41494. */
  41495. inspectorURL?: string;
  41496. }
  41497. module "babylonjs/scene" {
  41498. interface Scene {
  41499. /**
  41500. * @hidden
  41501. * Backing field
  41502. */
  41503. _debugLayer: DebugLayer;
  41504. /**
  41505. * Gets the debug layer (aka Inspector) associated with the scene
  41506. * @see http://doc.babylonjs.com/features/playground_debuglayer
  41507. */
  41508. debugLayer: DebugLayer;
  41509. }
  41510. }
  41511. /**
  41512. * The debug layer (aka Inspector) is the go to tool in order to better understand
  41513. * what is happening in your scene
  41514. * @see http://doc.babylonjs.com/features/playground_debuglayer
  41515. */
  41516. export class DebugLayer {
  41517. /**
  41518. * Define the url to get the inspector script from.
  41519. * By default it uses the babylonjs CDN.
  41520. * @ignoreNaming
  41521. */
  41522. static InspectorURL: string;
  41523. private _scene;
  41524. private BJSINSPECTOR;
  41525. /**
  41526. * Observable triggered when a property is changed through the inspector.
  41527. */
  41528. onPropertyChangedObservable: Observable<{
  41529. object: any;
  41530. property: string;
  41531. value: any;
  41532. initialValue: any;
  41533. }>;
  41534. /**
  41535. * Instantiates a new debug layer.
  41536. * The debug layer (aka Inspector) is the go to tool in order to better understand
  41537. * what is happening in your scene
  41538. * @see http://doc.babylonjs.com/features/playground_debuglayer
  41539. * @param scene Defines the scene to inspect
  41540. */
  41541. constructor(scene: Scene);
  41542. /** Creates the inspector window. */
  41543. private _createInspector;
  41544. /**
  41545. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  41546. * @param entity defines the entity to select
  41547. * @param lineContainerTitle defines the specific block to highlight
  41548. */
  41549. select(entity: any, lineContainerTitle?: string): void;
  41550. /** Get the inspector from bundle or global */
  41551. private _getGlobalInspector;
  41552. /**
  41553. * Get if the inspector is visible or not.
  41554. * @returns true if visible otherwise, false
  41555. */
  41556. isVisible(): boolean;
  41557. /**
  41558. * Hide the inspector and close its window.
  41559. */
  41560. hide(): void;
  41561. /**
  41562. * Launch the debugLayer.
  41563. * @param config Define the configuration of the inspector
  41564. * @return a promise fulfilled when the debug layer is visible
  41565. */
  41566. show(config?: IInspectorOptions): Promise<DebugLayer>;
  41567. }
  41568. }
  41569. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  41570. import { Nullable } from "babylonjs/types";
  41571. import { Scene } from "babylonjs/scene";
  41572. import { Vector4, Color4 } from "babylonjs/Maths/math";
  41573. import { Mesh } from "babylonjs/Meshes/mesh";
  41574. /**
  41575. * Class containing static functions to help procedurally build meshes
  41576. */
  41577. export class BoxBuilder {
  41578. /**
  41579. * Creates a box mesh
  41580. * * The parameter `size` sets the size (float) of each box side (default 1)
  41581. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  41582. * * 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)
  41583. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  41584. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41585. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  41586. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41587. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  41588. * @param name defines the name of the mesh
  41589. * @param options defines the options used to create the mesh
  41590. * @param scene defines the hosting scene
  41591. * @returns the box mesh
  41592. */
  41593. static CreateBox(name: string, options: {
  41594. size?: number;
  41595. width?: number;
  41596. height?: number;
  41597. depth?: number;
  41598. faceUV?: Vector4[];
  41599. faceColors?: Color4[];
  41600. sideOrientation?: number;
  41601. frontUVs?: Vector4;
  41602. backUVs?: Vector4;
  41603. updatable?: boolean;
  41604. }, scene?: Nullable<Scene>): Mesh;
  41605. }
  41606. }
  41607. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  41608. import { Vector4 } from "babylonjs/Maths/math";
  41609. import { Mesh } from "babylonjs/Meshes/mesh";
  41610. /**
  41611. * Class containing static functions to help procedurally build meshes
  41612. */
  41613. export class SphereBuilder {
  41614. /**
  41615. * Creates a sphere mesh
  41616. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  41617. * * 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`)
  41618. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  41619. * * 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
  41620. * * 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)
  41621. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41622. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  41623. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41624. * @param name defines the name of the mesh
  41625. * @param options defines the options used to create the mesh
  41626. * @param scene defines the hosting scene
  41627. * @returns the sphere mesh
  41628. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  41629. */
  41630. static CreateSphere(name: string, options: {
  41631. segments?: number;
  41632. diameter?: number;
  41633. diameterX?: number;
  41634. diameterY?: number;
  41635. diameterZ?: number;
  41636. arc?: number;
  41637. slice?: number;
  41638. sideOrientation?: number;
  41639. frontUVs?: Vector4;
  41640. backUVs?: Vector4;
  41641. updatable?: boolean;
  41642. }, scene: any): Mesh;
  41643. }
  41644. }
  41645. declare module "babylonjs/Debug/physicsViewer" {
  41646. import { Nullable } from "babylonjs/types";
  41647. import { Scene } from "babylonjs/scene";
  41648. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41649. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  41650. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  41651. /**
  41652. * Used to show the physics impostor around the specific mesh
  41653. */
  41654. export class PhysicsViewer {
  41655. /** @hidden */
  41656. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  41657. /** @hidden */
  41658. protected _meshes: Array<Nullable<AbstractMesh>>;
  41659. /** @hidden */
  41660. protected _scene: Nullable<Scene>;
  41661. /** @hidden */
  41662. protected _numMeshes: number;
  41663. /** @hidden */
  41664. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  41665. private _renderFunction;
  41666. private _utilityLayer;
  41667. private _debugBoxMesh;
  41668. private _debugSphereMesh;
  41669. private _debugMaterial;
  41670. /**
  41671. * Creates a new PhysicsViewer
  41672. * @param scene defines the hosting scene
  41673. */
  41674. constructor(scene: Scene);
  41675. /** @hidden */
  41676. protected _updateDebugMeshes(): void;
  41677. /**
  41678. * Renders a specified physic impostor
  41679. * @param impostor defines the impostor to render
  41680. * @returns the new debug mesh used to render the impostor
  41681. */
  41682. showImpostor(impostor: PhysicsImpostor): Nullable<AbstractMesh>;
  41683. /**
  41684. * Hides a specified physic impostor
  41685. * @param impostor defines the impostor to hide
  41686. */
  41687. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  41688. private _getDebugMaterial;
  41689. private _getDebugBoxMesh;
  41690. private _getDebugSphereMesh;
  41691. private _getDebugMesh;
  41692. /** Releases all resources */
  41693. dispose(): void;
  41694. }
  41695. }
  41696. declare module "babylonjs/Debug/rayHelper" {
  41697. import { Nullable } from "babylonjs/types";
  41698. import { Ray } from "babylonjs/Culling/ray";
  41699. import { Vector3, Color3 } from "babylonjs/Maths/math";
  41700. import { Scene } from "babylonjs/scene";
  41701. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41702. import "babylonjs/Meshes/Builders/linesBuilder";
  41703. /**
  41704. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  41705. * in order to better appreciate the issue one might have.
  41706. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  41707. */
  41708. export class RayHelper {
  41709. /**
  41710. * Defines the ray we are currently tryin to visualize.
  41711. */
  41712. ray: Nullable<Ray>;
  41713. private _renderPoints;
  41714. private _renderLine;
  41715. private _renderFunction;
  41716. private _scene;
  41717. private _updateToMeshFunction;
  41718. private _attachedToMesh;
  41719. private _meshSpaceDirection;
  41720. private _meshSpaceOrigin;
  41721. /**
  41722. * Helper function to create a colored helper in a scene in one line.
  41723. * @param ray Defines the ray we are currently tryin to visualize
  41724. * @param scene Defines the scene the ray is used in
  41725. * @param color Defines the color we want to see the ray in
  41726. * @returns The newly created ray helper.
  41727. */
  41728. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  41729. /**
  41730. * Instantiate a new ray helper.
  41731. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  41732. * in order to better appreciate the issue one might have.
  41733. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  41734. * @param ray Defines the ray we are currently tryin to visualize
  41735. */
  41736. constructor(ray: Ray);
  41737. /**
  41738. * Shows the ray we are willing to debug.
  41739. * @param scene Defines the scene the ray needs to be rendered in
  41740. * @param color Defines the color the ray needs to be rendered in
  41741. */
  41742. show(scene: Scene, color?: Color3): void;
  41743. /**
  41744. * Hides the ray we are debugging.
  41745. */
  41746. hide(): void;
  41747. private _render;
  41748. /**
  41749. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  41750. * @param mesh Defines the mesh we want the helper attached to
  41751. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  41752. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  41753. * @param length Defines the length of the ray
  41754. */
  41755. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  41756. /**
  41757. * Detach the ray helper from the mesh it has previously been attached to.
  41758. */
  41759. detachFromMesh(): void;
  41760. private _updateToMesh;
  41761. /**
  41762. * Dispose the helper and release its associated resources.
  41763. */
  41764. dispose(): void;
  41765. }
  41766. }
  41767. declare module "babylonjs/Debug/skeletonViewer" {
  41768. import { Color3 } from "babylonjs/Maths/math";
  41769. import { Scene } from "babylonjs/scene";
  41770. import { Nullable } from "babylonjs/types";
  41771. import { Skeleton } from "babylonjs/Bones/skeleton";
  41772. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41773. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  41774. /**
  41775. * Class used to render a debug view of a given skeleton
  41776. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  41777. */
  41778. export class SkeletonViewer {
  41779. /** defines the skeleton to render */
  41780. skeleton: Skeleton;
  41781. /** defines the mesh attached to the skeleton */
  41782. mesh: AbstractMesh;
  41783. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  41784. autoUpdateBonesMatrices: boolean;
  41785. /** defines the rendering group id to use with the viewer */
  41786. renderingGroupId: number;
  41787. /** Gets or sets the color used to render the skeleton */
  41788. color: Color3;
  41789. private _scene;
  41790. private _debugLines;
  41791. private _debugMesh;
  41792. private _isEnabled;
  41793. private _renderFunction;
  41794. private _utilityLayer;
  41795. /**
  41796. * Returns the mesh used to render the bones
  41797. */
  41798. readonly debugMesh: Nullable<LinesMesh>;
  41799. /**
  41800. * Creates a new SkeletonViewer
  41801. * @param skeleton defines the skeleton to render
  41802. * @param mesh defines the mesh attached to the skeleton
  41803. * @param scene defines the hosting scene
  41804. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  41805. * @param renderingGroupId defines the rendering group id to use with the viewer
  41806. */
  41807. constructor(
  41808. /** defines the skeleton to render */
  41809. skeleton: Skeleton,
  41810. /** defines the mesh attached to the skeleton */
  41811. mesh: AbstractMesh, scene: Scene,
  41812. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  41813. autoUpdateBonesMatrices?: boolean,
  41814. /** defines the rendering group id to use with the viewer */
  41815. renderingGroupId?: number);
  41816. /** Gets or sets a boolean indicating if the viewer is enabled */
  41817. isEnabled: boolean;
  41818. private _getBonePosition;
  41819. private _getLinesForBonesWithLength;
  41820. private _getLinesForBonesNoLength;
  41821. /** Update the viewer to sync with current skeleton state */
  41822. update(): void;
  41823. /** Release associated resources */
  41824. dispose(): void;
  41825. }
  41826. }
  41827. declare module "babylonjs/Debug/index" {
  41828. export * from "babylonjs/Debug/axesViewer";
  41829. export * from "babylonjs/Debug/boneAxesViewer";
  41830. export * from "babylonjs/Debug/debugLayer";
  41831. export * from "babylonjs/Debug/physicsViewer";
  41832. export * from "babylonjs/Debug/rayHelper";
  41833. export * from "babylonjs/Debug/skeletonViewer";
  41834. }
  41835. declare module "babylonjs/Engines/nullEngine" {
  41836. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  41837. import { Scene } from "babylonjs/scene";
  41838. import { Matrix, Color3, Color4, Viewport } from "babylonjs/Maths/math";
  41839. import { Engine } from "babylonjs/Engines/engine";
  41840. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  41841. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  41842. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  41843. import { Effect } from "babylonjs/Materials/effect";
  41844. /**
  41845. * Options to create the null engine
  41846. */
  41847. export class NullEngineOptions {
  41848. /**
  41849. * Render width (Default: 512)
  41850. */
  41851. renderWidth: number;
  41852. /**
  41853. * Render height (Default: 256)
  41854. */
  41855. renderHeight: number;
  41856. /**
  41857. * Texture size (Default: 512)
  41858. */
  41859. textureSize: number;
  41860. /**
  41861. * If delta time between frames should be constant
  41862. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41863. */
  41864. deterministicLockstep: boolean;
  41865. /**
  41866. * Maximum about of steps between frames (Default: 4)
  41867. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41868. */
  41869. lockstepMaxSteps: number;
  41870. }
  41871. /**
  41872. * The null engine class provides support for headless version of babylon.js.
  41873. * This can be used in server side scenario or for testing purposes
  41874. */
  41875. export class NullEngine extends Engine {
  41876. private _options;
  41877. /**
  41878. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41879. */
  41880. isDeterministicLockStep(): boolean;
  41881. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  41882. getLockstepMaxSteps(): number;
  41883. /**
  41884. * Sets hardware scaling, used to save performance if needed
  41885. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  41886. */
  41887. getHardwareScalingLevel(): number;
  41888. constructor(options?: NullEngineOptions);
  41889. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  41890. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  41891. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  41892. getRenderWidth(useScreen?: boolean): number;
  41893. getRenderHeight(useScreen?: boolean): number;
  41894. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  41895. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  41896. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  41897. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  41898. bindSamplers(effect: Effect): void;
  41899. enableEffect(effect: Effect): void;
  41900. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  41901. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  41902. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  41903. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  41904. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  41905. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  41906. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  41907. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  41908. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  41909. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  41910. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  41911. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  41912. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  41913. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  41914. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  41915. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  41916. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  41917. setFloat(uniform: WebGLUniformLocation, value: number): void;
  41918. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  41919. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  41920. setBool(uniform: WebGLUniformLocation, bool: number): void;
  41921. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  41922. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  41923. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  41924. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  41925. bindBuffers(vertexBuffers: {
  41926. [key: string]: VertexBuffer;
  41927. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  41928. wipeCaches(bruteForce?: boolean): void;
  41929. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  41930. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  41931. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  41932. /** @hidden */
  41933. _createTexture(): WebGLTexture;
  41934. /** @hidden */
  41935. _releaseTexture(texture: InternalTexture): void;
  41936. 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;
  41937. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  41938. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  41939. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  41940. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  41941. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  41942. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  41943. areAllEffectsReady(): boolean;
  41944. /**
  41945. * @hidden
  41946. * Get the current error code of the webGL context
  41947. * @returns the error code
  41948. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  41949. */
  41950. getError(): number;
  41951. /** @hidden */
  41952. _getUnpackAlignement(): number;
  41953. /** @hidden */
  41954. _unpackFlipY(value: boolean): void;
  41955. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  41956. /**
  41957. * Updates a dynamic vertex buffer.
  41958. * @param vertexBuffer the vertex buffer to update
  41959. * @param data the data used to update the vertex buffer
  41960. * @param byteOffset the byte offset of the data (optional)
  41961. * @param byteLength the byte length of the data (optional)
  41962. */
  41963. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  41964. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  41965. /** @hidden */
  41966. _bindTexture(channel: number, texture: InternalTexture): void;
  41967. /** @hidden */
  41968. _releaseBuffer(buffer: WebGLBuffer): boolean;
  41969. releaseEffects(): void;
  41970. displayLoadingUI(): void;
  41971. hideLoadingUI(): void;
  41972. /** @hidden */
  41973. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  41974. /** @hidden */
  41975. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  41976. /** @hidden */
  41977. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  41978. /** @hidden */
  41979. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  41980. }
  41981. }
  41982. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  41983. import { Nullable, int } from "babylonjs/types";
  41984. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  41985. /** @hidden */
  41986. export class _OcclusionDataStorage {
  41987. /** @hidden */
  41988. occlusionInternalRetryCounter: number;
  41989. /** @hidden */
  41990. isOcclusionQueryInProgress: boolean;
  41991. /** @hidden */
  41992. isOccluded: boolean;
  41993. /** @hidden */
  41994. occlusionRetryCount: number;
  41995. /** @hidden */
  41996. occlusionType: number;
  41997. /** @hidden */
  41998. occlusionQueryAlgorithmType: number;
  41999. }
  42000. module "babylonjs/Engines/engine" {
  42001. interface Engine {
  42002. /**
  42003. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  42004. * @return the new query
  42005. */
  42006. createQuery(): WebGLQuery;
  42007. /**
  42008. * Delete and release a webGL query
  42009. * @param query defines the query to delete
  42010. * @return the current engine
  42011. */
  42012. deleteQuery(query: WebGLQuery): Engine;
  42013. /**
  42014. * Check if a given query has resolved and got its value
  42015. * @param query defines the query to check
  42016. * @returns true if the query got its value
  42017. */
  42018. isQueryResultAvailable(query: WebGLQuery): boolean;
  42019. /**
  42020. * Gets the value of a given query
  42021. * @param query defines the query to check
  42022. * @returns the value of the query
  42023. */
  42024. getQueryResult(query: WebGLQuery): number;
  42025. /**
  42026. * Initiates an occlusion query
  42027. * @param algorithmType defines the algorithm to use
  42028. * @param query defines the query to use
  42029. * @returns the current engine
  42030. * @see http://doc.babylonjs.com/features/occlusionquery
  42031. */
  42032. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  42033. /**
  42034. * Ends an occlusion query
  42035. * @see http://doc.babylonjs.com/features/occlusionquery
  42036. * @param algorithmType defines the algorithm to use
  42037. * @returns the current engine
  42038. */
  42039. endOcclusionQuery(algorithmType: number): Engine;
  42040. /**
  42041. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  42042. * Please note that only one query can be issued at a time
  42043. * @returns a time token used to track the time span
  42044. */
  42045. startTimeQuery(): Nullable<_TimeToken>;
  42046. /**
  42047. * Ends a time query
  42048. * @param token defines the token used to measure the time span
  42049. * @returns the time spent (in ns)
  42050. */
  42051. endTimeQuery(token: _TimeToken): int;
  42052. /** @hidden */
  42053. _currentNonTimestampToken: Nullable<_TimeToken>;
  42054. /** @hidden */
  42055. _createTimeQuery(): WebGLQuery;
  42056. /** @hidden */
  42057. _deleteTimeQuery(query: WebGLQuery): void;
  42058. /** @hidden */
  42059. _getGlAlgorithmType(algorithmType: number): number;
  42060. /** @hidden */
  42061. _getTimeQueryResult(query: WebGLQuery): any;
  42062. /** @hidden */
  42063. _getTimeQueryAvailability(query: WebGLQuery): any;
  42064. }
  42065. }
  42066. module "babylonjs/Meshes/abstractMesh" {
  42067. interface AbstractMesh {
  42068. /**
  42069. * Backing filed
  42070. * @hidden
  42071. */
  42072. __occlusionDataStorage: _OcclusionDataStorage;
  42073. /**
  42074. * Access property
  42075. * @hidden
  42076. */
  42077. _occlusionDataStorage: _OcclusionDataStorage;
  42078. /**
  42079. * 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.
  42080. * The default value is -1 which means don't break the query and wait till the result
  42081. * @see http://doc.babylonjs.com/features/occlusionquery
  42082. */
  42083. occlusionRetryCount: number;
  42084. /**
  42085. * 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:
  42086. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  42087. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  42088. * * 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.
  42089. * @see http://doc.babylonjs.com/features/occlusionquery
  42090. */
  42091. occlusionType: number;
  42092. /**
  42093. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  42094. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  42095. * * 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.
  42096. * @see http://doc.babylonjs.com/features/occlusionquery
  42097. */
  42098. occlusionQueryAlgorithmType: number;
  42099. /**
  42100. * 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
  42101. * @see http://doc.babylonjs.com/features/occlusionquery
  42102. */
  42103. isOccluded: boolean;
  42104. /**
  42105. * Flag to check the progress status of the query
  42106. * @see http://doc.babylonjs.com/features/occlusionquery
  42107. */
  42108. isOcclusionQueryInProgress: boolean;
  42109. }
  42110. }
  42111. }
  42112. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  42113. import { Nullable } from "babylonjs/types";
  42114. /** @hidden */
  42115. export var _forceTransformFeedbackToBundle: boolean;
  42116. module "babylonjs/Engines/engine" {
  42117. interface Engine {
  42118. /**
  42119. * Creates a webGL transform feedback object
  42120. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  42121. * @returns the webGL transform feedback object
  42122. */
  42123. createTransformFeedback(): WebGLTransformFeedback;
  42124. /**
  42125. * Delete a webGL transform feedback object
  42126. * @param value defines the webGL transform feedback object to delete
  42127. */
  42128. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  42129. /**
  42130. * Bind a webGL transform feedback object to the webgl context
  42131. * @param value defines the webGL transform feedback object to bind
  42132. */
  42133. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  42134. /**
  42135. * Begins a transform feedback operation
  42136. * @param usePoints defines if points or triangles must be used
  42137. */
  42138. beginTransformFeedback(usePoints: boolean): void;
  42139. /**
  42140. * Ends a transform feedback operation
  42141. */
  42142. endTransformFeedback(): void;
  42143. /**
  42144. * Specify the varyings to use with transform feedback
  42145. * @param program defines the associated webGL program
  42146. * @param value defines the list of strings representing the varying names
  42147. */
  42148. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  42149. /**
  42150. * Bind a webGL buffer for a transform feedback operation
  42151. * @param value defines the webGL buffer to bind
  42152. */
  42153. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  42154. }
  42155. }
  42156. }
  42157. declare module "babylonjs/Engines/Extensions/index" {
  42158. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  42159. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  42160. }
  42161. declare module "babylonjs/Engines/index" {
  42162. export * from "babylonjs/Engines/constants";
  42163. export * from "babylonjs/Engines/engine";
  42164. export * from "babylonjs/Engines/engineStore";
  42165. export * from "babylonjs/Engines/nullEngine";
  42166. export * from "babylonjs/Engines/Extensions/index";
  42167. }
  42168. declare module "babylonjs/Events/clipboardEvents" {
  42169. /**
  42170. * Gather the list of clipboard event types as constants.
  42171. */
  42172. export class ClipboardEventTypes {
  42173. /**
  42174. * The clipboard event is fired when a copy command is active (pressed).
  42175. */
  42176. static readonly COPY: number;
  42177. /**
  42178. * The clipboard event is fired when a cut command is active (pressed).
  42179. */
  42180. static readonly CUT: number;
  42181. /**
  42182. * The clipboard event is fired when a paste command is active (pressed).
  42183. */
  42184. static readonly PASTE: number;
  42185. }
  42186. /**
  42187. * This class is used to store clipboard related info for the onClipboardObservable event.
  42188. */
  42189. export class ClipboardInfo {
  42190. /**
  42191. * Defines the type of event (BABYLON.ClipboardEventTypes)
  42192. */
  42193. type: number;
  42194. /**
  42195. * Defines the related dom event
  42196. */
  42197. event: ClipboardEvent;
  42198. /**
  42199. *Creates an instance of ClipboardInfo.
  42200. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  42201. * @param event Defines the related dom event
  42202. */
  42203. constructor(
  42204. /**
  42205. * Defines the type of event (BABYLON.ClipboardEventTypes)
  42206. */
  42207. type: number,
  42208. /**
  42209. * Defines the related dom event
  42210. */
  42211. event: ClipboardEvent);
  42212. /**
  42213. * Get the clipboard event's type from the keycode.
  42214. * @param keyCode Defines the keyCode for the current keyboard event.
  42215. * @return {number}
  42216. */
  42217. static GetTypeFromCharacter(keyCode: number): number;
  42218. }
  42219. }
  42220. declare module "babylonjs/Events/index" {
  42221. export * from "babylonjs/Events/keyboardEvents";
  42222. export * from "babylonjs/Events/pointerEvents";
  42223. export * from "babylonjs/Events/clipboardEvents";
  42224. }
  42225. declare module "babylonjs/Loading/sceneLoader" {
  42226. import { Observable } from "babylonjs/Misc/observable";
  42227. import { Nullable } from "babylonjs/types";
  42228. import { Scene } from "babylonjs/scene";
  42229. import { Engine } from "babylonjs/Engines/engine";
  42230. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42231. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  42232. import { AssetContainer } from "babylonjs/assetContainer";
  42233. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  42234. import { Skeleton } from "babylonjs/Bones/skeleton";
  42235. /**
  42236. * Class used to represent data loading progression
  42237. */
  42238. export class SceneLoaderProgressEvent {
  42239. /** defines if data length to load can be evaluated */
  42240. readonly lengthComputable: boolean;
  42241. /** defines the loaded data length */
  42242. readonly loaded: number;
  42243. /** defines the data length to load */
  42244. readonly total: number;
  42245. /**
  42246. * Create a new progress event
  42247. * @param lengthComputable defines if data length to load can be evaluated
  42248. * @param loaded defines the loaded data length
  42249. * @param total defines the data length to load
  42250. */
  42251. constructor(
  42252. /** defines if data length to load can be evaluated */
  42253. lengthComputable: boolean,
  42254. /** defines the loaded data length */
  42255. loaded: number,
  42256. /** defines the data length to load */
  42257. total: number);
  42258. /**
  42259. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  42260. * @param event defines the source event
  42261. * @returns a new SceneLoaderProgressEvent
  42262. */
  42263. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  42264. }
  42265. /**
  42266. * Interface used by SceneLoader plugins to define supported file extensions
  42267. */
  42268. export interface ISceneLoaderPluginExtensions {
  42269. /**
  42270. * Defines the list of supported extensions
  42271. */
  42272. [extension: string]: {
  42273. isBinary: boolean;
  42274. };
  42275. }
  42276. /**
  42277. * Interface used by SceneLoader plugin factory
  42278. */
  42279. export interface ISceneLoaderPluginFactory {
  42280. /**
  42281. * Defines the name of the factory
  42282. */
  42283. name: string;
  42284. /**
  42285. * Function called to create a new plugin
  42286. * @return the new plugin
  42287. */
  42288. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  42289. /**
  42290. * Boolean indicating if the plugin can direct load specific data
  42291. */
  42292. canDirectLoad?: (data: string) => boolean;
  42293. }
  42294. /**
  42295. * Interface used to define a SceneLoader plugin
  42296. */
  42297. export interface ISceneLoaderPlugin {
  42298. /**
  42299. * The friendly name of this plugin.
  42300. */
  42301. name: string;
  42302. /**
  42303. * The file extensions supported by this plugin.
  42304. */
  42305. extensions: string | ISceneLoaderPluginExtensions;
  42306. /**
  42307. * Import meshes into a scene.
  42308. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42309. * @param scene The scene to import into
  42310. * @param data The data to import
  42311. * @param rootUrl The root url for scene and resources
  42312. * @param meshes The meshes array to import into
  42313. * @param particleSystems The particle systems array to import into
  42314. * @param skeletons The skeletons array to import into
  42315. * @param onError The callback when import fails
  42316. * @returns True if successful or false otherwise
  42317. */
  42318. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  42319. /**
  42320. * Load into a scene.
  42321. * @param scene The scene to load into
  42322. * @param data The data to import
  42323. * @param rootUrl The root url for scene and resources
  42324. * @param onError The callback when import fails
  42325. * @returns true if successful or false otherwise
  42326. */
  42327. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  42328. /**
  42329. * The callback that returns true if the data can be directly loaded.
  42330. */
  42331. canDirectLoad?: (data: string) => boolean;
  42332. /**
  42333. * The callback that allows custom handling of the root url based on the response url.
  42334. */
  42335. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  42336. /**
  42337. * Load into an asset container.
  42338. * @param scene The scene to load into
  42339. * @param data The data to import
  42340. * @param rootUrl The root url for scene and resources
  42341. * @param onError The callback when import fails
  42342. * @returns The loaded asset container
  42343. */
  42344. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  42345. }
  42346. /**
  42347. * Interface used to define an async SceneLoader plugin
  42348. */
  42349. export interface ISceneLoaderPluginAsync {
  42350. /**
  42351. * The friendly name of this plugin.
  42352. */
  42353. name: string;
  42354. /**
  42355. * The file extensions supported by this plugin.
  42356. */
  42357. extensions: string | ISceneLoaderPluginExtensions;
  42358. /**
  42359. * Import meshes into a scene.
  42360. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42361. * @param scene The scene to import into
  42362. * @param data The data to import
  42363. * @param rootUrl The root url for scene and resources
  42364. * @param onProgress The callback when the load progresses
  42365. * @param fileName Defines the name of the file to load
  42366. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  42367. */
  42368. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  42369. meshes: AbstractMesh[];
  42370. particleSystems: IParticleSystem[];
  42371. skeletons: Skeleton[];
  42372. animationGroups: AnimationGroup[];
  42373. }>;
  42374. /**
  42375. * Load into a scene.
  42376. * @param scene The scene to load into
  42377. * @param data The data to import
  42378. * @param rootUrl The root url for scene and resources
  42379. * @param onProgress The callback when the load progresses
  42380. * @param fileName Defines the name of the file to load
  42381. * @returns Nothing
  42382. */
  42383. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  42384. /**
  42385. * The callback that returns true if the data can be directly loaded.
  42386. */
  42387. canDirectLoad?: (data: string) => boolean;
  42388. /**
  42389. * The callback that allows custom handling of the root url based on the response url.
  42390. */
  42391. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  42392. /**
  42393. * Load into an asset container.
  42394. * @param scene The scene to load into
  42395. * @param data The data to import
  42396. * @param rootUrl The root url for scene and resources
  42397. * @param onProgress The callback when the load progresses
  42398. * @param fileName Defines the name of the file to load
  42399. * @returns The loaded asset container
  42400. */
  42401. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  42402. }
  42403. /**
  42404. * Class used to load scene from various file formats using registered plugins
  42405. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  42406. */
  42407. export class SceneLoader {
  42408. /**
  42409. * No logging while loading
  42410. */
  42411. static readonly NO_LOGGING: number;
  42412. /**
  42413. * Minimal logging while loading
  42414. */
  42415. static readonly MINIMAL_LOGGING: number;
  42416. /**
  42417. * Summary logging while loading
  42418. */
  42419. static readonly SUMMARY_LOGGING: number;
  42420. /**
  42421. * Detailled logging while loading
  42422. */
  42423. static readonly DETAILED_LOGGING: number;
  42424. /**
  42425. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  42426. */
  42427. static ForceFullSceneLoadingForIncremental: boolean;
  42428. /**
  42429. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  42430. */
  42431. static ShowLoadingScreen: boolean;
  42432. /**
  42433. * Defines the current logging level (while loading the scene)
  42434. * @ignorenaming
  42435. */
  42436. static loggingLevel: number;
  42437. /**
  42438. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  42439. */
  42440. static CleanBoneMatrixWeights: boolean;
  42441. /**
  42442. * Event raised when a plugin is used to load a scene
  42443. */
  42444. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  42445. private static _registeredPlugins;
  42446. private static _getDefaultPlugin;
  42447. private static _getPluginForExtension;
  42448. private static _getPluginForDirectLoad;
  42449. private static _getPluginForFilename;
  42450. private static _getDirectLoad;
  42451. private static _loadData;
  42452. private static _getFileInfo;
  42453. /**
  42454. * Gets a plugin that can load the given extension
  42455. * @param extension defines the extension to load
  42456. * @returns a plugin or null if none works
  42457. */
  42458. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  42459. /**
  42460. * Gets a boolean indicating that the given extension can be loaded
  42461. * @param extension defines the extension to load
  42462. * @returns true if the extension is supported
  42463. */
  42464. static IsPluginForExtensionAvailable(extension: string): boolean;
  42465. /**
  42466. * Adds a new plugin to the list of registered plugins
  42467. * @param plugin defines the plugin to add
  42468. */
  42469. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  42470. /**
  42471. * Import meshes into a scene
  42472. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42473. * @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)
  42474. * @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)
  42475. * @param scene the instance of BABYLON.Scene to append to
  42476. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  42477. * @param onProgress a callback with a progress event for each file being loaded
  42478. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42479. * @param pluginExtension the extension used to determine the plugin
  42480. * @returns The loaded plugin
  42481. */
  42482. 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>;
  42483. /**
  42484. * Import meshes into a scene
  42485. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42486. * @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)
  42487. * @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)
  42488. * @param scene the instance of BABYLON.Scene to append to
  42489. * @param onProgress a callback with a progress event for each file being loaded
  42490. * @param pluginExtension the extension used to determine the plugin
  42491. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  42492. */
  42493. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  42494. meshes: AbstractMesh[];
  42495. particleSystems: IParticleSystem[];
  42496. skeletons: Skeleton[];
  42497. animationGroups: AnimationGroup[];
  42498. }>;
  42499. /**
  42500. * Load a scene
  42501. * @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)
  42502. * @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)
  42503. * @param engine is the instance of BABYLON.Engine to use to create the scene
  42504. * @param onSuccess a callback with the scene when import succeeds
  42505. * @param onProgress a callback with a progress event for each file being loaded
  42506. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42507. * @param pluginExtension the extension used to determine the plugin
  42508. * @returns The loaded plugin
  42509. */
  42510. 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>;
  42511. /**
  42512. * Load a scene
  42513. * @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)
  42514. * @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)
  42515. * @param engine is the instance of BABYLON.Engine to use to create the scene
  42516. * @param onProgress a callback with a progress event for each file being loaded
  42517. * @param pluginExtension the extension used to determine the plugin
  42518. * @returns The loaded scene
  42519. */
  42520. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  42521. /**
  42522. * Append a scene
  42523. * @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)
  42524. * @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)
  42525. * @param scene is the instance of BABYLON.Scene to append to
  42526. * @param onSuccess a callback with the scene when import succeeds
  42527. * @param onProgress a callback with a progress event for each file being loaded
  42528. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42529. * @param pluginExtension the extension used to determine the plugin
  42530. * @returns The loaded plugin
  42531. */
  42532. 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>;
  42533. /**
  42534. * Append a scene
  42535. * @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)
  42536. * @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)
  42537. * @param scene is the instance of BABYLON.Scene to append to
  42538. * @param onProgress a callback with a progress event for each file being loaded
  42539. * @param pluginExtension the extension used to determine the plugin
  42540. * @returns The given scene
  42541. */
  42542. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  42543. /**
  42544. * Load a scene into an asset container
  42545. * @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)
  42546. * @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)
  42547. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  42548. * @param onSuccess a callback with the scene when import succeeds
  42549. * @param onProgress a callback with a progress event for each file being loaded
  42550. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42551. * @param pluginExtension the extension used to determine the plugin
  42552. * @returns The loaded plugin
  42553. */
  42554. 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>;
  42555. /**
  42556. * Load a scene into an asset container
  42557. * @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)
  42558. * @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)
  42559. * @param scene is the instance of Scene to append to
  42560. * @param onProgress a callback with a progress event for each file being loaded
  42561. * @param pluginExtension the extension used to determine the plugin
  42562. * @returns The loaded asset container
  42563. */
  42564. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  42565. }
  42566. }
  42567. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  42568. import { Scene } from "babylonjs/scene";
  42569. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42570. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42571. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42572. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42573. /**
  42574. * Google Daydream controller
  42575. */
  42576. export class DaydreamController extends WebVRController {
  42577. /**
  42578. * Base Url for the controller model.
  42579. */
  42580. static MODEL_BASE_URL: string;
  42581. /**
  42582. * File name for the controller model.
  42583. */
  42584. static MODEL_FILENAME: string;
  42585. /**
  42586. * Gamepad Id prefix used to identify Daydream Controller.
  42587. */
  42588. static readonly GAMEPAD_ID_PREFIX: string;
  42589. /**
  42590. * Creates a new DaydreamController from a gamepad
  42591. * @param vrGamepad the gamepad that the controller should be created from
  42592. */
  42593. constructor(vrGamepad: any);
  42594. /**
  42595. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42596. * @param scene scene in which to add meshes
  42597. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42598. */
  42599. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42600. /**
  42601. * Called once for each button that changed state since the last frame
  42602. * @param buttonIdx Which button index changed
  42603. * @param state New state of the button
  42604. * @param changes Which properties on the state changed since last frame
  42605. */
  42606. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42607. }
  42608. }
  42609. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  42610. import { Scene } from "babylonjs/scene";
  42611. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42612. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42613. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42614. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42615. /**
  42616. * Gear VR Controller
  42617. */
  42618. export class GearVRController extends WebVRController {
  42619. /**
  42620. * Base Url for the controller model.
  42621. */
  42622. static MODEL_BASE_URL: string;
  42623. /**
  42624. * File name for the controller model.
  42625. */
  42626. static MODEL_FILENAME: string;
  42627. /**
  42628. * Gamepad Id prefix used to identify this controller.
  42629. */
  42630. static readonly GAMEPAD_ID_PREFIX: string;
  42631. private readonly _buttonIndexToObservableNameMap;
  42632. /**
  42633. * Creates a new GearVRController from a gamepad
  42634. * @param vrGamepad the gamepad that the controller should be created from
  42635. */
  42636. constructor(vrGamepad: any);
  42637. /**
  42638. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42639. * @param scene scene in which to add meshes
  42640. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42641. */
  42642. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42643. /**
  42644. * Called once for each button that changed state since the last frame
  42645. * @param buttonIdx Which button index changed
  42646. * @param state New state of the button
  42647. * @param changes Which properties on the state changed since last frame
  42648. */
  42649. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42650. }
  42651. }
  42652. declare module "babylonjs/Gamepads/Controllers/genericController" {
  42653. import { Scene } from "babylonjs/scene";
  42654. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42655. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42656. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42657. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42658. /**
  42659. * Generic Controller
  42660. */
  42661. export class GenericController extends WebVRController {
  42662. /**
  42663. * Base Url for the controller model.
  42664. */
  42665. static readonly MODEL_BASE_URL: string;
  42666. /**
  42667. * File name for the controller model.
  42668. */
  42669. static readonly MODEL_FILENAME: string;
  42670. /**
  42671. * Creates a new GenericController from a gamepad
  42672. * @param vrGamepad the gamepad that the controller should be created from
  42673. */
  42674. constructor(vrGamepad: any);
  42675. /**
  42676. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42677. * @param scene scene in which to add meshes
  42678. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42679. */
  42680. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42681. /**
  42682. * Called once for each button that changed state since the last frame
  42683. * @param buttonIdx Which button index changed
  42684. * @param state New state of the button
  42685. * @param changes Which properties on the state changed since last frame
  42686. */
  42687. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42688. }
  42689. }
  42690. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  42691. import { Observable } from "babylonjs/Misc/observable";
  42692. import { Scene } from "babylonjs/scene";
  42693. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42694. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42695. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42696. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42697. /**
  42698. * Oculus Touch Controller
  42699. */
  42700. export class OculusTouchController extends WebVRController {
  42701. /**
  42702. * Base Url for the controller model.
  42703. */
  42704. static MODEL_BASE_URL: string;
  42705. /**
  42706. * File name for the left controller model.
  42707. */
  42708. static MODEL_LEFT_FILENAME: string;
  42709. /**
  42710. * File name for the right controller model.
  42711. */
  42712. static MODEL_RIGHT_FILENAME: string;
  42713. /**
  42714. * Fired when the secondary trigger on this controller is modified
  42715. */
  42716. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  42717. /**
  42718. * Fired when the thumb rest on this controller is modified
  42719. */
  42720. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  42721. /**
  42722. * Creates a new OculusTouchController from a gamepad
  42723. * @param vrGamepad the gamepad that the controller should be created from
  42724. */
  42725. constructor(vrGamepad: any);
  42726. /**
  42727. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42728. * @param scene scene in which to add meshes
  42729. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42730. */
  42731. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42732. /**
  42733. * Fired when the A button on this controller is modified
  42734. */
  42735. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42736. /**
  42737. * Fired when the B button on this controller is modified
  42738. */
  42739. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42740. /**
  42741. * Fired when the X button on this controller is modified
  42742. */
  42743. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42744. /**
  42745. * Fired when the Y button on this controller is modified
  42746. */
  42747. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42748. /**
  42749. * Called once for each button that changed state since the last frame
  42750. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  42751. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  42752. * 2) secondary trigger (same)
  42753. * 3) A (right) X (left), touch, pressed = value
  42754. * 4) B / Y
  42755. * 5) thumb rest
  42756. * @param buttonIdx Which button index changed
  42757. * @param state New state of the button
  42758. * @param changes Which properties on the state changed since last frame
  42759. */
  42760. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42761. }
  42762. }
  42763. declare module "babylonjs/Gamepads/Controllers/viveController" {
  42764. import { Scene } from "babylonjs/scene";
  42765. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42766. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42767. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42768. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42769. import { Observable } from "babylonjs/Misc/observable";
  42770. /**
  42771. * Vive Controller
  42772. */
  42773. export class ViveController extends WebVRController {
  42774. /**
  42775. * Base Url for the controller model.
  42776. */
  42777. static MODEL_BASE_URL: string;
  42778. /**
  42779. * File name for the controller model.
  42780. */
  42781. static MODEL_FILENAME: string;
  42782. /**
  42783. * Creates a new ViveController from a gamepad
  42784. * @param vrGamepad the gamepad that the controller should be created from
  42785. */
  42786. constructor(vrGamepad: any);
  42787. /**
  42788. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42789. * @param scene scene in which to add meshes
  42790. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42791. */
  42792. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42793. /**
  42794. * Fired when the left button on this controller is modified
  42795. */
  42796. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42797. /**
  42798. * Fired when the right button on this controller is modified
  42799. */
  42800. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42801. /**
  42802. * Fired when the menu button on this controller is modified
  42803. */
  42804. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42805. /**
  42806. * Called once for each button that changed state since the last frame
  42807. * Vive mapping:
  42808. * 0: touchpad
  42809. * 1: trigger
  42810. * 2: left AND right buttons
  42811. * 3: menu button
  42812. * @param buttonIdx Which button index changed
  42813. * @param state New state of the button
  42814. * @param changes Which properties on the state changed since last frame
  42815. */
  42816. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42817. }
  42818. }
  42819. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  42820. import { Observable } from "babylonjs/Misc/observable";
  42821. import { Scene } from "babylonjs/scene";
  42822. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42823. import { Ray } from "babylonjs/Culling/ray";
  42824. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42825. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42826. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42827. /**
  42828. * Defines the WindowsMotionController object that the state of the windows motion controller
  42829. */
  42830. export class WindowsMotionController extends WebVRController {
  42831. /**
  42832. * The base url used to load the left and right controller models
  42833. */
  42834. static MODEL_BASE_URL: string;
  42835. /**
  42836. * The name of the left controller model file
  42837. */
  42838. static MODEL_LEFT_FILENAME: string;
  42839. /**
  42840. * The name of the right controller model file
  42841. */
  42842. static MODEL_RIGHT_FILENAME: string;
  42843. /**
  42844. * The controller name prefix for this controller type
  42845. */
  42846. static readonly GAMEPAD_ID_PREFIX: string;
  42847. /**
  42848. * The controller id pattern for this controller type
  42849. */
  42850. private static readonly GAMEPAD_ID_PATTERN;
  42851. private _loadedMeshInfo;
  42852. private readonly _mapping;
  42853. /**
  42854. * Fired when the trackpad on this controller is clicked
  42855. */
  42856. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  42857. /**
  42858. * Fired when the trackpad on this controller is modified
  42859. */
  42860. onTrackpadValuesChangedObservable: Observable<StickValues>;
  42861. /**
  42862. * The current x and y values of this controller's trackpad
  42863. */
  42864. trackpad: StickValues;
  42865. /**
  42866. * Creates a new WindowsMotionController from a gamepad
  42867. * @param vrGamepad the gamepad that the controller should be created from
  42868. */
  42869. constructor(vrGamepad: any);
  42870. /**
  42871. * Fired when the trigger on this controller is modified
  42872. */
  42873. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42874. /**
  42875. * Fired when the menu button on this controller is modified
  42876. */
  42877. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42878. /**
  42879. * Fired when the grip button on this controller is modified
  42880. */
  42881. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42882. /**
  42883. * Fired when the thumbstick button on this controller is modified
  42884. */
  42885. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42886. /**
  42887. * Fired when the touchpad button on this controller is modified
  42888. */
  42889. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42890. /**
  42891. * Fired when the touchpad values on this controller are modified
  42892. */
  42893. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  42894. private _updateTrackpad;
  42895. /**
  42896. * Called once per frame by the engine.
  42897. */
  42898. update(): void;
  42899. /**
  42900. * Called once for each button that changed state since the last frame
  42901. * @param buttonIdx Which button index changed
  42902. * @param state New state of the button
  42903. * @param changes Which properties on the state changed since last frame
  42904. */
  42905. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42906. /**
  42907. * Moves the buttons on the controller mesh based on their current state
  42908. * @param buttonName the name of the button to move
  42909. * @param buttonValue the value of the button which determines the buttons new position
  42910. */
  42911. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  42912. /**
  42913. * Moves the axis on the controller mesh based on its current state
  42914. * @param axis the index of the axis
  42915. * @param axisValue the value of the axis which determines the meshes new position
  42916. * @hidden
  42917. */
  42918. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  42919. /**
  42920. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42921. * @param scene scene in which to add meshes
  42922. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42923. */
  42924. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  42925. /**
  42926. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  42927. * can be transformed by button presses and axes values, based on this._mapping.
  42928. *
  42929. * @param scene scene in which the meshes exist
  42930. * @param meshes list of meshes that make up the controller model to process
  42931. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  42932. */
  42933. private processModel;
  42934. private createMeshInfo;
  42935. /**
  42936. * Gets the ray of the controller in the direction the controller is pointing
  42937. * @param length the length the resulting ray should be
  42938. * @returns a ray in the direction the controller is pointing
  42939. */
  42940. getForwardRay(length?: number): Ray;
  42941. /**
  42942. * Disposes of the controller
  42943. */
  42944. dispose(): void;
  42945. }
  42946. }
  42947. declare module "babylonjs/Gamepads/Controllers/index" {
  42948. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  42949. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  42950. export * from "babylonjs/Gamepads/Controllers/genericController";
  42951. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  42952. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42953. export * from "babylonjs/Gamepads/Controllers/viveController";
  42954. export * from "babylonjs/Gamepads/Controllers/webVRController";
  42955. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  42956. }
  42957. declare module "babylonjs/Gamepads/index" {
  42958. export * from "babylonjs/Gamepads/Controllers/index";
  42959. export * from "babylonjs/Gamepads/gamepad";
  42960. export * from "babylonjs/Gamepads/gamepadManager";
  42961. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  42962. export * from "babylonjs/Gamepads/xboxGamepad";
  42963. }
  42964. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  42965. import { Observable } from "babylonjs/Misc/observable";
  42966. import { Nullable } from "babylonjs/types";
  42967. import { Vector3, Color3 } from "babylonjs/Maths/math";
  42968. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42969. import { Mesh } from "babylonjs/Meshes/mesh";
  42970. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  42971. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  42972. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  42973. /**
  42974. * Single axis scale gizmo
  42975. */
  42976. export class AxisScaleGizmo extends Gizmo {
  42977. private _coloredMaterial;
  42978. /**
  42979. * Drag behavior responsible for the gizmos dragging interactions
  42980. */
  42981. dragBehavior: PointerDragBehavior;
  42982. private _pointerObserver;
  42983. /**
  42984. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42985. */
  42986. snapDistance: number;
  42987. /**
  42988. * Event that fires each time the gizmo snaps to a new location.
  42989. * * snapDistance is the the change in distance
  42990. */
  42991. onSnapObservable: Observable<{
  42992. snapDistance: number;
  42993. }>;
  42994. /**
  42995. * If the scaling operation should be done on all axis (default: false)
  42996. */
  42997. uniformScaling: boolean;
  42998. /**
  42999. * Creates an AxisScaleGizmo
  43000. * @param gizmoLayer The utility layer the gizmo will be added to
  43001. * @param dragAxis The axis which the gizmo will be able to scale on
  43002. * @param color The color of the gizmo
  43003. */
  43004. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  43005. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43006. /**
  43007. * Disposes of the gizmo
  43008. */
  43009. dispose(): void;
  43010. /**
  43011. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  43012. * @param mesh The mesh to replace the default mesh of the gizmo
  43013. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  43014. */
  43015. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  43016. }
  43017. }
  43018. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  43019. import { Observable } from "babylonjs/Misc/observable";
  43020. import { Nullable } from "babylonjs/types";
  43021. import { Vector3, Color3 } from "babylonjs/Maths/math";
  43022. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43023. import { Mesh } from "babylonjs/Meshes/mesh";
  43024. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43025. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43026. import "babylonjs/Meshes/Builders/boxBuilder";
  43027. /**
  43028. * Bounding box gizmo
  43029. */
  43030. export class BoundingBoxGizmo extends Gizmo {
  43031. private _lineBoundingBox;
  43032. private _rotateSpheresParent;
  43033. private _scaleBoxesParent;
  43034. private _boundingDimensions;
  43035. private _renderObserver;
  43036. private _pointerObserver;
  43037. private _scaleDragSpeed;
  43038. private _tmpQuaternion;
  43039. private _tmpVector;
  43040. private _tmpRotationMatrix;
  43041. /**
  43042. * 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)
  43043. */
  43044. ignoreChildren: boolean;
  43045. /**
  43046. * 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)
  43047. */
  43048. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  43049. /**
  43050. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  43051. */
  43052. rotationSphereSize: number;
  43053. /**
  43054. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  43055. */
  43056. scaleBoxSize: number;
  43057. /**
  43058. * 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)
  43059. */
  43060. fixedDragMeshScreenSize: boolean;
  43061. /**
  43062. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  43063. */
  43064. fixedDragMeshScreenSizeDistanceFactor: number;
  43065. /**
  43066. * Fired when a rotation sphere or scale box is dragged
  43067. */
  43068. onDragStartObservable: Observable<{}>;
  43069. /**
  43070. * Fired when a scale box is dragged
  43071. */
  43072. onScaleBoxDragObservable: Observable<{}>;
  43073. /**
  43074. * Fired when a scale box drag is ended
  43075. */
  43076. onScaleBoxDragEndObservable: Observable<{}>;
  43077. /**
  43078. * Fired when a rotation sphere is dragged
  43079. */
  43080. onRotationSphereDragObservable: Observable<{}>;
  43081. /**
  43082. * Fired when a rotation sphere drag is ended
  43083. */
  43084. onRotationSphereDragEndObservable: Observable<{}>;
  43085. /**
  43086. * 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)
  43087. */
  43088. scalePivot: Nullable<Vector3>;
  43089. private _anchorMesh;
  43090. private _existingMeshScale;
  43091. private _dragMesh;
  43092. private pointerDragBehavior;
  43093. private coloredMaterial;
  43094. private hoverColoredMaterial;
  43095. /**
  43096. * Sets the color of the bounding box gizmo
  43097. * @param color the color to set
  43098. */
  43099. setColor(color: Color3): void;
  43100. /**
  43101. * Creates an BoundingBoxGizmo
  43102. * @param gizmoLayer The utility layer the gizmo will be added to
  43103. * @param color The color of the gizmo
  43104. */
  43105. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  43106. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43107. private _selectNode;
  43108. /**
  43109. * Updates the bounding box information for the Gizmo
  43110. */
  43111. updateBoundingBox(): void;
  43112. private _updateRotationSpheres;
  43113. private _updateScaleBoxes;
  43114. /**
  43115. * Enables rotation on the specified axis and disables rotation on the others
  43116. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  43117. */
  43118. setEnabledRotationAxis(axis: string): void;
  43119. /**
  43120. * Enables/disables scaling
  43121. * @param enable if scaling should be enabled
  43122. */
  43123. setEnabledScaling(enable: boolean): void;
  43124. private _updateDummy;
  43125. /**
  43126. * Enables a pointer drag behavior on the bounding box of the gizmo
  43127. */
  43128. enableDragBehavior(): void;
  43129. /**
  43130. * Disposes of the gizmo
  43131. */
  43132. dispose(): void;
  43133. /**
  43134. * 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)
  43135. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  43136. * @returns the bounding box mesh with the passed in mesh as a child
  43137. */
  43138. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  43139. /**
  43140. * CustomMeshes are not supported by this gizmo
  43141. * @param mesh The mesh to replace the default mesh of the gizmo
  43142. */
  43143. setCustomMesh(mesh: Mesh): void;
  43144. }
  43145. }
  43146. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  43147. import { Observable } from "babylonjs/Misc/observable";
  43148. import { Nullable } from "babylonjs/types";
  43149. import { Vector3, Color3 } from "babylonjs/Maths/math";
  43150. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43151. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  43152. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43153. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43154. import "babylonjs/Meshes/Builders/linesBuilder";
  43155. /**
  43156. * Single plane rotation gizmo
  43157. */
  43158. export class PlaneRotationGizmo extends Gizmo {
  43159. /**
  43160. * Drag behavior responsible for the gizmos dragging interactions
  43161. */
  43162. dragBehavior: PointerDragBehavior;
  43163. private _pointerObserver;
  43164. /**
  43165. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  43166. */
  43167. snapDistance: number;
  43168. /**
  43169. * Event that fires each time the gizmo snaps to a new location.
  43170. * * snapDistance is the the change in distance
  43171. */
  43172. onSnapObservable: Observable<{
  43173. snapDistance: number;
  43174. }>;
  43175. /**
  43176. * Creates a PlaneRotationGizmo
  43177. * @param gizmoLayer The utility layer the gizmo will be added to
  43178. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  43179. * @param color The color of the gizmo
  43180. * @param tessellation Amount of tessellation to be used when creating rotation circles
  43181. */
  43182. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  43183. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43184. /**
  43185. * Disposes of the gizmo
  43186. */
  43187. dispose(): void;
  43188. }
  43189. }
  43190. declare module "babylonjs/Gizmos/rotationGizmo" {
  43191. import { Observable } from "babylonjs/Misc/observable";
  43192. import { Nullable } from "babylonjs/types";
  43193. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43194. import { Mesh } from "babylonjs/Meshes/mesh";
  43195. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43196. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  43197. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43198. /**
  43199. * Gizmo that enables rotating a mesh along 3 axis
  43200. */
  43201. export class RotationGizmo extends Gizmo {
  43202. /**
  43203. * Internal gizmo used for interactions on the x axis
  43204. */
  43205. xGizmo: PlaneRotationGizmo;
  43206. /**
  43207. * Internal gizmo used for interactions on the y axis
  43208. */
  43209. yGizmo: PlaneRotationGizmo;
  43210. /**
  43211. * Internal gizmo used for interactions on the z axis
  43212. */
  43213. zGizmo: PlaneRotationGizmo;
  43214. /** Fires an event when any of it's sub gizmos are dragged */
  43215. onDragStartObservable: Observable<{}>;
  43216. /** Fires an event when any of it's sub gizmos are released from dragging */
  43217. onDragEndObservable: Observable<{}>;
  43218. attachedMesh: Nullable<AbstractMesh>;
  43219. /**
  43220. * Creates a RotationGizmo
  43221. * @param gizmoLayer The utility layer the gizmo will be added to
  43222. * @param tessellation Amount of tessellation to be used when creating rotation circles
  43223. */
  43224. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  43225. updateGizmoRotationToMatchAttachedMesh: boolean;
  43226. /**
  43227. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43228. */
  43229. snapDistance: number;
  43230. /**
  43231. * Ratio for the scale of the gizmo (Default: 1)
  43232. */
  43233. scaleRatio: number;
  43234. /**
  43235. * Disposes of the gizmo
  43236. */
  43237. dispose(): void;
  43238. /**
  43239. * CustomMeshes are not supported by this gizmo
  43240. * @param mesh The mesh to replace the default mesh of the gizmo
  43241. */
  43242. setCustomMesh(mesh: Mesh): void;
  43243. }
  43244. }
  43245. declare module "babylonjs/Gizmos/positionGizmo" {
  43246. import { Observable } from "babylonjs/Misc/observable";
  43247. import { Nullable } from "babylonjs/types";
  43248. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43249. import { Mesh } from "babylonjs/Meshes/mesh";
  43250. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43251. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  43252. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43253. /**
  43254. * Gizmo that enables dragging a mesh along 3 axis
  43255. */
  43256. export class PositionGizmo extends Gizmo {
  43257. /**
  43258. * Internal gizmo used for interactions on the x axis
  43259. */
  43260. xGizmo: AxisDragGizmo;
  43261. /**
  43262. * Internal gizmo used for interactions on the y axis
  43263. */
  43264. yGizmo: AxisDragGizmo;
  43265. /**
  43266. * Internal gizmo used for interactions on the z axis
  43267. */
  43268. zGizmo: AxisDragGizmo;
  43269. /** Fires an event when any of it's sub gizmos are dragged */
  43270. onDragStartObservable: Observable<{}>;
  43271. /** Fires an event when any of it's sub gizmos are released from dragging */
  43272. onDragEndObservable: Observable<{}>;
  43273. attachedMesh: Nullable<AbstractMesh>;
  43274. /**
  43275. * Creates a PositionGizmo
  43276. * @param gizmoLayer The utility layer the gizmo will be added to
  43277. */
  43278. constructor(gizmoLayer?: UtilityLayerRenderer);
  43279. updateGizmoRotationToMatchAttachedMesh: boolean;
  43280. /**
  43281. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43282. */
  43283. snapDistance: number;
  43284. /**
  43285. * Ratio for the scale of the gizmo (Default: 1)
  43286. */
  43287. scaleRatio: number;
  43288. /**
  43289. * Disposes of the gizmo
  43290. */
  43291. dispose(): void;
  43292. /**
  43293. * CustomMeshes are not supported by this gizmo
  43294. * @param mesh The mesh to replace the default mesh of the gizmo
  43295. */
  43296. setCustomMesh(mesh: Mesh): void;
  43297. }
  43298. }
  43299. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  43300. import { Scene } from "babylonjs/scene";
  43301. import { Color4, Vector4 } from "babylonjs/Maths/math";
  43302. import { Mesh } from "babylonjs/Meshes/mesh";
  43303. /**
  43304. * Class containing static functions to help procedurally build meshes
  43305. */
  43306. export class PolyhedronBuilder {
  43307. /**
  43308. * Creates a polyhedron mesh
  43309. * * 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
  43310. * * The parameter `size` (positive float, default 1) sets the polygon size
  43311. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  43312. * * 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`
  43313. * * 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
  43314. * * 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)`)
  43315. * * 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
  43316. * * 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
  43317. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43318. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  43319. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43320. * @param name defines the name of the mesh
  43321. * @param options defines the options used to create the mesh
  43322. * @param scene defines the hosting scene
  43323. * @returns the polyhedron mesh
  43324. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  43325. */
  43326. static CreatePolyhedron(name: string, options: {
  43327. type?: number;
  43328. size?: number;
  43329. sizeX?: number;
  43330. sizeY?: number;
  43331. sizeZ?: number;
  43332. custom?: any;
  43333. faceUV?: Vector4[];
  43334. faceColors?: Color4[];
  43335. flat?: boolean;
  43336. updatable?: boolean;
  43337. sideOrientation?: number;
  43338. frontUVs?: Vector4;
  43339. backUVs?: Vector4;
  43340. }, scene: Scene): Mesh;
  43341. }
  43342. }
  43343. declare module "babylonjs/Gizmos/scaleGizmo" {
  43344. import { Observable } from "babylonjs/Misc/observable";
  43345. import { Nullable } from "babylonjs/types";
  43346. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43347. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43348. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  43349. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43350. /**
  43351. * Gizmo that enables scaling a mesh along 3 axis
  43352. */
  43353. export class ScaleGizmo extends Gizmo {
  43354. /**
  43355. * Internal gizmo used for interactions on the x axis
  43356. */
  43357. xGizmo: AxisScaleGizmo;
  43358. /**
  43359. * Internal gizmo used for interactions on the y axis
  43360. */
  43361. yGizmo: AxisScaleGizmo;
  43362. /**
  43363. * Internal gizmo used for interactions on the z axis
  43364. */
  43365. zGizmo: AxisScaleGizmo;
  43366. /**
  43367. * Internal gizmo used to scale all axis equally
  43368. */
  43369. uniformScaleGizmo: AxisScaleGizmo;
  43370. /** Fires an event when any of it's sub gizmos are dragged */
  43371. onDragStartObservable: Observable<{}>;
  43372. /** Fires an event when any of it's sub gizmos are released from dragging */
  43373. onDragEndObservable: Observable<{}>;
  43374. attachedMesh: Nullable<AbstractMesh>;
  43375. /**
  43376. * Creates a ScaleGizmo
  43377. * @param gizmoLayer The utility layer the gizmo will be added to
  43378. */
  43379. constructor(gizmoLayer?: UtilityLayerRenderer);
  43380. updateGizmoRotationToMatchAttachedMesh: boolean;
  43381. /**
  43382. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43383. */
  43384. snapDistance: number;
  43385. /**
  43386. * Ratio for the scale of the gizmo (Default: 1)
  43387. */
  43388. scaleRatio: number;
  43389. /**
  43390. * Disposes of the gizmo
  43391. */
  43392. dispose(): void;
  43393. }
  43394. }
  43395. declare module "babylonjs/Gizmos/gizmoManager" {
  43396. import { Observable } from "babylonjs/Misc/observable";
  43397. import { Nullable } from "babylonjs/types";
  43398. import { Scene, IDisposable } from "babylonjs/scene";
  43399. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43400. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  43401. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  43402. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  43403. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  43404. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  43405. /**
  43406. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  43407. */
  43408. export class GizmoManager implements IDisposable {
  43409. private scene;
  43410. /**
  43411. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  43412. */
  43413. gizmos: {
  43414. positionGizmo: Nullable<PositionGizmo>;
  43415. rotationGizmo: Nullable<RotationGizmo>;
  43416. scaleGizmo: Nullable<ScaleGizmo>;
  43417. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  43418. };
  43419. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  43420. clearGizmoOnEmptyPointerEvent: boolean;
  43421. /** Fires an event when the manager is attached to a mesh */
  43422. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  43423. private _gizmosEnabled;
  43424. private _pointerObserver;
  43425. private _attachedMesh;
  43426. private _boundingBoxColor;
  43427. private _defaultUtilityLayer;
  43428. private _defaultKeepDepthUtilityLayer;
  43429. /**
  43430. * When bounding box gizmo is enabled, this can be used to track drag/end events
  43431. */
  43432. boundingBoxDragBehavior: SixDofDragBehavior;
  43433. /**
  43434. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  43435. */
  43436. attachableMeshes: Nullable<Array<AbstractMesh>>;
  43437. /**
  43438. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  43439. */
  43440. usePointerToAttachGizmos: boolean;
  43441. /**
  43442. * Instatiates a gizmo manager
  43443. * @param scene the scene to overlay the gizmos on top of
  43444. */
  43445. constructor(scene: Scene);
  43446. /**
  43447. * Attaches a set of gizmos to the specified mesh
  43448. * @param mesh The mesh the gizmo's should be attached to
  43449. */
  43450. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  43451. /**
  43452. * If the position gizmo is enabled
  43453. */
  43454. positionGizmoEnabled: boolean;
  43455. /**
  43456. * If the rotation gizmo is enabled
  43457. */
  43458. rotationGizmoEnabled: boolean;
  43459. /**
  43460. * If the scale gizmo is enabled
  43461. */
  43462. scaleGizmoEnabled: boolean;
  43463. /**
  43464. * If the boundingBox gizmo is enabled
  43465. */
  43466. boundingBoxGizmoEnabled: boolean;
  43467. /**
  43468. * Disposes of the gizmo manager
  43469. */
  43470. dispose(): void;
  43471. }
  43472. }
  43473. declare module "babylonjs/Gizmos/lightGizmo" {
  43474. import { Nullable } from "babylonjs/types";
  43475. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43476. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43477. import { Light } from "babylonjs/Lights/light";
  43478. /**
  43479. * Gizmo that enables viewing a light
  43480. */
  43481. export class LightGizmo extends Gizmo {
  43482. private _box;
  43483. /**
  43484. * Creates a LightGizmo
  43485. * @param gizmoLayer The utility layer the gizmo will be added to
  43486. */
  43487. constructor(gizmoLayer?: UtilityLayerRenderer);
  43488. private _light;
  43489. /**
  43490. * The light that the gizmo is attached to
  43491. */
  43492. light: Nullable<Light>;
  43493. /**
  43494. * @hidden
  43495. * Updates the gizmo to match the attached mesh's position/rotation
  43496. */
  43497. protected _update(): void;
  43498. }
  43499. }
  43500. declare module "babylonjs/Gizmos/index" {
  43501. export * from "babylonjs/Gizmos/axisDragGizmo";
  43502. export * from "babylonjs/Gizmos/axisScaleGizmo";
  43503. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  43504. export * from "babylonjs/Gizmos/gizmo";
  43505. export * from "babylonjs/Gizmos/gizmoManager";
  43506. export * from "babylonjs/Gizmos/planeRotationGizmo";
  43507. export * from "babylonjs/Gizmos/positionGizmo";
  43508. export * from "babylonjs/Gizmos/rotationGizmo";
  43509. export * from "babylonjs/Gizmos/scaleGizmo";
  43510. export * from "babylonjs/Gizmos/lightGizmo";
  43511. }
  43512. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  43513. /** @hidden */
  43514. export var backgroundFragmentDeclaration: {
  43515. name: string;
  43516. shader: string;
  43517. };
  43518. }
  43519. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  43520. /** @hidden */
  43521. export var backgroundUboDeclaration: {
  43522. name: string;
  43523. shader: string;
  43524. };
  43525. }
  43526. declare module "babylonjs/Shaders/background.fragment" {
  43527. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  43528. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  43529. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  43530. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  43531. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  43532. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  43533. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  43534. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  43535. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  43536. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  43537. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  43538. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  43539. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  43540. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  43541. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  43542. /** @hidden */
  43543. export var backgroundPixelShader: {
  43544. name: string;
  43545. shader: string;
  43546. };
  43547. }
  43548. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  43549. /** @hidden */
  43550. export var backgroundVertexDeclaration: {
  43551. name: string;
  43552. shader: string;
  43553. };
  43554. }
  43555. declare module "babylonjs/Shaders/background.vertex" {
  43556. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  43557. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  43558. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  43559. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  43560. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  43561. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  43562. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  43563. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  43564. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  43565. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  43566. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  43567. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  43568. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  43569. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  43570. /** @hidden */
  43571. export var backgroundVertexShader: {
  43572. name: string;
  43573. shader: string;
  43574. };
  43575. }
  43576. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  43577. import { Nullable, int, float } from "babylonjs/types";
  43578. import { Scene } from "babylonjs/scene";
  43579. import { Matrix, Vector3, Color3 } from "babylonjs/Maths/math";
  43580. import { SubMesh } from "babylonjs/Meshes/subMesh";
  43581. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43582. import { Mesh } from "babylonjs/Meshes/mesh";
  43583. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  43584. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  43585. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  43586. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  43587. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  43588. import "babylonjs/Shaders/background.fragment";
  43589. import "babylonjs/Shaders/background.vertex";
  43590. /**
  43591. * Background material used to create an efficient environement around your scene.
  43592. */
  43593. export class BackgroundMaterial extends PushMaterial {
  43594. /**
  43595. * Standard reflectance value at parallel view angle.
  43596. */
  43597. static StandardReflectance0: number;
  43598. /**
  43599. * Standard reflectance value at grazing angle.
  43600. */
  43601. static StandardReflectance90: number;
  43602. protected _primaryColor: Color3;
  43603. /**
  43604. * Key light Color (multiply against the environement texture)
  43605. */
  43606. primaryColor: Color3;
  43607. protected __perceptualColor: Nullable<Color3>;
  43608. /**
  43609. * Experimental Internal Use Only.
  43610. *
  43611. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  43612. * This acts as a helper to set the primary color to a more "human friendly" value.
  43613. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  43614. * output color as close as possible from the chosen value.
  43615. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  43616. * part of lighting setup.)
  43617. */
  43618. _perceptualColor: Nullable<Color3>;
  43619. protected _primaryColorShadowLevel: float;
  43620. /**
  43621. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  43622. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  43623. */
  43624. primaryColorShadowLevel: float;
  43625. protected _primaryColorHighlightLevel: float;
  43626. /**
  43627. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  43628. * The primary color is used at the level chosen to define what the white area would look.
  43629. */
  43630. primaryColorHighlightLevel: float;
  43631. protected _reflectionTexture: Nullable<BaseTexture>;
  43632. /**
  43633. * Reflection Texture used in the material.
  43634. * Should be author in a specific way for the best result (refer to the documentation).
  43635. */
  43636. reflectionTexture: Nullable<BaseTexture>;
  43637. protected _reflectionBlur: float;
  43638. /**
  43639. * Reflection Texture level of blur.
  43640. *
  43641. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  43642. * texture twice.
  43643. */
  43644. reflectionBlur: float;
  43645. protected _diffuseTexture: Nullable<BaseTexture>;
  43646. /**
  43647. * Diffuse Texture used in the material.
  43648. * Should be author in a specific way for the best result (refer to the documentation).
  43649. */
  43650. diffuseTexture: Nullable<BaseTexture>;
  43651. protected _shadowLights: Nullable<IShadowLight[]>;
  43652. /**
  43653. * Specify the list of lights casting shadow on the material.
  43654. * All scene shadow lights will be included if null.
  43655. */
  43656. shadowLights: Nullable<IShadowLight[]>;
  43657. protected _shadowLevel: float;
  43658. /**
  43659. * Helps adjusting the shadow to a softer level if required.
  43660. * 0 means black shadows and 1 means no shadows.
  43661. */
  43662. shadowLevel: float;
  43663. protected _sceneCenter: Vector3;
  43664. /**
  43665. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  43666. * It is usually zero but might be interesting to modify according to your setup.
  43667. */
  43668. sceneCenter: Vector3;
  43669. protected _opacityFresnel: boolean;
  43670. /**
  43671. * This helps specifying that the material is falling off to the sky box at grazing angle.
  43672. * This helps ensuring a nice transition when the camera goes under the ground.
  43673. */
  43674. opacityFresnel: boolean;
  43675. protected _reflectionFresnel: boolean;
  43676. /**
  43677. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  43678. * This helps adding a mirror texture on the ground.
  43679. */
  43680. reflectionFresnel: boolean;
  43681. protected _reflectionFalloffDistance: number;
  43682. /**
  43683. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  43684. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  43685. */
  43686. reflectionFalloffDistance: number;
  43687. protected _reflectionAmount: number;
  43688. /**
  43689. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  43690. */
  43691. reflectionAmount: number;
  43692. protected _reflectionReflectance0: number;
  43693. /**
  43694. * This specifies the weight of the reflection at grazing angle.
  43695. */
  43696. reflectionReflectance0: number;
  43697. protected _reflectionReflectance90: number;
  43698. /**
  43699. * This specifies the weight of the reflection at a perpendicular point of view.
  43700. */
  43701. reflectionReflectance90: number;
  43702. /**
  43703. * Sets the reflection reflectance fresnel values according to the default standard
  43704. * empirically know to work well :-)
  43705. */
  43706. reflectionStandardFresnelWeight: number;
  43707. protected _useRGBColor: boolean;
  43708. /**
  43709. * Helps to directly use the maps channels instead of their level.
  43710. */
  43711. useRGBColor: boolean;
  43712. protected _enableNoise: boolean;
  43713. /**
  43714. * This helps reducing the banding effect that could occur on the background.
  43715. */
  43716. enableNoise: boolean;
  43717. /**
  43718. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  43719. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  43720. * Recommended to be keep at 1.0 except for special cases.
  43721. */
  43722. fovMultiplier: number;
  43723. private _fovMultiplier;
  43724. /**
  43725. * Enable the FOV adjustment feature controlled by fovMultiplier.
  43726. */
  43727. useEquirectangularFOV: boolean;
  43728. private _maxSimultaneousLights;
  43729. /**
  43730. * Number of Simultaneous lights allowed on the material.
  43731. */
  43732. maxSimultaneousLights: int;
  43733. /**
  43734. * Default configuration related to image processing available in the Background Material.
  43735. */
  43736. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  43737. /**
  43738. * Keep track of the image processing observer to allow dispose and replace.
  43739. */
  43740. private _imageProcessingObserver;
  43741. /**
  43742. * Attaches a new image processing configuration to the PBR Material.
  43743. * @param configuration (if null the scene configuration will be use)
  43744. */
  43745. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  43746. /**
  43747. * Gets the image processing configuration used either in this material.
  43748. */
  43749. /**
  43750. * Sets the Default image processing configuration used either in the this material.
  43751. *
  43752. * If sets to null, the scene one is in use.
  43753. */
  43754. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  43755. /**
  43756. * Gets wether the color curves effect is enabled.
  43757. */
  43758. /**
  43759. * Sets wether the color curves effect is enabled.
  43760. */
  43761. cameraColorCurvesEnabled: boolean;
  43762. /**
  43763. * Gets wether the color grading effect is enabled.
  43764. */
  43765. /**
  43766. * Gets wether the color grading effect is enabled.
  43767. */
  43768. cameraColorGradingEnabled: boolean;
  43769. /**
  43770. * Gets wether tonemapping is enabled or not.
  43771. */
  43772. /**
  43773. * Sets wether tonemapping is enabled or not
  43774. */
  43775. cameraToneMappingEnabled: boolean;
  43776. /**
  43777. * The camera exposure used on this material.
  43778. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  43779. * This corresponds to a photographic exposure.
  43780. */
  43781. /**
  43782. * The camera exposure used on this material.
  43783. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  43784. * This corresponds to a photographic exposure.
  43785. */
  43786. cameraExposure: float;
  43787. /**
  43788. * Gets The camera contrast used on this material.
  43789. */
  43790. /**
  43791. * Sets The camera contrast used on this material.
  43792. */
  43793. cameraContrast: float;
  43794. /**
  43795. * Gets the Color Grading 2D Lookup Texture.
  43796. */
  43797. /**
  43798. * Sets the Color Grading 2D Lookup Texture.
  43799. */
  43800. cameraColorGradingTexture: Nullable<BaseTexture>;
  43801. /**
  43802. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  43803. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  43804. * 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;
  43805. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  43806. */
  43807. /**
  43808. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  43809. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  43810. * 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;
  43811. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  43812. */
  43813. cameraColorCurves: Nullable<ColorCurves>;
  43814. /**
  43815. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  43816. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  43817. */
  43818. switchToBGR: boolean;
  43819. private _renderTargets;
  43820. private _reflectionControls;
  43821. private _white;
  43822. private _primaryShadowColor;
  43823. private _primaryHighlightColor;
  43824. /**
  43825. * Instantiates a Background Material in the given scene
  43826. * @param name The friendly name of the material
  43827. * @param scene The scene to add the material to
  43828. */
  43829. constructor(name: string, scene: Scene);
  43830. /**
  43831. * Gets a boolean indicating that current material needs to register RTT
  43832. */
  43833. readonly hasRenderTargetTextures: boolean;
  43834. /**
  43835. * The entire material has been created in order to prevent overdraw.
  43836. * @returns false
  43837. */
  43838. needAlphaTesting(): boolean;
  43839. /**
  43840. * The entire material has been created in order to prevent overdraw.
  43841. * @returns true if blending is enable
  43842. */
  43843. needAlphaBlending(): boolean;
  43844. /**
  43845. * Checks wether the material is ready to be rendered for a given mesh.
  43846. * @param mesh The mesh to render
  43847. * @param subMesh The submesh to check against
  43848. * @param useInstances Specify wether or not the material is used with instances
  43849. * @returns true if all the dependencies are ready (Textures, Effects...)
  43850. */
  43851. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  43852. /**
  43853. * Compute the primary color according to the chosen perceptual color.
  43854. */
  43855. private _computePrimaryColorFromPerceptualColor;
  43856. /**
  43857. * Compute the highlights and shadow colors according to their chosen levels.
  43858. */
  43859. private _computePrimaryColors;
  43860. /**
  43861. * Build the uniform buffer used in the material.
  43862. */
  43863. buildUniformLayout(): void;
  43864. /**
  43865. * Unbind the material.
  43866. */
  43867. unbind(): void;
  43868. /**
  43869. * Bind only the world matrix to the material.
  43870. * @param world The world matrix to bind.
  43871. */
  43872. bindOnlyWorldMatrix(world: Matrix): void;
  43873. /**
  43874. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  43875. * @param world The world matrix to bind.
  43876. * @param subMesh The submesh to bind for.
  43877. */
  43878. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  43879. /**
  43880. * Dispose the material.
  43881. * @param forceDisposeEffect Force disposal of the associated effect.
  43882. * @param forceDisposeTextures Force disposal of the associated textures.
  43883. */
  43884. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  43885. /**
  43886. * Clones the material.
  43887. * @param name The cloned name.
  43888. * @returns The cloned material.
  43889. */
  43890. clone(name: string): BackgroundMaterial;
  43891. /**
  43892. * Serializes the current material to its JSON representation.
  43893. * @returns The JSON representation.
  43894. */
  43895. serialize(): any;
  43896. /**
  43897. * Gets the class name of the material
  43898. * @returns "BackgroundMaterial"
  43899. */
  43900. getClassName(): string;
  43901. /**
  43902. * Parse a JSON input to create back a background material.
  43903. * @param source The JSON data to parse
  43904. * @param scene The scene to create the parsed material in
  43905. * @param rootUrl The root url of the assets the material depends upon
  43906. * @returns the instantiated BackgroundMaterial.
  43907. */
  43908. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  43909. }
  43910. }
  43911. declare module "babylonjs/Helpers/environmentHelper" {
  43912. import { Observable } from "babylonjs/Misc/observable";
  43913. import { Nullable } from "babylonjs/types";
  43914. import { Scene } from "babylonjs/scene";
  43915. import { Vector3, Color3 } from "babylonjs/Maths/math";
  43916. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43917. import { Mesh } from "babylonjs/Meshes/mesh";
  43918. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  43919. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  43920. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  43921. import "babylonjs/Meshes/Builders/planeBuilder";
  43922. import "babylonjs/Meshes/Builders/boxBuilder";
  43923. /**
  43924. * Represents the different options available during the creation of
  43925. * a Environment helper.
  43926. *
  43927. * This can control the default ground, skybox and image processing setup of your scene.
  43928. */
  43929. export interface IEnvironmentHelperOptions {
  43930. /**
  43931. * Specifies wether or not to create a ground.
  43932. * True by default.
  43933. */
  43934. createGround: boolean;
  43935. /**
  43936. * Specifies the ground size.
  43937. * 15 by default.
  43938. */
  43939. groundSize: number;
  43940. /**
  43941. * The texture used on the ground for the main color.
  43942. * Comes from the BabylonJS CDN by default.
  43943. *
  43944. * Remarks: Can be either a texture or a url.
  43945. */
  43946. groundTexture: string | BaseTexture;
  43947. /**
  43948. * The color mixed in the ground texture by default.
  43949. * BabylonJS clearColor by default.
  43950. */
  43951. groundColor: Color3;
  43952. /**
  43953. * Specifies the ground opacity.
  43954. * 1 by default.
  43955. */
  43956. groundOpacity: number;
  43957. /**
  43958. * Enables the ground to receive shadows.
  43959. * True by default.
  43960. */
  43961. enableGroundShadow: boolean;
  43962. /**
  43963. * Helps preventing the shadow to be fully black on the ground.
  43964. * 0.5 by default.
  43965. */
  43966. groundShadowLevel: number;
  43967. /**
  43968. * Creates a mirror texture attach to the ground.
  43969. * false by default.
  43970. */
  43971. enableGroundMirror: boolean;
  43972. /**
  43973. * Specifies the ground mirror size ratio.
  43974. * 0.3 by default as the default kernel is 64.
  43975. */
  43976. groundMirrorSizeRatio: number;
  43977. /**
  43978. * Specifies the ground mirror blur kernel size.
  43979. * 64 by default.
  43980. */
  43981. groundMirrorBlurKernel: number;
  43982. /**
  43983. * Specifies the ground mirror visibility amount.
  43984. * 1 by default
  43985. */
  43986. groundMirrorAmount: number;
  43987. /**
  43988. * Specifies the ground mirror reflectance weight.
  43989. * This uses the standard weight of the background material to setup the fresnel effect
  43990. * of the mirror.
  43991. * 1 by default.
  43992. */
  43993. groundMirrorFresnelWeight: number;
  43994. /**
  43995. * Specifies the ground mirror Falloff distance.
  43996. * This can helps reducing the size of the reflection.
  43997. * 0 by Default.
  43998. */
  43999. groundMirrorFallOffDistance: number;
  44000. /**
  44001. * Specifies the ground mirror texture type.
  44002. * Unsigned Int by Default.
  44003. */
  44004. groundMirrorTextureType: number;
  44005. /**
  44006. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  44007. * the shown objects.
  44008. */
  44009. groundYBias: number;
  44010. /**
  44011. * Specifies wether or not to create a skybox.
  44012. * True by default.
  44013. */
  44014. createSkybox: boolean;
  44015. /**
  44016. * Specifies the skybox size.
  44017. * 20 by default.
  44018. */
  44019. skyboxSize: number;
  44020. /**
  44021. * The texture used on the skybox for the main color.
  44022. * Comes from the BabylonJS CDN by default.
  44023. *
  44024. * Remarks: Can be either a texture or a url.
  44025. */
  44026. skyboxTexture: string | BaseTexture;
  44027. /**
  44028. * The color mixed in the skybox texture by default.
  44029. * BabylonJS clearColor by default.
  44030. */
  44031. skyboxColor: Color3;
  44032. /**
  44033. * The background rotation around the Y axis of the scene.
  44034. * This helps aligning the key lights of your scene with the background.
  44035. * 0 by default.
  44036. */
  44037. backgroundYRotation: number;
  44038. /**
  44039. * Compute automatically the size of the elements to best fit with the scene.
  44040. */
  44041. sizeAuto: boolean;
  44042. /**
  44043. * Default position of the rootMesh if autoSize is not true.
  44044. */
  44045. rootPosition: Vector3;
  44046. /**
  44047. * Sets up the image processing in the scene.
  44048. * true by default.
  44049. */
  44050. setupImageProcessing: boolean;
  44051. /**
  44052. * The texture used as your environment texture in the scene.
  44053. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  44054. *
  44055. * Remarks: Can be either a texture or a url.
  44056. */
  44057. environmentTexture: string | BaseTexture;
  44058. /**
  44059. * The value of the exposure to apply to the scene.
  44060. * 0.6 by default if setupImageProcessing is true.
  44061. */
  44062. cameraExposure: number;
  44063. /**
  44064. * The value of the contrast to apply to the scene.
  44065. * 1.6 by default if setupImageProcessing is true.
  44066. */
  44067. cameraContrast: number;
  44068. /**
  44069. * Specifies wether or not tonemapping should be enabled in the scene.
  44070. * true by default if setupImageProcessing is true.
  44071. */
  44072. toneMappingEnabled: boolean;
  44073. }
  44074. /**
  44075. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  44076. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  44077. * It also helps with the default setup of your imageProcessing configuration.
  44078. */
  44079. export class EnvironmentHelper {
  44080. /**
  44081. * Default ground texture URL.
  44082. */
  44083. private static _groundTextureCDNUrl;
  44084. /**
  44085. * Default skybox texture URL.
  44086. */
  44087. private static _skyboxTextureCDNUrl;
  44088. /**
  44089. * Default environment texture URL.
  44090. */
  44091. private static _environmentTextureCDNUrl;
  44092. /**
  44093. * Creates the default options for the helper.
  44094. */
  44095. private static _getDefaultOptions;
  44096. private _rootMesh;
  44097. /**
  44098. * Gets the root mesh created by the helper.
  44099. */
  44100. readonly rootMesh: Mesh;
  44101. private _skybox;
  44102. /**
  44103. * Gets the skybox created by the helper.
  44104. */
  44105. readonly skybox: Nullable<Mesh>;
  44106. private _skyboxTexture;
  44107. /**
  44108. * Gets the skybox texture created by the helper.
  44109. */
  44110. readonly skyboxTexture: Nullable<BaseTexture>;
  44111. private _skyboxMaterial;
  44112. /**
  44113. * Gets the skybox material created by the helper.
  44114. */
  44115. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  44116. private _ground;
  44117. /**
  44118. * Gets the ground mesh created by the helper.
  44119. */
  44120. readonly ground: Nullable<Mesh>;
  44121. private _groundTexture;
  44122. /**
  44123. * Gets the ground texture created by the helper.
  44124. */
  44125. readonly groundTexture: Nullable<BaseTexture>;
  44126. private _groundMirror;
  44127. /**
  44128. * Gets the ground mirror created by the helper.
  44129. */
  44130. readonly groundMirror: Nullable<MirrorTexture>;
  44131. /**
  44132. * Gets the ground mirror render list to helps pushing the meshes
  44133. * you wish in the ground reflection.
  44134. */
  44135. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  44136. private _groundMaterial;
  44137. /**
  44138. * Gets the ground material created by the helper.
  44139. */
  44140. readonly groundMaterial: Nullable<BackgroundMaterial>;
  44141. /**
  44142. * Stores the creation options.
  44143. */
  44144. private readonly _scene;
  44145. private _options;
  44146. /**
  44147. * This observable will be notified with any error during the creation of the environment,
  44148. * mainly texture creation errors.
  44149. */
  44150. onErrorObservable: Observable<{
  44151. message?: string;
  44152. exception?: any;
  44153. }>;
  44154. /**
  44155. * constructor
  44156. * @param options Defines the options we want to customize the helper
  44157. * @param scene The scene to add the material to
  44158. */
  44159. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  44160. /**
  44161. * Updates the background according to the new options
  44162. * @param options
  44163. */
  44164. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  44165. /**
  44166. * Sets the primary color of all the available elements.
  44167. * @param color the main color to affect to the ground and the background
  44168. */
  44169. setMainColor(color: Color3): void;
  44170. /**
  44171. * Setup the image processing according to the specified options.
  44172. */
  44173. private _setupImageProcessing;
  44174. /**
  44175. * Setup the environment texture according to the specified options.
  44176. */
  44177. private _setupEnvironmentTexture;
  44178. /**
  44179. * Setup the background according to the specified options.
  44180. */
  44181. private _setupBackground;
  44182. /**
  44183. * Get the scene sizes according to the setup.
  44184. */
  44185. private _getSceneSize;
  44186. /**
  44187. * Setup the ground according to the specified options.
  44188. */
  44189. private _setupGround;
  44190. /**
  44191. * Setup the ground material according to the specified options.
  44192. */
  44193. private _setupGroundMaterial;
  44194. /**
  44195. * Setup the ground diffuse texture according to the specified options.
  44196. */
  44197. private _setupGroundDiffuseTexture;
  44198. /**
  44199. * Setup the ground mirror texture according to the specified options.
  44200. */
  44201. private _setupGroundMirrorTexture;
  44202. /**
  44203. * Setup the ground to receive the mirror texture.
  44204. */
  44205. private _setupMirrorInGroundMaterial;
  44206. /**
  44207. * Setup the skybox according to the specified options.
  44208. */
  44209. private _setupSkybox;
  44210. /**
  44211. * Setup the skybox material according to the specified options.
  44212. */
  44213. private _setupSkyboxMaterial;
  44214. /**
  44215. * Setup the skybox reflection texture according to the specified options.
  44216. */
  44217. private _setupSkyboxReflectionTexture;
  44218. private _errorHandler;
  44219. /**
  44220. * Dispose all the elements created by the Helper.
  44221. */
  44222. dispose(): void;
  44223. }
  44224. }
  44225. declare module "babylonjs/Helpers/photoDome" {
  44226. import { Observable } from "babylonjs/Misc/observable";
  44227. import { Nullable } from "babylonjs/types";
  44228. import { Scene } from "babylonjs/scene";
  44229. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44230. import { Mesh } from "babylonjs/Meshes/mesh";
  44231. import { Texture } from "babylonjs/Materials/Textures/texture";
  44232. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  44233. import "babylonjs/Meshes/Builders/sphereBuilder";
  44234. /**
  44235. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  44236. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  44237. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  44238. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  44239. */
  44240. export class PhotoDome extends TransformNode {
  44241. private _useDirectMapping;
  44242. /**
  44243. * The texture being displayed on the sphere
  44244. */
  44245. protected _photoTexture: Texture;
  44246. /**
  44247. * Gets or sets the texture being displayed on the sphere
  44248. */
  44249. photoTexture: Texture;
  44250. /**
  44251. * Observable raised when an error occured while loading the 360 image
  44252. */
  44253. onLoadErrorObservable: Observable<string>;
  44254. /**
  44255. * The skybox material
  44256. */
  44257. protected _material: BackgroundMaterial;
  44258. /**
  44259. * The surface used for the skybox
  44260. */
  44261. protected _mesh: Mesh;
  44262. /**
  44263. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  44264. * Also see the options.resolution property.
  44265. */
  44266. fovMultiplier: number;
  44267. /**
  44268. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  44269. * @param name Element's name, child elements will append suffixes for their own names.
  44270. * @param urlsOfPhoto defines the url of the photo to display
  44271. * @param options defines an object containing optional or exposed sub element properties
  44272. * @param onError defines a callback called when an error occured while loading the texture
  44273. */
  44274. constructor(name: string, urlOfPhoto: string, options: {
  44275. resolution?: number;
  44276. size?: number;
  44277. useDirectMapping?: boolean;
  44278. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  44279. /**
  44280. * Releases resources associated with this node.
  44281. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  44282. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  44283. */
  44284. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  44285. }
  44286. }
  44287. declare module "babylonjs/Misc/textureTools" {
  44288. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44289. import { Texture } from "babylonjs/Materials/Textures/texture";
  44290. import { Scene } from "babylonjs/scene";
  44291. /**
  44292. * Class used to host texture specific utilities
  44293. */
  44294. export class TextureTools {
  44295. /**
  44296. * Uses the GPU to create a copy texture rescaled at a given size
  44297. * @param texture Texture to copy from
  44298. * @param width defines the desired width
  44299. * @param height defines the desired height
  44300. * @param useBilinearMode defines if bilinear mode has to be used
  44301. * @return the generated texture
  44302. */
  44303. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  44304. /**
  44305. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  44306. * @param scene defines the hosting scene
  44307. * @returns the environment BRDF texture
  44308. */
  44309. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  44310. private static _environmentBRDFBase64Texture;
  44311. }
  44312. }
  44313. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  44314. import { Nullable } from "babylonjs/types";
  44315. import { IAnimatable } from "babylonjs/Misc/tools";
  44316. import { Color3 } from "babylonjs/Maths/math";
  44317. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44318. import { EffectFallbacks } from "babylonjs/Materials/effect";
  44319. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  44320. import { Engine } from "babylonjs/Engines/engine";
  44321. import { Scene } from "babylonjs/scene";
  44322. /**
  44323. * @hidden
  44324. */
  44325. export interface IMaterialClearCoatDefines {
  44326. CLEARCOAT: boolean;
  44327. CLEARCOAT_DEFAULTIOR: boolean;
  44328. CLEARCOAT_TEXTURE: boolean;
  44329. CLEARCOAT_TEXTUREDIRECTUV: number;
  44330. CLEARCOAT_BUMP: boolean;
  44331. CLEARCOAT_BUMPDIRECTUV: number;
  44332. CLEARCOAT_TINT: boolean;
  44333. CLEARCOAT_TINT_TEXTURE: boolean;
  44334. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  44335. /** @hidden */
  44336. _areTexturesDirty: boolean;
  44337. }
  44338. /**
  44339. * Define the code related to the clear coat parameters of the pbr material.
  44340. */
  44341. export class PBRClearCoatConfiguration {
  44342. /**
  44343. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  44344. * The default fits with a polyurethane material.
  44345. */
  44346. private static readonly _DefaultIndiceOfRefraction;
  44347. private _isEnabled;
  44348. /**
  44349. * Defines if the clear coat is enabled in the material.
  44350. */
  44351. isEnabled: boolean;
  44352. /**
  44353. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  44354. */
  44355. intensity: number;
  44356. /**
  44357. * Defines the clear coat layer roughness.
  44358. */
  44359. roughness: number;
  44360. private _indiceOfRefraction;
  44361. /**
  44362. * Defines the indice of refraction of the clear coat.
  44363. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  44364. * The default fits with a polyurethane material.
  44365. * Changing the default value is more performance intensive.
  44366. */
  44367. indiceOfRefraction: number;
  44368. private _texture;
  44369. /**
  44370. * Stores the clear coat values in a texture.
  44371. */
  44372. texture: Nullable<BaseTexture>;
  44373. private _bumpTexture;
  44374. /**
  44375. * Define the clear coat specific bump texture.
  44376. */
  44377. bumpTexture: Nullable<BaseTexture>;
  44378. private _isTintEnabled;
  44379. /**
  44380. * Defines if the clear coat tint is enabled in the material.
  44381. */
  44382. isTintEnabled: boolean;
  44383. /**
  44384. * Defines if the clear coat tint is enabled in the material.
  44385. * This is only use if tint is enabled
  44386. */
  44387. tintColor: Color3;
  44388. /**
  44389. * Defines if the distance at which the tint color should be found in the
  44390. * clear coat media.
  44391. * This is only use if tint is enabled
  44392. */
  44393. tintColorAtDistance: number;
  44394. /**
  44395. * Defines the clear coat layer thickness.
  44396. * This is only use if tint is enabled
  44397. */
  44398. tintThickness: number;
  44399. private _tintTexture;
  44400. /**
  44401. * Stores the clear tint values in a texture.
  44402. * rgb is tint
  44403. * a is a thickness factor
  44404. */
  44405. tintTexture: Nullable<BaseTexture>;
  44406. /** @hidden */
  44407. private _internalMarkAllSubMeshesAsTexturesDirty;
  44408. /** @hidden */
  44409. _markAllSubMeshesAsTexturesDirty(): void;
  44410. /**
  44411. * Instantiate a new istance of clear coat configuration.
  44412. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  44413. */
  44414. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  44415. /**
  44416. * Specifies that the submesh is ready to be used.
  44417. * @param defines the list of "defines" to update.
  44418. * @param scene defines the scene the material belongs to.
  44419. * @param engine defines the engine the material belongs to.
  44420. * @param disableBumpMap defines wether the material disables bump or not.
  44421. * @returns - boolean indicating that the submesh is ready or not.
  44422. */
  44423. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  44424. /**
  44425. * Checks to see if a texture is used in the material.
  44426. * @param defines the list of "defines" to update.
  44427. * @param scene defines the scene to the material belongs to.
  44428. */
  44429. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  44430. /**
  44431. * Binds the material data.
  44432. * @param uniformBuffer defines the Uniform buffer to fill in.
  44433. * @param scene defines the scene the material belongs to.
  44434. * @param engine defines the engine the material belongs to.
  44435. * @param disableBumpMap defines wether the material disables bump or not.
  44436. * @param isFrozen defines wether the material is frozen or not.
  44437. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  44438. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  44439. */
  44440. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  44441. /**
  44442. * Checks to see if a texture is used in the material.
  44443. * @param texture - Base texture to use.
  44444. * @returns - Boolean specifying if a texture is used in the material.
  44445. */
  44446. hasTexture(texture: BaseTexture): boolean;
  44447. /**
  44448. * Returns an array of the actively used textures.
  44449. * @param activeTextures Array of BaseTextures
  44450. */
  44451. getActiveTextures(activeTextures: BaseTexture[]): void;
  44452. /**
  44453. * Returns the animatable textures.
  44454. * @param animatables Array of animatable textures.
  44455. */
  44456. getAnimatables(animatables: IAnimatable[]): void;
  44457. /**
  44458. * Disposes the resources of the material.
  44459. * @param forceDisposeTextures - Forces the disposal of all textures.
  44460. */
  44461. dispose(forceDisposeTextures?: boolean): void;
  44462. /**
  44463. * Get the current class name of the texture useful for serialization or dynamic coding.
  44464. * @returns "PBRClearCoatConfiguration"
  44465. */
  44466. getClassName(): string;
  44467. /**
  44468. * Add fallbacks to the effect fallbacks list.
  44469. * @param defines defines the Base texture to use.
  44470. * @param fallbacks defines the current fallback list.
  44471. * @param currentRank defines the current fallback rank.
  44472. * @returns the new fallback rank.
  44473. */
  44474. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  44475. /**
  44476. * Add the required uniforms to the current list.
  44477. * @param uniforms defines the current uniform list.
  44478. */
  44479. static AddUniforms(uniforms: string[]): void;
  44480. /**
  44481. * Add the required samplers to the current list.
  44482. * @param samplers defines the current sampler list.
  44483. */
  44484. static AddSamplers(samplers: string[]): void;
  44485. /**
  44486. * Add the required uniforms to the current buffer.
  44487. * @param uniformBuffer defines the current uniform buffer.
  44488. */
  44489. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  44490. /**
  44491. * Makes a duplicate of the current configuration into another one.
  44492. * @param clearCoatConfiguration define the config where to copy the info
  44493. */
  44494. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  44495. /**
  44496. * Serializes this clear coat configuration.
  44497. * @returns - An object with the serialized config.
  44498. */
  44499. serialize(): any;
  44500. /**
  44501. * Parses a Clear Coat Configuration from a serialized object.
  44502. * @param source - Serialized object.
  44503. */
  44504. parse(source: any): void;
  44505. }
  44506. }
  44507. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  44508. import { EffectFallbacks } from "babylonjs/Materials/effect";
  44509. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  44510. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44511. import { Vector2 } from "babylonjs/Maths/math";
  44512. import { Scene } from "babylonjs/scene";
  44513. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44514. import { IAnimatable } from "babylonjs/Misc/tools";
  44515. import { Nullable } from "babylonjs/types";
  44516. /**
  44517. * @hidden
  44518. */
  44519. export interface IMaterialAnisotropicDefines {
  44520. ANISOTROPIC: boolean;
  44521. ANISOTROPIC_TEXTURE: boolean;
  44522. ANISOTROPIC_TEXTUREDIRECTUV: number;
  44523. MAINUV1: boolean;
  44524. _areTexturesDirty: boolean;
  44525. _needUVs: boolean;
  44526. }
  44527. /**
  44528. * Define the code related to the anisotropic parameters of the pbr material.
  44529. */
  44530. export class PBRAnisotropicConfiguration {
  44531. private _isEnabled;
  44532. /**
  44533. * Defines if the anisotropy is enabled in the material.
  44534. */
  44535. isEnabled: boolean;
  44536. /**
  44537. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  44538. */
  44539. intensity: number;
  44540. /**
  44541. * Defines if the effect is along the tangents, bitangents or in between.
  44542. * By default, the effect is "strectching" the highlights along the tangents.
  44543. */
  44544. direction: Vector2;
  44545. private _texture;
  44546. /**
  44547. * Stores the anisotropy values in a texture.
  44548. * rg is direction (like normal from -1 to 1)
  44549. * b is a intensity
  44550. */
  44551. texture: Nullable<BaseTexture>;
  44552. /** @hidden */
  44553. private _internalMarkAllSubMeshesAsTexturesDirty;
  44554. /** @hidden */
  44555. _markAllSubMeshesAsTexturesDirty(): void;
  44556. /**
  44557. * Instantiate a new istance of anisotropy configuration.
  44558. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  44559. */
  44560. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  44561. /**
  44562. * Specifies that the submesh is ready to be used.
  44563. * @param defines the list of "defines" to update.
  44564. * @param scene defines the scene the material belongs to.
  44565. * @returns - boolean indicating that the submesh is ready or not.
  44566. */
  44567. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  44568. /**
  44569. * Checks to see if a texture is used in the material.
  44570. * @param defines the list of "defines" to update.
  44571. * @param mesh the mesh we are preparing the defines for.
  44572. * @param scene defines the scene the material belongs to.
  44573. */
  44574. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  44575. /**
  44576. * Binds the material data.
  44577. * @param uniformBuffer defines the Uniform buffer to fill in.
  44578. * @param scene defines the scene the material belongs to.
  44579. * @param isFrozen defines wether the material is frozen or not.
  44580. */
  44581. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  44582. /**
  44583. * Checks to see if a texture is used in the material.
  44584. * @param texture - Base texture to use.
  44585. * @returns - Boolean specifying if a texture is used in the material.
  44586. */
  44587. hasTexture(texture: BaseTexture): boolean;
  44588. /**
  44589. * Returns an array of the actively used textures.
  44590. * @param activeTextures Array of BaseTextures
  44591. */
  44592. getActiveTextures(activeTextures: BaseTexture[]): void;
  44593. /**
  44594. * Returns the animatable textures.
  44595. * @param animatables Array of animatable textures.
  44596. */
  44597. getAnimatables(animatables: IAnimatable[]): void;
  44598. /**
  44599. * Disposes the resources of the material.
  44600. * @param forceDisposeTextures - Forces the disposal of all textures.
  44601. */
  44602. dispose(forceDisposeTextures?: boolean): void;
  44603. /**
  44604. * Get the current class name of the texture useful for serialization or dynamic coding.
  44605. * @returns "PBRAnisotropicConfiguration"
  44606. */
  44607. getClassName(): string;
  44608. /**
  44609. * Add fallbacks to the effect fallbacks list.
  44610. * @param defines defines the Base texture to use.
  44611. * @param fallbacks defines the current fallback list.
  44612. * @param currentRank defines the current fallback rank.
  44613. * @returns the new fallback rank.
  44614. */
  44615. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  44616. /**
  44617. * Add the required uniforms to the current list.
  44618. * @param uniforms defines the current uniform list.
  44619. */
  44620. static AddUniforms(uniforms: string[]): void;
  44621. /**
  44622. * Add the required uniforms to the current buffer.
  44623. * @param uniformBuffer defines the current uniform buffer.
  44624. */
  44625. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  44626. /**
  44627. * Add the required samplers to the current list.
  44628. * @param samplers defines the current sampler list.
  44629. */
  44630. static AddSamplers(samplers: string[]): void;
  44631. /**
  44632. * Makes a duplicate of the current configuration into another one.
  44633. * @param anisotropicConfiguration define the config where to copy the info
  44634. */
  44635. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  44636. /**
  44637. * Serializes this anisotropy configuration.
  44638. * @returns - An object with the serialized config.
  44639. */
  44640. serialize(): any;
  44641. /**
  44642. * Parses a anisotropy Configuration from a serialized object.
  44643. * @param source - Serialized object.
  44644. */
  44645. parse(source: any): void;
  44646. }
  44647. }
  44648. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  44649. /**
  44650. * @hidden
  44651. */
  44652. export interface IMaterialBRDFDefines {
  44653. BRDF_V_HEIGHT_CORRELATED: boolean;
  44654. MS_BRDF_ENERGY_CONSERVATION: boolean;
  44655. /** @hidden */
  44656. _areMiscDirty: boolean;
  44657. }
  44658. /**
  44659. * Define the code related to the BRDF parameters of the pbr material.
  44660. */
  44661. export class PBRBRDFConfiguration {
  44662. private _useEnergyConservation;
  44663. /**
  44664. * Defines if the material uses energy conservation.
  44665. */
  44666. useEnergyConservation: boolean;
  44667. private _useSmithVisibilityHeightCorrelated;
  44668. /**
  44669. * LEGACY Mode set to false
  44670. * Defines if the material uses height smith correlated visibility term.
  44671. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  44672. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  44673. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  44674. * Not relying on height correlated will also disable energy conservation.
  44675. */
  44676. useSmithVisibilityHeightCorrelated: boolean;
  44677. /** @hidden */
  44678. private _internalMarkAllSubMeshesAsMiscDirty;
  44679. /** @hidden */
  44680. _markAllSubMeshesAsMiscDirty(): void;
  44681. /**
  44682. * Instantiate a new istance of clear coat configuration.
  44683. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  44684. */
  44685. constructor(markAllSubMeshesAsMiscDirty: () => void);
  44686. /**
  44687. * Checks to see if a texture is used in the material.
  44688. * @param defines the list of "defines" to update.
  44689. */
  44690. prepareDefines(defines: IMaterialBRDFDefines): void;
  44691. /**
  44692. * Get the current class name of the texture useful for serialization or dynamic coding.
  44693. * @returns "PBRClearCoatConfiguration"
  44694. */
  44695. getClassName(): string;
  44696. /**
  44697. * Makes a duplicate of the current configuration into another one.
  44698. * @param brdfConfiguration define the config where to copy the info
  44699. */
  44700. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  44701. /**
  44702. * Serializes this BRDF configuration.
  44703. * @returns - An object with the serialized config.
  44704. */
  44705. serialize(): any;
  44706. /**
  44707. * Parses a BRDF Configuration from a serialized object.
  44708. * @param source - Serialized object.
  44709. */
  44710. parse(source: any): void;
  44711. }
  44712. }
  44713. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  44714. import { EffectFallbacks } from "babylonjs/Materials/effect";
  44715. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  44716. import { Color3 } from "babylonjs/Maths/math";
  44717. import { Scene } from "babylonjs/scene";
  44718. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44719. import { IAnimatable } from "babylonjs/Misc/tools";
  44720. import { Nullable } from "babylonjs/types";
  44721. /**
  44722. * @hidden
  44723. */
  44724. export interface IMaterialSheenDefines {
  44725. SHEEN: boolean;
  44726. SHEEN_TEXTURE: boolean;
  44727. SHEEN_TEXTUREDIRECTUV: number;
  44728. SHEEN_LINKWITHALBEDO: boolean;
  44729. /** @hidden */
  44730. _areTexturesDirty: boolean;
  44731. }
  44732. /**
  44733. * Define the code related to the Sheen parameters of the pbr material.
  44734. */
  44735. export class PBRSheenConfiguration {
  44736. private _isEnabled;
  44737. /**
  44738. * Defines if the material uses sheen.
  44739. */
  44740. isEnabled: boolean;
  44741. private _linkSheenWithAlbedo;
  44742. /**
  44743. * Defines if the sheen is linked to the sheen color.
  44744. */
  44745. linkSheenWithAlbedo: boolean;
  44746. /**
  44747. * Defines the sheen intensity.
  44748. */
  44749. intensity: number;
  44750. /**
  44751. * Defines the sheen color.
  44752. */
  44753. color: Color3;
  44754. private _texture;
  44755. /**
  44756. * Stores the sheen tint values in a texture.
  44757. * rgb is tint
  44758. * a is a intensity
  44759. */
  44760. texture: Nullable<BaseTexture>;
  44761. /** @hidden */
  44762. private _internalMarkAllSubMeshesAsTexturesDirty;
  44763. /** @hidden */
  44764. _markAllSubMeshesAsTexturesDirty(): void;
  44765. /**
  44766. * Instantiate a new istance of clear coat configuration.
  44767. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  44768. */
  44769. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  44770. /**
  44771. * Specifies that the submesh is ready to be used.
  44772. * @param defines the list of "defines" to update.
  44773. * @param scene defines the scene the material belongs to.
  44774. * @returns - boolean indicating that the submesh is ready or not.
  44775. */
  44776. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  44777. /**
  44778. * Checks to see if a texture is used in the material.
  44779. * @param defines the list of "defines" to update.
  44780. * @param scene defines the scene the material belongs to.
  44781. */
  44782. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  44783. /**
  44784. * Binds the material data.
  44785. * @param uniformBuffer defines the Uniform buffer to fill in.
  44786. * @param scene defines the scene the material belongs to.
  44787. * @param isFrozen defines wether the material is frozen or not.
  44788. */
  44789. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  44790. /**
  44791. * Checks to see if a texture is used in the material.
  44792. * @param texture - Base texture to use.
  44793. * @returns - Boolean specifying if a texture is used in the material.
  44794. */
  44795. hasTexture(texture: BaseTexture): boolean;
  44796. /**
  44797. * Returns an array of the actively used textures.
  44798. * @param activeTextures Array of BaseTextures
  44799. */
  44800. getActiveTextures(activeTextures: BaseTexture[]): void;
  44801. /**
  44802. * Returns the animatable textures.
  44803. * @param animatables Array of animatable textures.
  44804. */
  44805. getAnimatables(animatables: IAnimatable[]): void;
  44806. /**
  44807. * Disposes the resources of the material.
  44808. * @param forceDisposeTextures - Forces the disposal of all textures.
  44809. */
  44810. dispose(forceDisposeTextures?: boolean): void;
  44811. /**
  44812. * Get the current class name of the texture useful for serialization or dynamic coding.
  44813. * @returns "PBRSheenConfiguration"
  44814. */
  44815. getClassName(): string;
  44816. /**
  44817. * Add fallbacks to the effect fallbacks list.
  44818. * @param defines defines the Base texture to use.
  44819. * @param fallbacks defines the current fallback list.
  44820. * @param currentRank defines the current fallback rank.
  44821. * @returns the new fallback rank.
  44822. */
  44823. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  44824. /**
  44825. * Add the required uniforms to the current list.
  44826. * @param uniforms defines the current uniform list.
  44827. */
  44828. static AddUniforms(uniforms: string[]): void;
  44829. /**
  44830. * Add the required uniforms to the current buffer.
  44831. * @param uniformBuffer defines the current uniform buffer.
  44832. */
  44833. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  44834. /**
  44835. * Add the required samplers to the current list.
  44836. * @param samplers defines the current sampler list.
  44837. */
  44838. static AddSamplers(samplers: string[]): void;
  44839. /**
  44840. * Makes a duplicate of the current configuration into another one.
  44841. * @param sheenConfiguration define the config where to copy the info
  44842. */
  44843. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  44844. /**
  44845. * Serializes this BRDF configuration.
  44846. * @returns - An object with the serialized config.
  44847. */
  44848. serialize(): any;
  44849. /**
  44850. * Parses a Sheen Configuration from a serialized object.
  44851. * @param source - Serialized object.
  44852. */
  44853. parse(source: any): void;
  44854. }
  44855. }
  44856. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  44857. /** @hidden */
  44858. export var pbrFragmentDeclaration: {
  44859. name: string;
  44860. shader: string;
  44861. };
  44862. }
  44863. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  44864. /** @hidden */
  44865. export var pbrUboDeclaration: {
  44866. name: string;
  44867. shader: string;
  44868. };
  44869. }
  44870. declare module "babylonjs/Shaders/ShadersInclude/pbrFunctions" {
  44871. /** @hidden */
  44872. export var pbrFunctions: {
  44873. name: string;
  44874. shader: string;
  44875. };
  44876. }
  44877. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  44878. /** @hidden */
  44879. export var harmonicsFunctions: {
  44880. name: string;
  44881. shader: string;
  44882. };
  44883. }
  44884. declare module "babylonjs/Shaders/ShadersInclude/pbrPreLightingFunctions" {
  44885. /** @hidden */
  44886. export var pbrPreLightingFunctions: {
  44887. name: string;
  44888. shader: string;
  44889. };
  44890. }
  44891. declare module "babylonjs/Shaders/ShadersInclude/pbrFalloffLightingFunctions" {
  44892. /** @hidden */
  44893. export var pbrFalloffLightingFunctions: {
  44894. name: string;
  44895. shader: string;
  44896. };
  44897. }
  44898. declare module "babylonjs/Shaders/ShadersInclude/pbrLightingFunctions" {
  44899. /** @hidden */
  44900. export var pbrLightingFunctions: {
  44901. name: string;
  44902. shader: string;
  44903. };
  44904. }
  44905. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  44906. /** @hidden */
  44907. export var pbrDebug: {
  44908. name: string;
  44909. shader: string;
  44910. };
  44911. }
  44912. declare module "babylonjs/Shaders/pbr.fragment" {
  44913. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  44914. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  44915. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  44916. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  44917. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  44918. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  44919. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  44920. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  44921. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  44922. import "babylonjs/Shaders/ShadersInclude/pbrFunctions";
  44923. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  44924. import "babylonjs/Shaders/ShadersInclude/pbrPreLightingFunctions";
  44925. import "babylonjs/Shaders/ShadersInclude/pbrFalloffLightingFunctions";
  44926. import "babylonjs/Shaders/ShadersInclude/pbrLightingFunctions";
  44927. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  44928. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  44929. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  44930. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  44931. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  44932. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  44933. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  44934. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  44935. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  44936. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  44937. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  44938. /** @hidden */
  44939. export var pbrPixelShader: {
  44940. name: string;
  44941. shader: string;
  44942. };
  44943. }
  44944. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  44945. /** @hidden */
  44946. export var pbrVertexDeclaration: {
  44947. name: string;
  44948. shader: string;
  44949. };
  44950. }
  44951. declare module "babylonjs/Shaders/pbr.vertex" {
  44952. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  44953. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  44954. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  44955. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  44956. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  44957. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  44958. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  44959. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  44960. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  44961. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  44962. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  44963. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  44964. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  44965. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  44966. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  44967. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  44968. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  44969. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  44970. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  44971. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  44972. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  44973. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  44974. /** @hidden */
  44975. export var pbrVertexShader: {
  44976. name: string;
  44977. shader: string;
  44978. };
  44979. }
  44980. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  44981. import { IAnimatable } from "babylonjs/Misc/tools";
  44982. import { Nullable } from "babylonjs/types";
  44983. import { Scene } from "babylonjs/scene";
  44984. import { Matrix, Color3 } from "babylonjs/Maths/math";
  44985. import { SubMesh } from "babylonjs/Meshes/subMesh";
  44986. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44987. import { Mesh } from "babylonjs/Meshes/mesh";
  44988. import { PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  44989. import { PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  44990. import { PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  44991. import { PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  44992. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  44993. import { Material } from "babylonjs/Materials/material";
  44994. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  44995. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44996. import "babylonjs/Shaders/pbr.fragment";
  44997. import "babylonjs/Shaders/pbr.vertex";
  44998. /**
  44999. * The Physically based material base class of BJS.
  45000. *
  45001. * This offers the main features of a standard PBR material.
  45002. * For more information, please refer to the documentation :
  45003. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  45004. */
  45005. export abstract class PBRBaseMaterial extends PushMaterial {
  45006. /**
  45007. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  45008. */
  45009. static readonly PBRMATERIAL_OPAQUE: number;
  45010. /**
  45011. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  45012. */
  45013. static readonly PBRMATERIAL_ALPHATEST: number;
  45014. /**
  45015. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45016. */
  45017. static readonly PBRMATERIAL_ALPHABLEND: number;
  45018. /**
  45019. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45020. * They are also discarded below the alpha cutoff threshold to improve performances.
  45021. */
  45022. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  45023. /**
  45024. * Defines the default value of how much AO map is occluding the analytical lights
  45025. * (point spot...).
  45026. */
  45027. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  45028. /**
  45029. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  45030. */
  45031. static readonly LIGHTFALLOFF_PHYSICAL: number;
  45032. /**
  45033. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  45034. * to enhance interoperability with other engines.
  45035. */
  45036. static readonly LIGHTFALLOFF_GLTF: number;
  45037. /**
  45038. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  45039. * to enhance interoperability with other materials.
  45040. */
  45041. static readonly LIGHTFALLOFF_STANDARD: number;
  45042. /**
  45043. * Intensity of the direct lights e.g. the four lights available in your scene.
  45044. * This impacts both the direct diffuse and specular highlights.
  45045. */
  45046. protected _directIntensity: number;
  45047. /**
  45048. * Intensity of the emissive part of the material.
  45049. * This helps controlling the emissive effect without modifying the emissive color.
  45050. */
  45051. protected _emissiveIntensity: number;
  45052. /**
  45053. * Intensity of the environment e.g. how much the environment will light the object
  45054. * either through harmonics for rough material or through the refelction for shiny ones.
  45055. */
  45056. protected _environmentIntensity: number;
  45057. /**
  45058. * This is a special control allowing the reduction of the specular highlights coming from the
  45059. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  45060. */
  45061. protected _specularIntensity: number;
  45062. /**
  45063. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  45064. */
  45065. private _lightingInfos;
  45066. /**
  45067. * Debug Control allowing disabling the bump map on this material.
  45068. */
  45069. protected _disableBumpMap: boolean;
  45070. /**
  45071. * AKA Diffuse Texture in standard nomenclature.
  45072. */
  45073. protected _albedoTexture: BaseTexture;
  45074. /**
  45075. * AKA Occlusion Texture in other nomenclature.
  45076. */
  45077. protected _ambientTexture: BaseTexture;
  45078. /**
  45079. * AKA Occlusion Texture Intensity in other nomenclature.
  45080. */
  45081. protected _ambientTextureStrength: number;
  45082. /**
  45083. * Defines how much the AO map is occluding the analytical lights (point spot...).
  45084. * 1 means it completely occludes it
  45085. * 0 mean it has no impact
  45086. */
  45087. protected _ambientTextureImpactOnAnalyticalLights: number;
  45088. /**
  45089. * Stores the alpha values in a texture.
  45090. */
  45091. protected _opacityTexture: BaseTexture;
  45092. /**
  45093. * Stores the reflection values in a texture.
  45094. */
  45095. protected _reflectionTexture: BaseTexture;
  45096. /**
  45097. * Stores the refraction values in a texture.
  45098. */
  45099. protected _refractionTexture: BaseTexture;
  45100. /**
  45101. * Stores the emissive values in a texture.
  45102. */
  45103. protected _emissiveTexture: BaseTexture;
  45104. /**
  45105. * AKA Specular texture in other nomenclature.
  45106. */
  45107. protected _reflectivityTexture: BaseTexture;
  45108. /**
  45109. * Used to switch from specular/glossiness to metallic/roughness workflow.
  45110. */
  45111. protected _metallicTexture: BaseTexture;
  45112. /**
  45113. * Specifies the metallic scalar of the metallic/roughness workflow.
  45114. * Can also be used to scale the metalness values of the metallic texture.
  45115. */
  45116. protected _metallic: Nullable<number>;
  45117. /**
  45118. * Specifies the roughness scalar of the metallic/roughness workflow.
  45119. * Can also be used to scale the roughness values of the metallic texture.
  45120. */
  45121. protected _roughness: Nullable<number>;
  45122. /**
  45123. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  45124. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  45125. */
  45126. protected _microSurfaceTexture: BaseTexture;
  45127. /**
  45128. * Stores surface normal data used to displace a mesh in a texture.
  45129. */
  45130. protected _bumpTexture: BaseTexture;
  45131. /**
  45132. * Stores the pre-calculated light information of a mesh in a texture.
  45133. */
  45134. protected _lightmapTexture: BaseTexture;
  45135. /**
  45136. * The color of a material in ambient lighting.
  45137. */
  45138. protected _ambientColor: Color3;
  45139. /**
  45140. * AKA Diffuse Color in other nomenclature.
  45141. */
  45142. protected _albedoColor: Color3;
  45143. /**
  45144. * AKA Specular Color in other nomenclature.
  45145. */
  45146. protected _reflectivityColor: Color3;
  45147. /**
  45148. * The color applied when light is reflected from a material.
  45149. */
  45150. protected _reflectionColor: Color3;
  45151. /**
  45152. * The color applied when light is emitted from a material.
  45153. */
  45154. protected _emissiveColor: Color3;
  45155. /**
  45156. * AKA Glossiness in other nomenclature.
  45157. */
  45158. protected _microSurface: number;
  45159. /**
  45160. * source material index of refraction (IOR)' / 'destination material IOR.
  45161. */
  45162. protected _indexOfRefraction: number;
  45163. /**
  45164. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  45165. */
  45166. protected _invertRefractionY: boolean;
  45167. /**
  45168. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  45169. * Materials half opaque for instance using refraction could benefit from this control.
  45170. */
  45171. protected _linkRefractionWithTransparency: boolean;
  45172. /**
  45173. * Specifies that the material will use the light map as a show map.
  45174. */
  45175. protected _useLightmapAsShadowmap: boolean;
  45176. /**
  45177. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  45178. * makes the reflect vector face the model (under horizon).
  45179. */
  45180. protected _useHorizonOcclusion: boolean;
  45181. /**
  45182. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  45183. * too much the area relying on ambient texture to define their ambient occlusion.
  45184. */
  45185. protected _useRadianceOcclusion: boolean;
  45186. /**
  45187. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  45188. */
  45189. protected _useAlphaFromAlbedoTexture: boolean;
  45190. /**
  45191. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  45192. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  45193. */
  45194. protected _useSpecularOverAlpha: boolean;
  45195. /**
  45196. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  45197. */
  45198. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  45199. /**
  45200. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  45201. */
  45202. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  45203. /**
  45204. * Specifies if the metallic texture contains the roughness information in its green channel.
  45205. */
  45206. protected _useRoughnessFromMetallicTextureGreen: boolean;
  45207. /**
  45208. * Specifies if the metallic texture contains the metallness information in its blue channel.
  45209. */
  45210. protected _useMetallnessFromMetallicTextureBlue: boolean;
  45211. /**
  45212. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  45213. */
  45214. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  45215. /**
  45216. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  45217. */
  45218. protected _useAmbientInGrayScale: boolean;
  45219. /**
  45220. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  45221. * The material will try to infer what glossiness each pixel should be.
  45222. */
  45223. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  45224. /**
  45225. * Defines the falloff type used in this material.
  45226. * It by default is Physical.
  45227. */
  45228. protected _lightFalloff: number;
  45229. /**
  45230. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  45231. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  45232. */
  45233. protected _useRadianceOverAlpha: boolean;
  45234. /**
  45235. * Allows using an object space normal map (instead of tangent space).
  45236. */
  45237. protected _useObjectSpaceNormalMap: boolean;
  45238. /**
  45239. * Allows using the bump map in parallax mode.
  45240. */
  45241. protected _useParallax: boolean;
  45242. /**
  45243. * Allows using the bump map in parallax occlusion mode.
  45244. */
  45245. protected _useParallaxOcclusion: boolean;
  45246. /**
  45247. * Controls the scale bias of the parallax mode.
  45248. */
  45249. protected _parallaxScaleBias: number;
  45250. /**
  45251. * If sets to true, disables all the lights affecting the material.
  45252. */
  45253. protected _disableLighting: boolean;
  45254. /**
  45255. * Number of Simultaneous lights allowed on the material.
  45256. */
  45257. protected _maxSimultaneousLights: number;
  45258. /**
  45259. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  45260. */
  45261. protected _invertNormalMapX: boolean;
  45262. /**
  45263. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  45264. */
  45265. protected _invertNormalMapY: boolean;
  45266. /**
  45267. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  45268. */
  45269. protected _twoSidedLighting: boolean;
  45270. /**
  45271. * Defines the alpha limits in alpha test mode.
  45272. */
  45273. protected _alphaCutOff: number;
  45274. /**
  45275. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  45276. */
  45277. protected _forceAlphaTest: boolean;
  45278. /**
  45279. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45280. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  45281. */
  45282. protected _useAlphaFresnel: boolean;
  45283. /**
  45284. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45285. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  45286. */
  45287. protected _useLinearAlphaFresnel: boolean;
  45288. /**
  45289. * The transparency mode of the material.
  45290. */
  45291. protected _transparencyMode: Nullable<number>;
  45292. /**
  45293. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  45294. * from cos thetav and roughness:
  45295. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  45296. */
  45297. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  45298. /**
  45299. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  45300. */
  45301. protected _forceIrradianceInFragment: boolean;
  45302. /**
  45303. * Force normal to face away from face.
  45304. */
  45305. protected _forceNormalForward: boolean;
  45306. /**
  45307. * Enables specular anti aliasing in the PBR shader.
  45308. * It will both interacts on the Geometry for analytical and IBL lighting.
  45309. * It also prefilter the roughness map based on the bump values.
  45310. */
  45311. protected _enableSpecularAntiAliasing: boolean;
  45312. /**
  45313. * Default configuration related to image processing available in the PBR Material.
  45314. */
  45315. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  45316. /**
  45317. * Keep track of the image processing observer to allow dispose and replace.
  45318. */
  45319. private _imageProcessingObserver;
  45320. /**
  45321. * Attaches a new image processing configuration to the PBR Material.
  45322. * @param configuration
  45323. */
  45324. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  45325. /**
  45326. * Stores the available render targets.
  45327. */
  45328. private _renderTargets;
  45329. /**
  45330. * Sets the global ambient color for the material used in lighting calculations.
  45331. */
  45332. private _globalAmbientColor;
  45333. /**
  45334. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  45335. */
  45336. private _useLogarithmicDepth;
  45337. /**
  45338. * If set to true, no lighting calculations will be applied.
  45339. */
  45340. private _unlit;
  45341. private _debugMode;
  45342. /**
  45343. * @hidden
  45344. * This is reserved for the inspector.
  45345. * Defines the material debug mode.
  45346. * It helps seeing only some components of the material while troubleshooting.
  45347. */
  45348. debugMode: number;
  45349. /**
  45350. * @hidden
  45351. * This is reserved for the inspector.
  45352. * Specify from where on screen the debug mode should start.
  45353. * The value goes from -1 (full screen) to 1 (not visible)
  45354. * It helps with side by side comparison against the final render
  45355. * This defaults to -1
  45356. */
  45357. private debugLimit;
  45358. /**
  45359. * @hidden
  45360. * This is reserved for the inspector.
  45361. * As the default viewing range might not be enough (if the ambient is really small for instance)
  45362. * You can use the factor to better multiply the final value.
  45363. */
  45364. private debugFactor;
  45365. /**
  45366. * Defines the clear coat layer parameters for the material.
  45367. */
  45368. readonly clearCoat: PBRClearCoatConfiguration;
  45369. /**
  45370. * Defines the anisotropic parameters for the material.
  45371. */
  45372. readonly anisotropy: PBRAnisotropicConfiguration;
  45373. /**
  45374. * Defines the BRDF parameters for the material.
  45375. */
  45376. readonly brdf: PBRBRDFConfiguration;
  45377. /**
  45378. * Defines the Sheen parameters for the material.
  45379. */
  45380. readonly sheen: PBRSheenConfiguration;
  45381. /**
  45382. * Instantiates a new PBRMaterial instance.
  45383. *
  45384. * @param name The material name
  45385. * @param scene The scene the material will be use in.
  45386. */
  45387. constructor(name: string, scene: Scene);
  45388. /**
  45389. * Gets a boolean indicating that current material needs to register RTT
  45390. */
  45391. readonly hasRenderTargetTextures: boolean;
  45392. /**
  45393. * Gets the name of the material class.
  45394. */
  45395. getClassName(): string;
  45396. /**
  45397. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  45398. */
  45399. /**
  45400. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  45401. */
  45402. useLogarithmicDepth: boolean;
  45403. /**
  45404. * Gets the current transparency mode.
  45405. */
  45406. /**
  45407. * Sets the transparency mode of the material.
  45408. *
  45409. * | Value | Type | Description |
  45410. * | ----- | ----------------------------------- | ----------- |
  45411. * | 0 | OPAQUE | |
  45412. * | 1 | ALPHATEST | |
  45413. * | 2 | ALPHABLEND | |
  45414. * | 3 | ALPHATESTANDBLEND | |
  45415. *
  45416. */
  45417. transparencyMode: Nullable<number>;
  45418. /**
  45419. * Returns true if alpha blending should be disabled.
  45420. */
  45421. private readonly _disableAlphaBlending;
  45422. /**
  45423. * Specifies whether or not this material should be rendered in alpha blend mode.
  45424. */
  45425. needAlphaBlending(): boolean;
  45426. /**
  45427. * Specifies if the mesh will require alpha blending.
  45428. * @param mesh - BJS mesh.
  45429. */
  45430. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  45431. /**
  45432. * Specifies whether or not this material should be rendered in alpha test mode.
  45433. */
  45434. needAlphaTesting(): boolean;
  45435. /**
  45436. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  45437. */
  45438. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  45439. /**
  45440. * Gets the texture used for the alpha test.
  45441. */
  45442. getAlphaTestTexture(): BaseTexture;
  45443. /**
  45444. * Specifies that the submesh is ready to be used.
  45445. * @param mesh - BJS mesh.
  45446. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  45447. * @param useInstances - Specifies that instances should be used.
  45448. * @returns - boolean indicating that the submesh is ready or not.
  45449. */
  45450. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  45451. /**
  45452. * Specifies if the material uses metallic roughness workflow.
  45453. * @returns boolean specifiying if the material uses metallic roughness workflow.
  45454. */
  45455. isMetallicWorkflow(): boolean;
  45456. private _prepareEffect;
  45457. private _prepareDefines;
  45458. /**
  45459. * Force shader compilation
  45460. */
  45461. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  45462. clipPlane: boolean;
  45463. }>): void;
  45464. /**
  45465. * Initializes the uniform buffer layout for the shader.
  45466. */
  45467. buildUniformLayout(): void;
  45468. /**
  45469. * Unbinds the textures.
  45470. */
  45471. unbind(): void;
  45472. /**
  45473. * Binds the submesh data.
  45474. * @param world - The world matrix.
  45475. * @param mesh - The BJS mesh.
  45476. * @param subMesh - A submesh of the BJS mesh.
  45477. */
  45478. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  45479. /**
  45480. * Returns the animatable textures.
  45481. * @returns - Array of animatable textures.
  45482. */
  45483. getAnimatables(): IAnimatable[];
  45484. /**
  45485. * Returns the texture used for reflections.
  45486. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  45487. */
  45488. private _getReflectionTexture;
  45489. /**
  45490. * Returns the texture used for refraction or null if none is used.
  45491. * @returns - Refection texture if present. If no refraction texture and refraction
  45492. * is linked with transparency, returns environment texture. Otherwise, returns null.
  45493. */
  45494. private _getRefractionTexture;
  45495. /**
  45496. * Returns an array of the actively used textures.
  45497. * @returns - Array of BaseTextures
  45498. */
  45499. getActiveTextures(): BaseTexture[];
  45500. /**
  45501. * Checks to see if a texture is used in the material.
  45502. * @param texture - Base texture to use.
  45503. * @returns - Boolean specifying if a texture is used in the material.
  45504. */
  45505. hasTexture(texture: BaseTexture): boolean;
  45506. /**
  45507. * Disposes the resources of the material.
  45508. * @param forceDisposeEffect - Forces the disposal of effects.
  45509. * @param forceDisposeTextures - Forces the disposal of all textures.
  45510. */
  45511. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  45512. }
  45513. }
  45514. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  45515. import { Nullable } from "babylonjs/types";
  45516. import { Scene } from "babylonjs/scene";
  45517. import { Color3 } from "babylonjs/Maths/math";
  45518. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  45519. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  45520. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45521. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  45522. /**
  45523. * The Physically based material of BJS.
  45524. *
  45525. * This offers the main features of a standard PBR material.
  45526. * For more information, please refer to the documentation :
  45527. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  45528. */
  45529. export class PBRMaterial extends PBRBaseMaterial {
  45530. /**
  45531. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  45532. */
  45533. static readonly PBRMATERIAL_OPAQUE: number;
  45534. /**
  45535. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  45536. */
  45537. static readonly PBRMATERIAL_ALPHATEST: number;
  45538. /**
  45539. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45540. */
  45541. static readonly PBRMATERIAL_ALPHABLEND: number;
  45542. /**
  45543. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45544. * They are also discarded below the alpha cutoff threshold to improve performances.
  45545. */
  45546. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  45547. /**
  45548. * Defines the default value of how much AO map is occluding the analytical lights
  45549. * (point spot...).
  45550. */
  45551. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  45552. /**
  45553. * Intensity of the direct lights e.g. the four lights available in your scene.
  45554. * This impacts both the direct diffuse and specular highlights.
  45555. */
  45556. directIntensity: number;
  45557. /**
  45558. * Intensity of the emissive part of the material.
  45559. * This helps controlling the emissive effect without modifying the emissive color.
  45560. */
  45561. emissiveIntensity: number;
  45562. /**
  45563. * Intensity of the environment e.g. how much the environment will light the object
  45564. * either through harmonics for rough material or through the refelction for shiny ones.
  45565. */
  45566. environmentIntensity: number;
  45567. /**
  45568. * This is a special control allowing the reduction of the specular highlights coming from the
  45569. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  45570. */
  45571. specularIntensity: number;
  45572. /**
  45573. * Debug Control allowing disabling the bump map on this material.
  45574. */
  45575. disableBumpMap: boolean;
  45576. /**
  45577. * AKA Diffuse Texture in standard nomenclature.
  45578. */
  45579. albedoTexture: BaseTexture;
  45580. /**
  45581. * AKA Occlusion Texture in other nomenclature.
  45582. */
  45583. ambientTexture: BaseTexture;
  45584. /**
  45585. * AKA Occlusion Texture Intensity in other nomenclature.
  45586. */
  45587. ambientTextureStrength: number;
  45588. /**
  45589. * Defines how much the AO map is occluding the analytical lights (point spot...).
  45590. * 1 means it completely occludes it
  45591. * 0 mean it has no impact
  45592. */
  45593. ambientTextureImpactOnAnalyticalLights: number;
  45594. /**
  45595. * Stores the alpha values in a texture.
  45596. */
  45597. opacityTexture: BaseTexture;
  45598. /**
  45599. * Stores the reflection values in a texture.
  45600. */
  45601. reflectionTexture: Nullable<BaseTexture>;
  45602. /**
  45603. * Stores the emissive values in a texture.
  45604. */
  45605. emissiveTexture: BaseTexture;
  45606. /**
  45607. * AKA Specular texture in other nomenclature.
  45608. */
  45609. reflectivityTexture: BaseTexture;
  45610. /**
  45611. * Used to switch from specular/glossiness to metallic/roughness workflow.
  45612. */
  45613. metallicTexture: BaseTexture;
  45614. /**
  45615. * Specifies the metallic scalar of the metallic/roughness workflow.
  45616. * Can also be used to scale the metalness values of the metallic texture.
  45617. */
  45618. metallic: Nullable<number>;
  45619. /**
  45620. * Specifies the roughness scalar of the metallic/roughness workflow.
  45621. * Can also be used to scale the roughness values of the metallic texture.
  45622. */
  45623. roughness: Nullable<number>;
  45624. /**
  45625. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  45626. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  45627. */
  45628. microSurfaceTexture: BaseTexture;
  45629. /**
  45630. * Stores surface normal data used to displace a mesh in a texture.
  45631. */
  45632. bumpTexture: BaseTexture;
  45633. /**
  45634. * Stores the pre-calculated light information of a mesh in a texture.
  45635. */
  45636. lightmapTexture: BaseTexture;
  45637. /**
  45638. * Stores the refracted light information in a texture.
  45639. */
  45640. refractionTexture: BaseTexture;
  45641. /**
  45642. * The color of a material in ambient lighting.
  45643. */
  45644. ambientColor: Color3;
  45645. /**
  45646. * AKA Diffuse Color in other nomenclature.
  45647. */
  45648. albedoColor: Color3;
  45649. /**
  45650. * AKA Specular Color in other nomenclature.
  45651. */
  45652. reflectivityColor: Color3;
  45653. /**
  45654. * The color reflected from the material.
  45655. */
  45656. reflectionColor: Color3;
  45657. /**
  45658. * The color emitted from the material.
  45659. */
  45660. emissiveColor: Color3;
  45661. /**
  45662. * AKA Glossiness in other nomenclature.
  45663. */
  45664. microSurface: number;
  45665. /**
  45666. * source material index of refraction (IOR)' / 'destination material IOR.
  45667. */
  45668. indexOfRefraction: number;
  45669. /**
  45670. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  45671. */
  45672. invertRefractionY: boolean;
  45673. /**
  45674. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  45675. * Materials half opaque for instance using refraction could benefit from this control.
  45676. */
  45677. linkRefractionWithTransparency: boolean;
  45678. /**
  45679. * If true, the light map contains occlusion information instead of lighting info.
  45680. */
  45681. useLightmapAsShadowmap: boolean;
  45682. /**
  45683. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  45684. */
  45685. useAlphaFromAlbedoTexture: boolean;
  45686. /**
  45687. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  45688. */
  45689. forceAlphaTest: boolean;
  45690. /**
  45691. * Defines the alpha limits in alpha test mode.
  45692. */
  45693. alphaCutOff: number;
  45694. /**
  45695. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  45696. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  45697. */
  45698. useSpecularOverAlpha: boolean;
  45699. /**
  45700. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  45701. */
  45702. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  45703. /**
  45704. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  45705. */
  45706. useRoughnessFromMetallicTextureAlpha: boolean;
  45707. /**
  45708. * Specifies if the metallic texture contains the roughness information in its green channel.
  45709. */
  45710. useRoughnessFromMetallicTextureGreen: boolean;
  45711. /**
  45712. * Specifies if the metallic texture contains the metallness information in its blue channel.
  45713. */
  45714. useMetallnessFromMetallicTextureBlue: boolean;
  45715. /**
  45716. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  45717. */
  45718. useAmbientOcclusionFromMetallicTextureRed: boolean;
  45719. /**
  45720. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  45721. */
  45722. useAmbientInGrayScale: boolean;
  45723. /**
  45724. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  45725. * The material will try to infer what glossiness each pixel should be.
  45726. */
  45727. useAutoMicroSurfaceFromReflectivityMap: boolean;
  45728. /**
  45729. * BJS is using an harcoded light falloff based on a manually sets up range.
  45730. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  45731. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  45732. */
  45733. /**
  45734. * BJS is using an harcoded light falloff based on a manually sets up range.
  45735. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  45736. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  45737. */
  45738. usePhysicalLightFalloff: boolean;
  45739. /**
  45740. * In order to support the falloff compatibility with gltf, a special mode has been added
  45741. * to reproduce the gltf light falloff.
  45742. */
  45743. /**
  45744. * In order to support the falloff compatibility with gltf, a special mode has been added
  45745. * to reproduce the gltf light falloff.
  45746. */
  45747. useGLTFLightFalloff: boolean;
  45748. /**
  45749. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  45750. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  45751. */
  45752. useRadianceOverAlpha: boolean;
  45753. /**
  45754. * Allows using an object space normal map (instead of tangent space).
  45755. */
  45756. useObjectSpaceNormalMap: boolean;
  45757. /**
  45758. * Allows using the bump map in parallax mode.
  45759. */
  45760. useParallax: boolean;
  45761. /**
  45762. * Allows using the bump map in parallax occlusion mode.
  45763. */
  45764. useParallaxOcclusion: boolean;
  45765. /**
  45766. * Controls the scale bias of the parallax mode.
  45767. */
  45768. parallaxScaleBias: number;
  45769. /**
  45770. * If sets to true, disables all the lights affecting the material.
  45771. */
  45772. disableLighting: boolean;
  45773. /**
  45774. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  45775. */
  45776. forceIrradianceInFragment: boolean;
  45777. /**
  45778. * Number of Simultaneous lights allowed on the material.
  45779. */
  45780. maxSimultaneousLights: number;
  45781. /**
  45782. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  45783. */
  45784. invertNormalMapX: boolean;
  45785. /**
  45786. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  45787. */
  45788. invertNormalMapY: boolean;
  45789. /**
  45790. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  45791. */
  45792. twoSidedLighting: boolean;
  45793. /**
  45794. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45795. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  45796. */
  45797. useAlphaFresnel: boolean;
  45798. /**
  45799. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45800. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  45801. */
  45802. useLinearAlphaFresnel: boolean;
  45803. /**
  45804. * Let user defines the brdf lookup texture used for IBL.
  45805. * A default 8bit version is embedded but you could point at :
  45806. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.png
  45807. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  45808. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  45809. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  45810. */
  45811. environmentBRDFTexture: Nullable<BaseTexture>;
  45812. /**
  45813. * Force normal to face away from face.
  45814. */
  45815. forceNormalForward: boolean;
  45816. /**
  45817. * Enables specular anti aliasing in the PBR shader.
  45818. * It will both interacts on the Geometry for analytical and IBL lighting.
  45819. * It also prefilter the roughness map based on the bump values.
  45820. */
  45821. enableSpecularAntiAliasing: boolean;
  45822. /**
  45823. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  45824. * makes the reflect vector face the model (under horizon).
  45825. */
  45826. useHorizonOcclusion: boolean;
  45827. /**
  45828. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  45829. * too much the area relying on ambient texture to define their ambient occlusion.
  45830. */
  45831. useRadianceOcclusion: boolean;
  45832. /**
  45833. * If set to true, no lighting calculations will be applied.
  45834. */
  45835. unlit: boolean;
  45836. /**
  45837. * Gets the image processing configuration used either in this material.
  45838. */
  45839. /**
  45840. * Sets the Default image processing configuration used either in the this material.
  45841. *
  45842. * If sets to null, the scene one is in use.
  45843. */
  45844. imageProcessingConfiguration: ImageProcessingConfiguration;
  45845. /**
  45846. * Gets wether the color curves effect is enabled.
  45847. */
  45848. /**
  45849. * Sets wether the color curves effect is enabled.
  45850. */
  45851. cameraColorCurvesEnabled: boolean;
  45852. /**
  45853. * Gets wether the color grading effect is enabled.
  45854. */
  45855. /**
  45856. * Gets wether the color grading effect is enabled.
  45857. */
  45858. cameraColorGradingEnabled: boolean;
  45859. /**
  45860. * Gets wether tonemapping is enabled or not.
  45861. */
  45862. /**
  45863. * Sets wether tonemapping is enabled or not
  45864. */
  45865. cameraToneMappingEnabled: boolean;
  45866. /**
  45867. * The camera exposure used on this material.
  45868. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45869. * This corresponds to a photographic exposure.
  45870. */
  45871. /**
  45872. * The camera exposure used on this material.
  45873. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45874. * This corresponds to a photographic exposure.
  45875. */
  45876. cameraExposure: number;
  45877. /**
  45878. * Gets The camera contrast used on this material.
  45879. */
  45880. /**
  45881. * Sets The camera contrast used on this material.
  45882. */
  45883. cameraContrast: number;
  45884. /**
  45885. * Gets the Color Grading 2D Lookup Texture.
  45886. */
  45887. /**
  45888. * Sets the Color Grading 2D Lookup Texture.
  45889. */
  45890. cameraColorGradingTexture: Nullable<BaseTexture>;
  45891. /**
  45892. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45893. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45894. * 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;
  45895. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45896. */
  45897. /**
  45898. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45899. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45900. * 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;
  45901. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45902. */
  45903. cameraColorCurves: Nullable<ColorCurves>;
  45904. /**
  45905. * Instantiates a new PBRMaterial instance.
  45906. *
  45907. * @param name The material name
  45908. * @param scene The scene the material will be use in.
  45909. */
  45910. constructor(name: string, scene: Scene);
  45911. /**
  45912. * Returns the name of this material class.
  45913. */
  45914. getClassName(): string;
  45915. /**
  45916. * Makes a duplicate of the current material.
  45917. * @param name - name to use for the new material.
  45918. */
  45919. clone(name: string): PBRMaterial;
  45920. /**
  45921. * Serializes this PBR Material.
  45922. * @returns - An object with the serialized material.
  45923. */
  45924. serialize(): any;
  45925. /**
  45926. * Parses a PBR Material from a serialized object.
  45927. * @param source - Serialized object.
  45928. * @param scene - BJS scene instance.
  45929. * @param rootUrl - url for the scene object
  45930. * @returns - PBRMaterial
  45931. */
  45932. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  45933. }
  45934. }
  45935. declare module "babylonjs/Misc/dds" {
  45936. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  45937. import { Engine } from "babylonjs/Engines/engine";
  45938. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  45939. import { Nullable } from "babylonjs/types";
  45940. import { Scene } from "babylonjs/scene";
  45941. /**
  45942. * Direct draw surface info
  45943. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  45944. */
  45945. export interface DDSInfo {
  45946. /**
  45947. * Width of the texture
  45948. */
  45949. width: number;
  45950. /**
  45951. * Width of the texture
  45952. */
  45953. height: number;
  45954. /**
  45955. * Number of Mipmaps for the texture
  45956. * @see https://en.wikipedia.org/wiki/Mipmap
  45957. */
  45958. mipmapCount: number;
  45959. /**
  45960. * If the textures format is a known fourCC format
  45961. * @see https://www.fourcc.org/
  45962. */
  45963. isFourCC: boolean;
  45964. /**
  45965. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  45966. */
  45967. isRGB: boolean;
  45968. /**
  45969. * If the texture is a lumincance format
  45970. */
  45971. isLuminance: boolean;
  45972. /**
  45973. * If this is a cube texture
  45974. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  45975. */
  45976. isCube: boolean;
  45977. /**
  45978. * If the texture is a compressed format eg. FOURCC_DXT1
  45979. */
  45980. isCompressed: boolean;
  45981. /**
  45982. * The dxgiFormat of the texture
  45983. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  45984. */
  45985. dxgiFormat: number;
  45986. /**
  45987. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  45988. */
  45989. textureType: number;
  45990. /**
  45991. * Sphericle polynomial created for the dds texture
  45992. */
  45993. sphericalPolynomial?: SphericalPolynomial;
  45994. }
  45995. /**
  45996. * Class used to provide DDS decompression tools
  45997. */
  45998. export class DDSTools {
  45999. /**
  46000. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  46001. */
  46002. static StoreLODInAlphaChannel: boolean;
  46003. /**
  46004. * Gets DDS information from an array buffer
  46005. * @param arrayBuffer defines the array buffer to read data from
  46006. * @returns the DDS information
  46007. */
  46008. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  46009. private static _FloatView;
  46010. private static _Int32View;
  46011. private static _ToHalfFloat;
  46012. private static _FromHalfFloat;
  46013. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  46014. private static _GetHalfFloatRGBAArrayBuffer;
  46015. private static _GetFloatRGBAArrayBuffer;
  46016. private static _GetFloatAsUIntRGBAArrayBuffer;
  46017. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  46018. private static _GetRGBAArrayBuffer;
  46019. private static _ExtractLongWordOrder;
  46020. private static _GetRGBArrayBuffer;
  46021. private static _GetLuminanceArrayBuffer;
  46022. /**
  46023. * Uploads DDS Levels to a Babylon Texture
  46024. * @hidden
  46025. */
  46026. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  46027. }
  46028. module "babylonjs/Engines/engine" {
  46029. interface Engine {
  46030. /**
  46031. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  46032. * @param rootUrl defines the url where the file to load is located
  46033. * @param scene defines the current scene
  46034. * @param lodScale defines scale to apply to the mip map selection
  46035. * @param lodOffset defines offset to apply to the mip map selection
  46036. * @param onLoad defines an optional callback raised when the texture is loaded
  46037. * @param onError defines an optional callback raised if there is an issue to load the texture
  46038. * @param format defines the format of the data
  46039. * @param forcedExtension defines the extension to use to pick the right loader
  46040. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  46041. * @returns the cube texture as an InternalTexture
  46042. */
  46043. 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;
  46044. }
  46045. }
  46046. }
  46047. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  46048. import { Nullable } from "babylonjs/types";
  46049. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46050. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  46051. /**
  46052. * Implementation of the DDS Texture Loader.
  46053. * @hidden
  46054. */
  46055. export class _DDSTextureLoader implements IInternalTextureLoader {
  46056. /**
  46057. * Defines wether the loader supports cascade loading the different faces.
  46058. */
  46059. readonly supportCascades: boolean;
  46060. /**
  46061. * This returns if the loader support the current file information.
  46062. * @param extension defines the file extension of the file being loaded
  46063. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46064. * @param fallback defines the fallback internal texture if any
  46065. * @param isBase64 defines whether the texture is encoded as a base64
  46066. * @param isBuffer defines whether the texture data are stored as a buffer
  46067. * @returns true if the loader can load the specified file
  46068. */
  46069. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  46070. /**
  46071. * Transform the url before loading if required.
  46072. * @param rootUrl the url of the texture
  46073. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46074. * @returns the transformed texture
  46075. */
  46076. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  46077. /**
  46078. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  46079. * @param rootUrl the url of the texture
  46080. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46081. * @returns the fallback texture
  46082. */
  46083. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  46084. /**
  46085. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  46086. * @param data contains the texture data
  46087. * @param texture defines the BabylonJS internal texture
  46088. * @param createPolynomials will be true if polynomials have been requested
  46089. * @param onLoad defines the callback to trigger once the texture is ready
  46090. * @param onError defines the callback to trigger in case of error
  46091. */
  46092. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  46093. /**
  46094. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  46095. * @param data contains the texture data
  46096. * @param texture defines the BabylonJS internal texture
  46097. * @param callback defines the method to call once ready to upload
  46098. */
  46099. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  46100. }
  46101. }
  46102. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  46103. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46104. /** @hidden */
  46105. export var rgbdEncodePixelShader: {
  46106. name: string;
  46107. shader: string;
  46108. };
  46109. }
  46110. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  46111. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46112. /** @hidden */
  46113. export var rgbdDecodePixelShader: {
  46114. name: string;
  46115. shader: string;
  46116. };
  46117. }
  46118. declare module "babylonjs/Misc/environmentTextureTools" {
  46119. import { Nullable } from "babylonjs/types";
  46120. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  46121. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46122. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  46123. import "babylonjs/Shaders/rgbdEncode.fragment";
  46124. import "babylonjs/Shaders/rgbdDecode.fragment";
  46125. /**
  46126. * Raw texture data and descriptor sufficient for WebGL texture upload
  46127. */
  46128. export interface EnvironmentTextureInfo {
  46129. /**
  46130. * Version of the environment map
  46131. */
  46132. version: number;
  46133. /**
  46134. * Width of image
  46135. */
  46136. width: number;
  46137. /**
  46138. * Irradiance information stored in the file.
  46139. */
  46140. irradiance: any;
  46141. /**
  46142. * Specular information stored in the file.
  46143. */
  46144. specular: any;
  46145. }
  46146. /**
  46147. * Sets of helpers addressing the serialization and deserialization of environment texture
  46148. * stored in a BabylonJS env file.
  46149. * Those files are usually stored as .env files.
  46150. */
  46151. export class EnvironmentTextureTools {
  46152. /**
  46153. * Magic number identifying the env file.
  46154. */
  46155. private static _MagicBytes;
  46156. /**
  46157. * Gets the environment info from an env file.
  46158. * @param data The array buffer containing the .env bytes.
  46159. * @returns the environment file info (the json header) if successfully parsed.
  46160. */
  46161. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  46162. /**
  46163. * Creates an environment texture from a loaded cube texture.
  46164. * @param texture defines the cube texture to convert in env file
  46165. * @return a promise containing the environment data if succesfull.
  46166. */
  46167. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  46168. /**
  46169. * Creates a JSON representation of the spherical data.
  46170. * @param texture defines the texture containing the polynomials
  46171. * @return the JSON representation of the spherical info
  46172. */
  46173. private static _CreateEnvTextureIrradiance;
  46174. /**
  46175. * Uploads the texture info contained in the env file to the GPU.
  46176. * @param texture defines the internal texture to upload to
  46177. * @param arrayBuffer defines the buffer cotaining the data to load
  46178. * @param info defines the texture info retrieved through the GetEnvInfo method
  46179. * @returns a promise
  46180. */
  46181. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  46182. /**
  46183. * Uploads the levels of image data to the GPU.
  46184. * @param texture defines the internal texture to upload to
  46185. * @param imageData defines the array buffer views of image data [mipmap][face]
  46186. * @returns a promise
  46187. */
  46188. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  46189. /**
  46190. * Uploads spherical polynomials information to the texture.
  46191. * @param texture defines the texture we are trying to upload the information to
  46192. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  46193. */
  46194. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  46195. /** @hidden */
  46196. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  46197. }
  46198. }
  46199. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  46200. import { Nullable } from "babylonjs/types";
  46201. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46202. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  46203. /**
  46204. * Implementation of the ENV Texture Loader.
  46205. * @hidden
  46206. */
  46207. export class _ENVTextureLoader implements IInternalTextureLoader {
  46208. /**
  46209. * Defines wether the loader supports cascade loading the different faces.
  46210. */
  46211. readonly supportCascades: boolean;
  46212. /**
  46213. * This returns if the loader support the current file information.
  46214. * @param extension defines the file extension of the file being loaded
  46215. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46216. * @param fallback defines the fallback internal texture if any
  46217. * @param isBase64 defines whether the texture is encoded as a base64
  46218. * @param isBuffer defines whether the texture data are stored as a buffer
  46219. * @returns true if the loader can load the specified file
  46220. */
  46221. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  46222. /**
  46223. * Transform the url before loading if required.
  46224. * @param rootUrl the url of the texture
  46225. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46226. * @returns the transformed texture
  46227. */
  46228. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  46229. /**
  46230. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  46231. * @param rootUrl the url of the texture
  46232. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46233. * @returns the fallback texture
  46234. */
  46235. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  46236. /**
  46237. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  46238. * @param data contains the texture data
  46239. * @param texture defines the BabylonJS internal texture
  46240. * @param createPolynomials will be true if polynomials have been requested
  46241. * @param onLoad defines the callback to trigger once the texture is ready
  46242. * @param onError defines the callback to trigger in case of error
  46243. */
  46244. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  46245. /**
  46246. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  46247. * @param data contains the texture data
  46248. * @param texture defines the BabylonJS internal texture
  46249. * @param callback defines the method to call once ready to upload
  46250. */
  46251. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  46252. }
  46253. }
  46254. declare module "babylonjs/Misc/khronosTextureContainer" {
  46255. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46256. /**
  46257. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  46258. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  46259. */
  46260. export class KhronosTextureContainer {
  46261. /** contents of the KTX container file */
  46262. arrayBuffer: any;
  46263. private static HEADER_LEN;
  46264. private static COMPRESSED_2D;
  46265. private static COMPRESSED_3D;
  46266. private static TEX_2D;
  46267. private static TEX_3D;
  46268. /**
  46269. * Gets the openGL type
  46270. */
  46271. glType: number;
  46272. /**
  46273. * Gets the openGL type size
  46274. */
  46275. glTypeSize: number;
  46276. /**
  46277. * Gets the openGL format
  46278. */
  46279. glFormat: number;
  46280. /**
  46281. * Gets the openGL internal format
  46282. */
  46283. glInternalFormat: number;
  46284. /**
  46285. * Gets the base internal format
  46286. */
  46287. glBaseInternalFormat: number;
  46288. /**
  46289. * Gets image width in pixel
  46290. */
  46291. pixelWidth: number;
  46292. /**
  46293. * Gets image height in pixel
  46294. */
  46295. pixelHeight: number;
  46296. /**
  46297. * Gets image depth in pixels
  46298. */
  46299. pixelDepth: number;
  46300. /**
  46301. * Gets the number of array elements
  46302. */
  46303. numberOfArrayElements: number;
  46304. /**
  46305. * Gets the number of faces
  46306. */
  46307. numberOfFaces: number;
  46308. /**
  46309. * Gets the number of mipmap levels
  46310. */
  46311. numberOfMipmapLevels: number;
  46312. /**
  46313. * Gets the bytes of key value data
  46314. */
  46315. bytesOfKeyValueData: number;
  46316. /**
  46317. * Gets the load type
  46318. */
  46319. loadType: number;
  46320. /**
  46321. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  46322. */
  46323. isInvalid: boolean;
  46324. /**
  46325. * Creates a new KhronosTextureContainer
  46326. * @param arrayBuffer contents of the KTX container file
  46327. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  46328. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  46329. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  46330. */
  46331. constructor(
  46332. /** contents of the KTX container file */
  46333. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  46334. /**
  46335. * Uploads KTX content to a Babylon Texture.
  46336. * It is assumed that the texture has already been created & is currently bound
  46337. * @hidden
  46338. */
  46339. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  46340. private _upload2DCompressedLevels;
  46341. }
  46342. }
  46343. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  46344. import { Nullable } from "babylonjs/types";
  46345. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46346. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  46347. /**
  46348. * Implementation of the KTX Texture Loader.
  46349. * @hidden
  46350. */
  46351. export class _KTXTextureLoader implements IInternalTextureLoader {
  46352. /**
  46353. * Defines wether the loader supports cascade loading the different faces.
  46354. */
  46355. readonly supportCascades: boolean;
  46356. /**
  46357. * This returns if the loader support the current file information.
  46358. * @param extension defines the file extension of the file being loaded
  46359. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46360. * @param fallback defines the fallback internal texture if any
  46361. * @param isBase64 defines whether the texture is encoded as a base64
  46362. * @param isBuffer defines whether the texture data are stored as a buffer
  46363. * @returns true if the loader can load the specified file
  46364. */
  46365. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  46366. /**
  46367. * Transform the url before loading if required.
  46368. * @param rootUrl the url of the texture
  46369. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46370. * @returns the transformed texture
  46371. */
  46372. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  46373. /**
  46374. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  46375. * @param rootUrl the url of the texture
  46376. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46377. * @returns the fallback texture
  46378. */
  46379. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  46380. /**
  46381. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  46382. * @param data contains the texture data
  46383. * @param texture defines the BabylonJS internal texture
  46384. * @param createPolynomials will be true if polynomials have been requested
  46385. * @param onLoad defines the callback to trigger once the texture is ready
  46386. * @param onError defines the callback to trigger in case of error
  46387. */
  46388. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  46389. /**
  46390. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  46391. * @param data contains the texture data
  46392. * @param texture defines the BabylonJS internal texture
  46393. * @param callback defines the method to call once ready to upload
  46394. */
  46395. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  46396. }
  46397. }
  46398. declare module "babylonjs/Helpers/sceneHelpers" {
  46399. import { Nullable } from "babylonjs/types";
  46400. import { Mesh } from "babylonjs/Meshes/mesh";
  46401. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46402. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  46403. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  46404. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  46405. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  46406. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  46407. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  46408. import "babylonjs/Meshes/Builders/boxBuilder";
  46409. /** @hidden */
  46410. export var _forceSceneHelpersToBundle: boolean;
  46411. module "babylonjs/scene" {
  46412. interface Scene {
  46413. /**
  46414. * Creates a default light for the scene.
  46415. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  46416. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  46417. */
  46418. createDefaultLight(replace?: boolean): void;
  46419. /**
  46420. * Creates a default camera for the scene.
  46421. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  46422. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  46423. * @param replace has default false, when true replaces the active camera in the scene
  46424. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  46425. */
  46426. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  46427. /**
  46428. * Creates a default camera and a default light.
  46429. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  46430. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  46431. * @param replace has the default false, when true replaces the active camera/light in the scene
  46432. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  46433. */
  46434. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  46435. /**
  46436. * Creates a new sky box
  46437. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  46438. * @param environmentTexture defines the texture to use as environment texture
  46439. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  46440. * @param scale defines the overall scale of the skybox
  46441. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  46442. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  46443. * @returns a new mesh holding the sky box
  46444. */
  46445. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  46446. /**
  46447. * Creates a new environment
  46448. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  46449. * @param options defines the options you can use to configure the environment
  46450. * @returns the new EnvironmentHelper
  46451. */
  46452. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  46453. /**
  46454. * Creates a new VREXperienceHelper
  46455. * @see http://doc.babylonjs.com/how_to/webvr_helper
  46456. * @param webVROptions defines the options used to create the new VREXperienceHelper
  46457. * @returns a new VREXperienceHelper
  46458. */
  46459. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  46460. /**
  46461. * Creates a new XREXperienceHelper
  46462. * @see http://doc.babylonjs.com/how_to/webxr
  46463. * @returns a promise for a new XREXperienceHelper
  46464. */
  46465. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  46466. }
  46467. }
  46468. }
  46469. declare module "babylonjs/Helpers/videoDome" {
  46470. import { Scene } from "babylonjs/scene";
  46471. import { TransformNode } from "babylonjs/Meshes/transformNode";
  46472. import { Mesh } from "babylonjs/Meshes/mesh";
  46473. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  46474. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  46475. import "babylonjs/Meshes/Builders/sphereBuilder";
  46476. /**
  46477. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  46478. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  46479. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  46480. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  46481. */
  46482. export class VideoDome extends TransformNode {
  46483. /**
  46484. * Define the video source as a Monoscopic panoramic 360 video.
  46485. */
  46486. static readonly MODE_MONOSCOPIC: number;
  46487. /**
  46488. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  46489. */
  46490. static readonly MODE_TOPBOTTOM: number;
  46491. /**
  46492. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  46493. */
  46494. static readonly MODE_SIDEBYSIDE: number;
  46495. private _useDirectMapping;
  46496. /**
  46497. * The video texture being displayed on the sphere
  46498. */
  46499. protected _videoTexture: VideoTexture;
  46500. /**
  46501. * Gets the video texture being displayed on the sphere
  46502. */
  46503. readonly videoTexture: VideoTexture;
  46504. /**
  46505. * The skybox material
  46506. */
  46507. protected _material: BackgroundMaterial;
  46508. /**
  46509. * The surface used for the skybox
  46510. */
  46511. protected _mesh: Mesh;
  46512. /**
  46513. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  46514. * Also see the options.resolution property.
  46515. */
  46516. fovMultiplier: number;
  46517. private _videoMode;
  46518. /**
  46519. * Gets or set the current video mode for the video. It can be:
  46520. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  46521. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  46522. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  46523. */
  46524. videoMode: number;
  46525. /**
  46526. * Oberserver used in Stereoscopic VR Mode.
  46527. */
  46528. private _onBeforeCameraRenderObserver;
  46529. /**
  46530. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  46531. * @param name Element's name, child elements will append suffixes for their own names.
  46532. * @param urlsOrVideo defines the url(s) or the video element to use
  46533. * @param options An object containing optional or exposed sub element properties
  46534. */
  46535. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  46536. resolution?: number;
  46537. clickToPlay?: boolean;
  46538. autoPlay?: boolean;
  46539. loop?: boolean;
  46540. size?: number;
  46541. poster?: string;
  46542. useDirectMapping?: boolean;
  46543. }, scene: Scene);
  46544. private _changeVideoMode;
  46545. /**
  46546. * Releases resources associated with this node.
  46547. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  46548. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  46549. */
  46550. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  46551. }
  46552. }
  46553. declare module "babylonjs/Helpers/index" {
  46554. export * from "babylonjs/Helpers/environmentHelper";
  46555. export * from "babylonjs/Helpers/photoDome";
  46556. export * from "babylonjs/Helpers/sceneHelpers";
  46557. export * from "babylonjs/Helpers/videoDome";
  46558. }
  46559. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  46560. import { PerfCounter } from "babylonjs/Misc/tools";
  46561. import { IDisposable } from "babylonjs/scene";
  46562. import { Engine } from "babylonjs/Engines/engine";
  46563. /**
  46564. * This class can be used to get instrumentation data from a Babylon engine
  46565. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  46566. */
  46567. export class EngineInstrumentation implements IDisposable {
  46568. /**
  46569. * Define the instrumented engine.
  46570. */
  46571. engine: Engine;
  46572. private _captureGPUFrameTime;
  46573. private _gpuFrameTimeToken;
  46574. private _gpuFrameTime;
  46575. private _captureShaderCompilationTime;
  46576. private _shaderCompilationTime;
  46577. private _onBeginFrameObserver;
  46578. private _onEndFrameObserver;
  46579. private _onBeforeShaderCompilationObserver;
  46580. private _onAfterShaderCompilationObserver;
  46581. /**
  46582. * Gets the perf counter used for GPU frame time
  46583. */
  46584. readonly gpuFrameTimeCounter: PerfCounter;
  46585. /**
  46586. * Gets the GPU frame time capture status
  46587. */
  46588. /**
  46589. * Enable or disable the GPU frame time capture
  46590. */
  46591. captureGPUFrameTime: boolean;
  46592. /**
  46593. * Gets the perf counter used for shader compilation time
  46594. */
  46595. readonly shaderCompilationTimeCounter: PerfCounter;
  46596. /**
  46597. * Gets the shader compilation time capture status
  46598. */
  46599. /**
  46600. * Enable or disable the shader compilation time capture
  46601. */
  46602. captureShaderCompilationTime: boolean;
  46603. /**
  46604. * Instantiates a new engine instrumentation.
  46605. * This class can be used to get instrumentation data from a Babylon engine
  46606. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  46607. * @param engine Defines the engine to instrument
  46608. */
  46609. constructor(
  46610. /**
  46611. * Define the instrumented engine.
  46612. */
  46613. engine: Engine);
  46614. /**
  46615. * Dispose and release associated resources.
  46616. */
  46617. dispose(): void;
  46618. }
  46619. }
  46620. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  46621. import { PerfCounter } from "babylonjs/Misc/tools";
  46622. import { Scene, IDisposable } from "babylonjs/scene";
  46623. /**
  46624. * This class can be used to get instrumentation data from a Babylon engine
  46625. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  46626. */
  46627. export class SceneInstrumentation implements IDisposable {
  46628. /**
  46629. * Defines the scene to instrument
  46630. */
  46631. scene: Scene;
  46632. private _captureActiveMeshesEvaluationTime;
  46633. private _activeMeshesEvaluationTime;
  46634. private _captureRenderTargetsRenderTime;
  46635. private _renderTargetsRenderTime;
  46636. private _captureFrameTime;
  46637. private _frameTime;
  46638. private _captureRenderTime;
  46639. private _renderTime;
  46640. private _captureInterFrameTime;
  46641. private _interFrameTime;
  46642. private _captureParticlesRenderTime;
  46643. private _particlesRenderTime;
  46644. private _captureSpritesRenderTime;
  46645. private _spritesRenderTime;
  46646. private _capturePhysicsTime;
  46647. private _physicsTime;
  46648. private _captureAnimationsTime;
  46649. private _animationsTime;
  46650. private _captureCameraRenderTime;
  46651. private _cameraRenderTime;
  46652. private _onBeforeActiveMeshesEvaluationObserver;
  46653. private _onAfterActiveMeshesEvaluationObserver;
  46654. private _onBeforeRenderTargetsRenderObserver;
  46655. private _onAfterRenderTargetsRenderObserver;
  46656. private _onAfterRenderObserver;
  46657. private _onBeforeDrawPhaseObserver;
  46658. private _onAfterDrawPhaseObserver;
  46659. private _onBeforeAnimationsObserver;
  46660. private _onBeforeParticlesRenderingObserver;
  46661. private _onAfterParticlesRenderingObserver;
  46662. private _onBeforeSpritesRenderingObserver;
  46663. private _onAfterSpritesRenderingObserver;
  46664. private _onBeforePhysicsObserver;
  46665. private _onAfterPhysicsObserver;
  46666. private _onAfterAnimationsObserver;
  46667. private _onBeforeCameraRenderObserver;
  46668. private _onAfterCameraRenderObserver;
  46669. /**
  46670. * Gets the perf counter used for active meshes evaluation time
  46671. */
  46672. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  46673. /**
  46674. * Gets the active meshes evaluation time capture status
  46675. */
  46676. /**
  46677. * Enable or disable the active meshes evaluation time capture
  46678. */
  46679. captureActiveMeshesEvaluationTime: boolean;
  46680. /**
  46681. * Gets the perf counter used for render targets render time
  46682. */
  46683. readonly renderTargetsRenderTimeCounter: PerfCounter;
  46684. /**
  46685. * Gets the render targets render time capture status
  46686. */
  46687. /**
  46688. * Enable or disable the render targets render time capture
  46689. */
  46690. captureRenderTargetsRenderTime: boolean;
  46691. /**
  46692. * Gets the perf counter used for particles render time
  46693. */
  46694. readonly particlesRenderTimeCounter: PerfCounter;
  46695. /**
  46696. * Gets the particles render time capture status
  46697. */
  46698. /**
  46699. * Enable or disable the particles render time capture
  46700. */
  46701. captureParticlesRenderTime: boolean;
  46702. /**
  46703. * Gets the perf counter used for sprites render time
  46704. */
  46705. readonly spritesRenderTimeCounter: PerfCounter;
  46706. /**
  46707. * Gets the sprites render time capture status
  46708. */
  46709. /**
  46710. * Enable or disable the sprites render time capture
  46711. */
  46712. captureSpritesRenderTime: boolean;
  46713. /**
  46714. * Gets the perf counter used for physics time
  46715. */
  46716. readonly physicsTimeCounter: PerfCounter;
  46717. /**
  46718. * Gets the physics time capture status
  46719. */
  46720. /**
  46721. * Enable or disable the physics time capture
  46722. */
  46723. capturePhysicsTime: boolean;
  46724. /**
  46725. * Gets the perf counter used for animations time
  46726. */
  46727. readonly animationsTimeCounter: PerfCounter;
  46728. /**
  46729. * Gets the animations time capture status
  46730. */
  46731. /**
  46732. * Enable or disable the animations time capture
  46733. */
  46734. captureAnimationsTime: boolean;
  46735. /**
  46736. * Gets the perf counter used for frame time capture
  46737. */
  46738. readonly frameTimeCounter: PerfCounter;
  46739. /**
  46740. * Gets the frame time capture status
  46741. */
  46742. /**
  46743. * Enable or disable the frame time capture
  46744. */
  46745. captureFrameTime: boolean;
  46746. /**
  46747. * Gets the perf counter used for inter-frames time capture
  46748. */
  46749. readonly interFrameTimeCounter: PerfCounter;
  46750. /**
  46751. * Gets the inter-frames time capture status
  46752. */
  46753. /**
  46754. * Enable or disable the inter-frames time capture
  46755. */
  46756. captureInterFrameTime: boolean;
  46757. /**
  46758. * Gets the perf counter used for render time capture
  46759. */
  46760. readonly renderTimeCounter: PerfCounter;
  46761. /**
  46762. * Gets the render time capture status
  46763. */
  46764. /**
  46765. * Enable or disable the render time capture
  46766. */
  46767. captureRenderTime: boolean;
  46768. /**
  46769. * Gets the perf counter used for camera render time capture
  46770. */
  46771. readonly cameraRenderTimeCounter: PerfCounter;
  46772. /**
  46773. * Gets the camera render time capture status
  46774. */
  46775. /**
  46776. * Enable or disable the camera render time capture
  46777. */
  46778. captureCameraRenderTime: boolean;
  46779. /**
  46780. * Gets the perf counter used for draw calls
  46781. */
  46782. readonly drawCallsCounter: PerfCounter;
  46783. /**
  46784. * Gets the perf counter used for texture collisions
  46785. */
  46786. readonly textureCollisionsCounter: PerfCounter;
  46787. /**
  46788. * Instantiates a new scene instrumentation.
  46789. * This class can be used to get instrumentation data from a Babylon engine
  46790. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  46791. * @param scene Defines the scene to instrument
  46792. */
  46793. constructor(
  46794. /**
  46795. * Defines the scene to instrument
  46796. */
  46797. scene: Scene);
  46798. /**
  46799. * Dispose and release associated resources.
  46800. */
  46801. dispose(): void;
  46802. }
  46803. }
  46804. declare module "babylonjs/Instrumentation/index" {
  46805. export * from "babylonjs/Instrumentation/engineInstrumentation";
  46806. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  46807. export * from "babylonjs/Instrumentation/timeToken";
  46808. }
  46809. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  46810. /** @hidden */
  46811. export var glowMapGenerationPixelShader: {
  46812. name: string;
  46813. shader: string;
  46814. };
  46815. }
  46816. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  46817. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  46818. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  46819. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  46820. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  46821. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  46822. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  46823. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  46824. /** @hidden */
  46825. export var glowMapGenerationVertexShader: {
  46826. name: string;
  46827. shader: string;
  46828. };
  46829. }
  46830. declare module "babylonjs/Layers/effectLayer" {
  46831. import { Observable } from "babylonjs/Misc/observable";
  46832. import { Nullable } from "babylonjs/types";
  46833. import { Camera } from "babylonjs/Cameras/camera";
  46834. import { Scene } from "babylonjs/scene";
  46835. import { Color4, ISize } from "babylonjs/Maths/math";
  46836. import { Engine } from "babylonjs/Engines/engine";
  46837. import { SubMesh } from "babylonjs/Meshes/subMesh";
  46838. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46839. import { Mesh } from "babylonjs/Meshes/mesh";
  46840. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  46841. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46842. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  46843. import { Effect } from "babylonjs/Materials/effect";
  46844. import { Material } from "babylonjs/Materials/material";
  46845. import "babylonjs/Shaders/glowMapGeneration.fragment";
  46846. import "babylonjs/Shaders/glowMapGeneration.vertex";
  46847. /**
  46848. * Effect layer options. This helps customizing the behaviour
  46849. * of the effect layer.
  46850. */
  46851. export interface IEffectLayerOptions {
  46852. /**
  46853. * Multiplication factor apply to the canvas size to compute the render target size
  46854. * used to generated the objects (the smaller the faster).
  46855. */
  46856. mainTextureRatio: number;
  46857. /**
  46858. * Enforces a fixed size texture to ensure effect stability across devices.
  46859. */
  46860. mainTextureFixedSize?: number;
  46861. /**
  46862. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  46863. */
  46864. alphaBlendingMode: number;
  46865. /**
  46866. * The camera attached to the layer.
  46867. */
  46868. camera: Nullable<Camera>;
  46869. /**
  46870. * The rendering group to draw the layer in.
  46871. */
  46872. renderingGroupId: number;
  46873. }
  46874. /**
  46875. * The effect layer Helps adding post process effect blended with the main pass.
  46876. *
  46877. * This can be for instance use to generate glow or higlight effects on the scene.
  46878. *
  46879. * The effect layer class can not be used directly and is intented to inherited from to be
  46880. * customized per effects.
  46881. */
  46882. export abstract class EffectLayer {
  46883. private _vertexBuffers;
  46884. private _indexBuffer;
  46885. private _cachedDefines;
  46886. private _effectLayerMapGenerationEffect;
  46887. private _effectLayerOptions;
  46888. private _mergeEffect;
  46889. protected _scene: Scene;
  46890. protected _engine: Engine;
  46891. protected _maxSize: number;
  46892. protected _mainTextureDesiredSize: ISize;
  46893. protected _mainTexture: RenderTargetTexture;
  46894. protected _shouldRender: boolean;
  46895. protected _postProcesses: PostProcess[];
  46896. protected _textures: BaseTexture[];
  46897. protected _emissiveTextureAndColor: {
  46898. texture: Nullable<BaseTexture>;
  46899. color: Color4;
  46900. };
  46901. /**
  46902. * The name of the layer
  46903. */
  46904. name: string;
  46905. /**
  46906. * The clear color of the texture used to generate the glow map.
  46907. */
  46908. neutralColor: Color4;
  46909. /**
  46910. * Specifies wether the highlight layer is enabled or not.
  46911. */
  46912. isEnabled: boolean;
  46913. /**
  46914. * Gets the camera attached to the layer.
  46915. */
  46916. readonly camera: Nullable<Camera>;
  46917. /**
  46918. * Gets the rendering group id the layer should render in.
  46919. */
  46920. readonly renderingGroupId: number;
  46921. /**
  46922. * An event triggered when the effect layer has been disposed.
  46923. */
  46924. onDisposeObservable: Observable<EffectLayer>;
  46925. /**
  46926. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  46927. */
  46928. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  46929. /**
  46930. * An event triggered when the generated texture is being merged in the scene.
  46931. */
  46932. onBeforeComposeObservable: Observable<EffectLayer>;
  46933. /**
  46934. * An event triggered when the generated texture has been merged in the scene.
  46935. */
  46936. onAfterComposeObservable: Observable<EffectLayer>;
  46937. /**
  46938. * An event triggered when the efffect layer changes its size.
  46939. */
  46940. onSizeChangedObservable: Observable<EffectLayer>;
  46941. /** @hidden */
  46942. static _SceneComponentInitialization: (scene: Scene) => void;
  46943. /**
  46944. * Instantiates a new effect Layer and references it in the scene.
  46945. * @param name The name of the layer
  46946. * @param scene The scene to use the layer in
  46947. */
  46948. constructor(
  46949. /** The Friendly of the effect in the scene */
  46950. name: string, scene: Scene);
  46951. /**
  46952. * Get the effect name of the layer.
  46953. * @return The effect name
  46954. */
  46955. abstract getEffectName(): string;
  46956. /**
  46957. * Checks for the readiness of the element composing the layer.
  46958. * @param subMesh the mesh to check for
  46959. * @param useInstances specify wether or not to use instances to render the mesh
  46960. * @return true if ready otherwise, false
  46961. */
  46962. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  46963. /**
  46964. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  46965. * @returns true if the effect requires stencil during the main canvas render pass.
  46966. */
  46967. abstract needStencil(): boolean;
  46968. /**
  46969. * Create the merge effect. This is the shader use to blit the information back
  46970. * to the main canvas at the end of the scene rendering.
  46971. * @returns The effect containing the shader used to merge the effect on the main canvas
  46972. */
  46973. protected abstract _createMergeEffect(): Effect;
  46974. /**
  46975. * Creates the render target textures and post processes used in the effect layer.
  46976. */
  46977. protected abstract _createTextureAndPostProcesses(): void;
  46978. /**
  46979. * Implementation specific of rendering the generating effect on the main canvas.
  46980. * @param effect The effect used to render through
  46981. */
  46982. protected abstract _internalRender(effect: Effect): void;
  46983. /**
  46984. * Sets the required values for both the emissive texture and and the main color.
  46985. */
  46986. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  46987. /**
  46988. * Free any resources and references associated to a mesh.
  46989. * Internal use
  46990. * @param mesh The mesh to free.
  46991. */
  46992. abstract _disposeMesh(mesh: Mesh): void;
  46993. /**
  46994. * Serializes this layer (Glow or Highlight for example)
  46995. * @returns a serialized layer object
  46996. */
  46997. abstract serialize?(): any;
  46998. /**
  46999. * Initializes the effect layer with the required options.
  47000. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  47001. */
  47002. protected _init(options: Partial<IEffectLayerOptions>): void;
  47003. /**
  47004. * Generates the index buffer of the full screen quad blending to the main canvas.
  47005. */
  47006. private _generateIndexBuffer;
  47007. /**
  47008. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  47009. */
  47010. private _genrateVertexBuffer;
  47011. /**
  47012. * Sets the main texture desired size which is the closest power of two
  47013. * of the engine canvas size.
  47014. */
  47015. private _setMainTextureSize;
  47016. /**
  47017. * Creates the main texture for the effect layer.
  47018. */
  47019. protected _createMainTexture(): void;
  47020. /**
  47021. * Adds specific effects defines.
  47022. * @param defines The defines to add specifics to.
  47023. */
  47024. protected _addCustomEffectDefines(defines: string[]): void;
  47025. /**
  47026. * Checks for the readiness of the element composing the layer.
  47027. * @param subMesh the mesh to check for
  47028. * @param useInstances specify wether or not to use instances to render the mesh
  47029. * @param emissiveTexture the associated emissive texture used to generate the glow
  47030. * @return true if ready otherwise, false
  47031. */
  47032. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  47033. /**
  47034. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  47035. */
  47036. render(): void;
  47037. /**
  47038. * Determine if a given mesh will be used in the current effect.
  47039. * @param mesh mesh to test
  47040. * @returns true if the mesh will be used
  47041. */
  47042. hasMesh(mesh: AbstractMesh): boolean;
  47043. /**
  47044. * Returns true if the layer contains information to display, otherwise false.
  47045. * @returns true if the glow layer should be rendered
  47046. */
  47047. shouldRender(): boolean;
  47048. /**
  47049. * Returns true if the mesh should render, otherwise false.
  47050. * @param mesh The mesh to render
  47051. * @returns true if it should render otherwise false
  47052. */
  47053. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  47054. /**
  47055. * Returns true if the mesh can be rendered, otherwise false.
  47056. * @param mesh The mesh to render
  47057. * @param material The material used on the mesh
  47058. * @returns true if it can be rendered otherwise false
  47059. */
  47060. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  47061. /**
  47062. * Returns true if the mesh should render, otherwise false.
  47063. * @param mesh The mesh to render
  47064. * @returns true if it should render otherwise false
  47065. */
  47066. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  47067. /**
  47068. * Renders the submesh passed in parameter to the generation map.
  47069. */
  47070. protected _renderSubMesh(subMesh: SubMesh): void;
  47071. /**
  47072. * Rebuild the required buffers.
  47073. * @hidden Internal use only.
  47074. */
  47075. _rebuild(): void;
  47076. /**
  47077. * Dispose only the render target textures and post process.
  47078. */
  47079. private _disposeTextureAndPostProcesses;
  47080. /**
  47081. * Dispose the highlight layer and free resources.
  47082. */
  47083. dispose(): void;
  47084. /**
  47085. * Gets the class name of the effect layer
  47086. * @returns the string with the class name of the effect layer
  47087. */
  47088. getClassName(): string;
  47089. /**
  47090. * Creates an effect layer from parsed effect layer data
  47091. * @param parsedEffectLayer defines effect layer data
  47092. * @param scene defines the current scene
  47093. * @param rootUrl defines the root URL containing the effect layer information
  47094. * @returns a parsed effect Layer
  47095. */
  47096. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  47097. }
  47098. }
  47099. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  47100. import { Scene } from "babylonjs/scene";
  47101. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  47102. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  47103. import { AbstractScene } from "babylonjs/abstractScene";
  47104. module "babylonjs/abstractScene" {
  47105. interface AbstractScene {
  47106. /**
  47107. * The list of effect layers (highlights/glow) added to the scene
  47108. * @see http://doc.babylonjs.com/how_to/highlight_layer
  47109. * @see http://doc.babylonjs.com/how_to/glow_layer
  47110. */
  47111. effectLayers: Array<EffectLayer>;
  47112. /**
  47113. * Removes the given effect layer from this scene.
  47114. * @param toRemove defines the effect layer to remove
  47115. * @returns the index of the removed effect layer
  47116. */
  47117. removeEffectLayer(toRemove: EffectLayer): number;
  47118. /**
  47119. * Adds the given effect layer to this scene
  47120. * @param newEffectLayer defines the effect layer to add
  47121. */
  47122. addEffectLayer(newEffectLayer: EffectLayer): void;
  47123. }
  47124. }
  47125. /**
  47126. * Defines the layer scene component responsible to manage any effect layers
  47127. * in a given scene.
  47128. */
  47129. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  47130. /**
  47131. * The component name helpfull to identify the component in the list of scene components.
  47132. */
  47133. readonly name: string;
  47134. /**
  47135. * The scene the component belongs to.
  47136. */
  47137. scene: Scene;
  47138. private _engine;
  47139. private _renderEffects;
  47140. private _needStencil;
  47141. private _previousStencilState;
  47142. /**
  47143. * Creates a new instance of the component for the given scene
  47144. * @param scene Defines the scene to register the component in
  47145. */
  47146. constructor(scene: Scene);
  47147. /**
  47148. * Registers the component in a given scene
  47149. */
  47150. register(): void;
  47151. /**
  47152. * Rebuilds the elements related to this component in case of
  47153. * context lost for instance.
  47154. */
  47155. rebuild(): void;
  47156. /**
  47157. * Serializes the component data to the specified json object
  47158. * @param serializationObject The object to serialize to
  47159. */
  47160. serialize(serializationObject: any): void;
  47161. /**
  47162. * Adds all the element from the container to the scene
  47163. * @param container the container holding the elements
  47164. */
  47165. addFromContainer(container: AbstractScene): void;
  47166. /**
  47167. * Removes all the elements in the container from the scene
  47168. * @param container contains the elements to remove
  47169. */
  47170. removeFromContainer(container: AbstractScene): void;
  47171. /**
  47172. * Disposes the component and the associated ressources.
  47173. */
  47174. dispose(): void;
  47175. private _isReadyForMesh;
  47176. private _renderMainTexture;
  47177. private _setStencil;
  47178. private _setStencilBack;
  47179. private _draw;
  47180. private _drawCamera;
  47181. private _drawRenderingGroup;
  47182. }
  47183. }
  47184. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  47185. /** @hidden */
  47186. export var glowMapMergePixelShader: {
  47187. name: string;
  47188. shader: string;
  47189. };
  47190. }
  47191. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  47192. /** @hidden */
  47193. export var glowMapMergeVertexShader: {
  47194. name: string;
  47195. shader: string;
  47196. };
  47197. }
  47198. declare module "babylonjs/Layers/glowLayer" {
  47199. import { Nullable } from "babylonjs/types";
  47200. import { Camera } from "babylonjs/Cameras/camera";
  47201. import { Scene } from "babylonjs/scene";
  47202. import { Color4 } from "babylonjs/Maths/math";
  47203. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47204. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47205. import { Mesh } from "babylonjs/Meshes/mesh";
  47206. import { Texture } from "babylonjs/Materials/Textures/texture";
  47207. import { Effect } from "babylonjs/Materials/effect";
  47208. import { Material } from "babylonjs/Materials/material";
  47209. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  47210. import "babylonjs/Shaders/glowMapMerge.fragment";
  47211. import "babylonjs/Shaders/glowMapMerge.vertex";
  47212. import "babylonjs/Layers/effectLayerSceneComponent";
  47213. module "babylonjs/abstractScene" {
  47214. interface AbstractScene {
  47215. /**
  47216. * Return a the first highlight layer of the scene with a given name.
  47217. * @param name The name of the highlight layer to look for.
  47218. * @return The highlight layer if found otherwise null.
  47219. */
  47220. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  47221. }
  47222. }
  47223. /**
  47224. * Glow layer options. This helps customizing the behaviour
  47225. * of the glow layer.
  47226. */
  47227. export interface IGlowLayerOptions {
  47228. /**
  47229. * Multiplication factor apply to the canvas size to compute the render target size
  47230. * used to generated the glowing objects (the smaller the faster).
  47231. */
  47232. mainTextureRatio: number;
  47233. /**
  47234. * Enforces a fixed size texture to ensure resize independant blur.
  47235. */
  47236. mainTextureFixedSize?: number;
  47237. /**
  47238. * How big is the kernel of the blur texture.
  47239. */
  47240. blurKernelSize: number;
  47241. /**
  47242. * The camera attached to the layer.
  47243. */
  47244. camera: Nullable<Camera>;
  47245. /**
  47246. * Enable MSAA by chosing the number of samples.
  47247. */
  47248. mainTextureSamples?: number;
  47249. /**
  47250. * The rendering group to draw the layer in.
  47251. */
  47252. renderingGroupId: number;
  47253. }
  47254. /**
  47255. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  47256. *
  47257. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  47258. * glowy meshes to your scene.
  47259. *
  47260. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  47261. */
  47262. export class GlowLayer extends EffectLayer {
  47263. /**
  47264. * Effect Name of the layer.
  47265. */
  47266. static readonly EffectName: string;
  47267. /**
  47268. * The default blur kernel size used for the glow.
  47269. */
  47270. static DefaultBlurKernelSize: number;
  47271. /**
  47272. * The default texture size ratio used for the glow.
  47273. */
  47274. static DefaultTextureRatio: number;
  47275. /**
  47276. * Sets the kernel size of the blur.
  47277. */
  47278. /**
  47279. * Gets the kernel size of the blur.
  47280. */
  47281. blurKernelSize: number;
  47282. /**
  47283. * Sets the glow intensity.
  47284. */
  47285. /**
  47286. * Gets the glow intensity.
  47287. */
  47288. intensity: number;
  47289. private _options;
  47290. private _intensity;
  47291. private _horizontalBlurPostprocess1;
  47292. private _verticalBlurPostprocess1;
  47293. private _horizontalBlurPostprocess2;
  47294. private _verticalBlurPostprocess2;
  47295. private _blurTexture1;
  47296. private _blurTexture2;
  47297. private _postProcesses1;
  47298. private _postProcesses2;
  47299. private _includedOnlyMeshes;
  47300. private _excludedMeshes;
  47301. /**
  47302. * Callback used to let the user override the color selection on a per mesh basis
  47303. */
  47304. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  47305. /**
  47306. * Callback used to let the user override the texture selection on a per mesh basis
  47307. */
  47308. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  47309. /**
  47310. * Instantiates a new glow Layer and references it to the scene.
  47311. * @param name The name of the layer
  47312. * @param scene The scene to use the layer in
  47313. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  47314. */
  47315. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  47316. /**
  47317. * Get the effect name of the layer.
  47318. * @return The effect name
  47319. */
  47320. getEffectName(): string;
  47321. /**
  47322. * Create the merge effect. This is the shader use to blit the information back
  47323. * to the main canvas at the end of the scene rendering.
  47324. */
  47325. protected _createMergeEffect(): Effect;
  47326. /**
  47327. * Creates the render target textures and post processes used in the glow layer.
  47328. */
  47329. protected _createTextureAndPostProcesses(): void;
  47330. /**
  47331. * Checks for the readiness of the element composing the layer.
  47332. * @param subMesh the mesh to check for
  47333. * @param useInstances specify wether or not to use instances to render the mesh
  47334. * @param emissiveTexture the associated emissive texture used to generate the glow
  47335. * @return true if ready otherwise, false
  47336. */
  47337. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  47338. /**
  47339. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  47340. */
  47341. needStencil(): boolean;
  47342. /**
  47343. * Returns true if the mesh can be rendered, otherwise false.
  47344. * @param mesh The mesh to render
  47345. * @param material The material used on the mesh
  47346. * @returns true if it can be rendered otherwise false
  47347. */
  47348. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  47349. /**
  47350. * Implementation specific of rendering the generating effect on the main canvas.
  47351. * @param effect The effect used to render through
  47352. */
  47353. protected _internalRender(effect: Effect): void;
  47354. /**
  47355. * Sets the required values for both the emissive texture and and the main color.
  47356. */
  47357. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  47358. /**
  47359. * Returns true if the mesh should render, otherwise false.
  47360. * @param mesh The mesh to render
  47361. * @returns true if it should render otherwise false
  47362. */
  47363. protected _shouldRenderMesh(mesh: Mesh): boolean;
  47364. /**
  47365. * Adds specific effects defines.
  47366. * @param defines The defines to add specifics to.
  47367. */
  47368. protected _addCustomEffectDefines(defines: string[]): void;
  47369. /**
  47370. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  47371. * @param mesh The mesh to exclude from the glow layer
  47372. */
  47373. addExcludedMesh(mesh: Mesh): void;
  47374. /**
  47375. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  47376. * @param mesh The mesh to remove
  47377. */
  47378. removeExcludedMesh(mesh: Mesh): void;
  47379. /**
  47380. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  47381. * @param mesh The mesh to include in the glow layer
  47382. */
  47383. addIncludedOnlyMesh(mesh: Mesh): void;
  47384. /**
  47385. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  47386. * @param mesh The mesh to remove
  47387. */
  47388. removeIncludedOnlyMesh(mesh: Mesh): void;
  47389. /**
  47390. * Determine if a given mesh will be used in the glow layer
  47391. * @param mesh The mesh to test
  47392. * @returns true if the mesh will be highlighted by the current glow layer
  47393. */
  47394. hasMesh(mesh: AbstractMesh): boolean;
  47395. /**
  47396. * Free any resources and references associated to a mesh.
  47397. * Internal use
  47398. * @param mesh The mesh to free.
  47399. * @hidden
  47400. */
  47401. _disposeMesh(mesh: Mesh): void;
  47402. /**
  47403. * Gets the class name of the effect layer
  47404. * @returns the string with the class name of the effect layer
  47405. */
  47406. getClassName(): string;
  47407. /**
  47408. * Serializes this glow layer
  47409. * @returns a serialized glow layer object
  47410. */
  47411. serialize(): any;
  47412. /**
  47413. * Creates a Glow Layer from parsed glow layer data
  47414. * @param parsedGlowLayer defines glow layer data
  47415. * @param scene defines the current scene
  47416. * @param rootUrl defines the root URL containing the glow layer information
  47417. * @returns a parsed Glow Layer
  47418. */
  47419. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  47420. }
  47421. }
  47422. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  47423. /** @hidden */
  47424. export var glowBlurPostProcessPixelShader: {
  47425. name: string;
  47426. shader: string;
  47427. };
  47428. }
  47429. declare module "babylonjs/Layers/highlightLayer" {
  47430. import { Observable } from "babylonjs/Misc/observable";
  47431. import { Nullable } from "babylonjs/types";
  47432. import { Camera } from "babylonjs/Cameras/camera";
  47433. import { Scene } from "babylonjs/scene";
  47434. import { Color3, Color4 } from "babylonjs/Maths/math";
  47435. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47436. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47437. import { Mesh } from "babylonjs/Meshes/mesh";
  47438. import { Effect } from "babylonjs/Materials/effect";
  47439. import { Material } from "babylonjs/Materials/material";
  47440. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  47441. import "babylonjs/Shaders/glowMapMerge.fragment";
  47442. import "babylonjs/Shaders/glowMapMerge.vertex";
  47443. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  47444. module "babylonjs/abstractScene" {
  47445. interface AbstractScene {
  47446. /**
  47447. * Return a the first highlight layer of the scene with a given name.
  47448. * @param name The name of the highlight layer to look for.
  47449. * @return The highlight layer if found otherwise null.
  47450. */
  47451. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  47452. }
  47453. }
  47454. /**
  47455. * Highlight layer options. This helps customizing the behaviour
  47456. * of the highlight layer.
  47457. */
  47458. export interface IHighlightLayerOptions {
  47459. /**
  47460. * Multiplication factor apply to the canvas size to compute the render target size
  47461. * used to generated the glowing objects (the smaller the faster).
  47462. */
  47463. mainTextureRatio: number;
  47464. /**
  47465. * Enforces a fixed size texture to ensure resize independant blur.
  47466. */
  47467. mainTextureFixedSize?: number;
  47468. /**
  47469. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  47470. * of the picture to blur (the smaller the faster).
  47471. */
  47472. blurTextureSizeRatio: number;
  47473. /**
  47474. * How big in texel of the blur texture is the vertical blur.
  47475. */
  47476. blurVerticalSize: number;
  47477. /**
  47478. * How big in texel of the blur texture is the horizontal blur.
  47479. */
  47480. blurHorizontalSize: number;
  47481. /**
  47482. * Alpha blending mode used to apply the blur. Default is combine.
  47483. */
  47484. alphaBlendingMode: number;
  47485. /**
  47486. * The camera attached to the layer.
  47487. */
  47488. camera: Nullable<Camera>;
  47489. /**
  47490. * Should we display highlight as a solid stroke?
  47491. */
  47492. isStroke?: boolean;
  47493. /**
  47494. * The rendering group to draw the layer in.
  47495. */
  47496. renderingGroupId: number;
  47497. }
  47498. /**
  47499. * The highlight layer Helps adding a glow effect around a mesh.
  47500. *
  47501. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  47502. * glowy meshes to your scene.
  47503. *
  47504. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  47505. */
  47506. export class HighlightLayer extends EffectLayer {
  47507. name: string;
  47508. /**
  47509. * Effect Name of the highlight layer.
  47510. */
  47511. static readonly EffectName: string;
  47512. /**
  47513. * The neutral color used during the preparation of the glow effect.
  47514. * This is black by default as the blend operation is a blend operation.
  47515. */
  47516. static NeutralColor: Color4;
  47517. /**
  47518. * Stencil value used for glowing meshes.
  47519. */
  47520. static GlowingMeshStencilReference: number;
  47521. /**
  47522. * Stencil value used for the other meshes in the scene.
  47523. */
  47524. static NormalMeshStencilReference: number;
  47525. /**
  47526. * Specifies whether or not the inner glow is ACTIVE in the layer.
  47527. */
  47528. innerGlow: boolean;
  47529. /**
  47530. * Specifies whether or not the outer glow is ACTIVE in the layer.
  47531. */
  47532. outerGlow: boolean;
  47533. /**
  47534. * Specifies the horizontal size of the blur.
  47535. */
  47536. /**
  47537. * Gets the horizontal size of the blur.
  47538. */
  47539. blurHorizontalSize: number;
  47540. /**
  47541. * Specifies the vertical size of the blur.
  47542. */
  47543. /**
  47544. * Gets the vertical size of the blur.
  47545. */
  47546. blurVerticalSize: number;
  47547. /**
  47548. * An event triggered when the highlight layer is being blurred.
  47549. */
  47550. onBeforeBlurObservable: Observable<HighlightLayer>;
  47551. /**
  47552. * An event triggered when the highlight layer has been blurred.
  47553. */
  47554. onAfterBlurObservable: Observable<HighlightLayer>;
  47555. private _instanceGlowingMeshStencilReference;
  47556. private _options;
  47557. private _downSamplePostprocess;
  47558. private _horizontalBlurPostprocess;
  47559. private _verticalBlurPostprocess;
  47560. private _blurTexture;
  47561. private _meshes;
  47562. private _excludedMeshes;
  47563. /**
  47564. * Instantiates a new highlight Layer and references it to the scene..
  47565. * @param name The name of the layer
  47566. * @param scene The scene to use the layer in
  47567. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  47568. */
  47569. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  47570. /**
  47571. * Get the effect name of the layer.
  47572. * @return The effect name
  47573. */
  47574. getEffectName(): string;
  47575. /**
  47576. * Create the merge effect. This is the shader use to blit the information back
  47577. * to the main canvas at the end of the scene rendering.
  47578. */
  47579. protected _createMergeEffect(): Effect;
  47580. /**
  47581. * Creates the render target textures and post processes used in the highlight layer.
  47582. */
  47583. protected _createTextureAndPostProcesses(): void;
  47584. /**
  47585. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  47586. */
  47587. needStencil(): boolean;
  47588. /**
  47589. * Checks for the readiness of the element composing the layer.
  47590. * @param subMesh the mesh to check for
  47591. * @param useInstances specify wether or not to use instances to render the mesh
  47592. * @param emissiveTexture the associated emissive texture used to generate the glow
  47593. * @return true if ready otherwise, false
  47594. */
  47595. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  47596. /**
  47597. * Implementation specific of rendering the generating effect on the main canvas.
  47598. * @param effect The effect used to render through
  47599. */
  47600. protected _internalRender(effect: Effect): void;
  47601. /**
  47602. * Returns true if the layer contains information to display, otherwise false.
  47603. */
  47604. shouldRender(): boolean;
  47605. /**
  47606. * Returns true if the mesh should render, otherwise false.
  47607. * @param mesh The mesh to render
  47608. * @returns true if it should render otherwise false
  47609. */
  47610. protected _shouldRenderMesh(mesh: Mesh): boolean;
  47611. /**
  47612. * Sets the required values for both the emissive texture and and the main color.
  47613. */
  47614. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  47615. /**
  47616. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  47617. * @param mesh The mesh to exclude from the highlight layer
  47618. */
  47619. addExcludedMesh(mesh: Mesh): void;
  47620. /**
  47621. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  47622. * @param mesh The mesh to highlight
  47623. */
  47624. removeExcludedMesh(mesh: Mesh): void;
  47625. /**
  47626. * Determine if a given mesh will be highlighted by the current HighlightLayer
  47627. * @param mesh mesh to test
  47628. * @returns true if the mesh will be highlighted by the current HighlightLayer
  47629. */
  47630. hasMesh(mesh: AbstractMesh): boolean;
  47631. /**
  47632. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  47633. * @param mesh The mesh to highlight
  47634. * @param color The color of the highlight
  47635. * @param glowEmissiveOnly Extract the glow from the emissive texture
  47636. */
  47637. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  47638. /**
  47639. * Remove a mesh from the highlight layer in order to make it stop glowing.
  47640. * @param mesh The mesh to highlight
  47641. */
  47642. removeMesh(mesh: Mesh): void;
  47643. /**
  47644. * Force the stencil to the normal expected value for none glowing parts
  47645. */
  47646. private _defaultStencilReference;
  47647. /**
  47648. * Free any resources and references associated to a mesh.
  47649. * Internal use
  47650. * @param mesh The mesh to free.
  47651. * @hidden
  47652. */
  47653. _disposeMesh(mesh: Mesh): void;
  47654. /**
  47655. * Dispose the highlight layer and free resources.
  47656. */
  47657. dispose(): void;
  47658. /**
  47659. * Gets the class name of the effect layer
  47660. * @returns the string with the class name of the effect layer
  47661. */
  47662. getClassName(): string;
  47663. /**
  47664. * Serializes this Highlight layer
  47665. * @returns a serialized Highlight layer object
  47666. */
  47667. serialize(): any;
  47668. /**
  47669. * Creates a Highlight layer from parsed Highlight layer data
  47670. * @param parsedHightlightLayer defines the Highlight layer data
  47671. * @param scene defines the current scene
  47672. * @param rootUrl defines the root URL containing the Highlight layer information
  47673. * @returns a parsed Highlight layer
  47674. */
  47675. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  47676. }
  47677. }
  47678. declare module "babylonjs/Layers/index" {
  47679. export * from "babylonjs/Layers/effectLayer";
  47680. export * from "babylonjs/Layers/effectLayerSceneComponent";
  47681. export * from "babylonjs/Layers/glowLayer";
  47682. export * from "babylonjs/Layers/highlightLayer";
  47683. export * from "babylonjs/Layers/layer";
  47684. export * from "babylonjs/Layers/layerSceneComponent";
  47685. }
  47686. declare module "babylonjs/Shaders/lensFlare.fragment" {
  47687. /** @hidden */
  47688. export var lensFlarePixelShader: {
  47689. name: string;
  47690. shader: string;
  47691. };
  47692. }
  47693. declare module "babylonjs/Shaders/lensFlare.vertex" {
  47694. /** @hidden */
  47695. export var lensFlareVertexShader: {
  47696. name: string;
  47697. shader: string;
  47698. };
  47699. }
  47700. declare module "babylonjs/LensFlares/lensFlareSystem" {
  47701. import { Scene } from "babylonjs/scene";
  47702. import { Vector3, Viewport } from "babylonjs/Maths/math";
  47703. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47704. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  47705. import "babylonjs/Shaders/lensFlare.fragment";
  47706. import "babylonjs/Shaders/lensFlare.vertex";
  47707. /**
  47708. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  47709. * It is usually composed of several `lensFlare`.
  47710. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47711. */
  47712. export class LensFlareSystem {
  47713. /**
  47714. * Define the name of the lens flare system
  47715. */
  47716. name: string;
  47717. /**
  47718. * List of lens flares used in this system.
  47719. */
  47720. lensFlares: LensFlare[];
  47721. /**
  47722. * Define a limit from the border the lens flare can be visible.
  47723. */
  47724. borderLimit: number;
  47725. /**
  47726. * Define a viewport border we do not want to see the lens flare in.
  47727. */
  47728. viewportBorder: number;
  47729. /**
  47730. * Define a predicate which could limit the list of meshes able to occlude the effect.
  47731. */
  47732. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  47733. /**
  47734. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  47735. */
  47736. layerMask: number;
  47737. /**
  47738. * Define the id of the lens flare system in the scene.
  47739. * (equal to name by default)
  47740. */
  47741. id: string;
  47742. private _scene;
  47743. private _emitter;
  47744. private _vertexBuffers;
  47745. private _indexBuffer;
  47746. private _effect;
  47747. private _positionX;
  47748. private _positionY;
  47749. private _isEnabled;
  47750. /** @hidden */
  47751. static _SceneComponentInitialization: (scene: Scene) => void;
  47752. /**
  47753. * Instantiates a lens flare system.
  47754. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  47755. * It is usually composed of several `lensFlare`.
  47756. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47757. * @param name Define the name of the lens flare system in the scene
  47758. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  47759. * @param scene Define the scene the lens flare system belongs to
  47760. */
  47761. constructor(
  47762. /**
  47763. * Define the name of the lens flare system
  47764. */
  47765. name: string, emitter: any, scene: Scene);
  47766. /**
  47767. * Define if the lens flare system is enabled.
  47768. */
  47769. isEnabled: boolean;
  47770. /**
  47771. * Get the scene the effects belongs to.
  47772. * @returns the scene holding the lens flare system
  47773. */
  47774. getScene(): Scene;
  47775. /**
  47776. * Get the emitter of the lens flare system.
  47777. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  47778. * @returns the emitter of the lens flare system
  47779. */
  47780. getEmitter(): any;
  47781. /**
  47782. * Set the emitter of the lens flare system.
  47783. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  47784. * @param newEmitter Define the new emitter of the system
  47785. */
  47786. setEmitter(newEmitter: any): void;
  47787. /**
  47788. * Get the lens flare system emitter position.
  47789. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  47790. * @returns the position
  47791. */
  47792. getEmitterPosition(): Vector3;
  47793. /**
  47794. * @hidden
  47795. */
  47796. computeEffectivePosition(globalViewport: Viewport): boolean;
  47797. /** @hidden */
  47798. _isVisible(): boolean;
  47799. /**
  47800. * @hidden
  47801. */
  47802. render(): boolean;
  47803. /**
  47804. * Dispose and release the lens flare with its associated resources.
  47805. */
  47806. dispose(): void;
  47807. /**
  47808. * Parse a lens flare system from a JSON repressentation
  47809. * @param parsedLensFlareSystem Define the JSON to parse
  47810. * @param scene Define the scene the parsed system should be instantiated in
  47811. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  47812. * @returns the parsed system
  47813. */
  47814. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  47815. /**
  47816. * Serialize the current Lens Flare System into a JSON representation.
  47817. * @returns the serialized JSON
  47818. */
  47819. serialize(): any;
  47820. }
  47821. }
  47822. declare module "babylonjs/LensFlares/lensFlare" {
  47823. import { Nullable } from "babylonjs/types";
  47824. import { Color3 } from "babylonjs/Maths/math";
  47825. import { Texture } from "babylonjs/Materials/Textures/texture";
  47826. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  47827. /**
  47828. * This represents one of the lens effect in a `lensFlareSystem`.
  47829. * It controls one of the indiviual texture used in the effect.
  47830. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47831. */
  47832. export class LensFlare {
  47833. /**
  47834. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  47835. */
  47836. size: number;
  47837. /**
  47838. * 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.
  47839. */
  47840. position: number;
  47841. /**
  47842. * Define the lens color.
  47843. */
  47844. color: Color3;
  47845. /**
  47846. * Define the lens texture.
  47847. */
  47848. texture: Nullable<Texture>;
  47849. /**
  47850. * Define the alpha mode to render this particular lens.
  47851. */
  47852. alphaMode: number;
  47853. private _system;
  47854. /**
  47855. * Creates a new Lens Flare.
  47856. * This represents one of the lens effect in a `lensFlareSystem`.
  47857. * It controls one of the indiviual texture used in the effect.
  47858. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47859. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  47860. * @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.
  47861. * @param color Define the lens color
  47862. * @param imgUrl Define the lens texture url
  47863. * @param system Define the `lensFlareSystem` this flare is part of
  47864. * @returns The newly created Lens Flare
  47865. */
  47866. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  47867. /**
  47868. * Instantiates a new Lens Flare.
  47869. * This represents one of the lens effect in a `lensFlareSystem`.
  47870. * It controls one of the indiviual texture used in the effect.
  47871. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47872. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  47873. * @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.
  47874. * @param color Define the lens color
  47875. * @param imgUrl Define the lens texture url
  47876. * @param system Define the `lensFlareSystem` this flare is part of
  47877. */
  47878. constructor(
  47879. /**
  47880. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  47881. */
  47882. size: number,
  47883. /**
  47884. * 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.
  47885. */
  47886. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  47887. /**
  47888. * Dispose and release the lens flare with its associated resources.
  47889. */
  47890. dispose(): void;
  47891. }
  47892. }
  47893. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  47894. import { Nullable } from "babylonjs/types";
  47895. import { Scene } from "babylonjs/scene";
  47896. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  47897. import { AbstractScene } from "babylonjs/abstractScene";
  47898. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  47899. module "babylonjs/abstractScene" {
  47900. interface AbstractScene {
  47901. /**
  47902. * The list of lens flare system added to the scene
  47903. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47904. */
  47905. lensFlareSystems: Array<LensFlareSystem>;
  47906. /**
  47907. * Removes the given lens flare system from this scene.
  47908. * @param toRemove The lens flare system to remove
  47909. * @returns The index of the removed lens flare system
  47910. */
  47911. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  47912. /**
  47913. * Adds the given lens flare system to this scene
  47914. * @param newLensFlareSystem The lens flare system to add
  47915. */
  47916. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  47917. /**
  47918. * Gets a lens flare system using its name
  47919. * @param name defines the name to look for
  47920. * @returns the lens flare system or null if not found
  47921. */
  47922. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  47923. /**
  47924. * Gets a lens flare system using its id
  47925. * @param id defines the id to look for
  47926. * @returns the lens flare system or null if not found
  47927. */
  47928. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  47929. }
  47930. }
  47931. /**
  47932. * Defines the lens flare scene component responsible to manage any lens flares
  47933. * in a given scene.
  47934. */
  47935. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  47936. /**
  47937. * The component name helpfull to identify the component in the list of scene components.
  47938. */
  47939. readonly name: string;
  47940. /**
  47941. * The scene the component belongs to.
  47942. */
  47943. scene: Scene;
  47944. /**
  47945. * Creates a new instance of the component for the given scene
  47946. * @param scene Defines the scene to register the component in
  47947. */
  47948. constructor(scene: Scene);
  47949. /**
  47950. * Registers the component in a given scene
  47951. */
  47952. register(): void;
  47953. /**
  47954. * Rebuilds the elements related to this component in case of
  47955. * context lost for instance.
  47956. */
  47957. rebuild(): void;
  47958. /**
  47959. * Adds all the element from the container to the scene
  47960. * @param container the container holding the elements
  47961. */
  47962. addFromContainer(container: AbstractScene): void;
  47963. /**
  47964. * Removes all the elements in the container from the scene
  47965. * @param container contains the elements to remove
  47966. */
  47967. removeFromContainer(container: AbstractScene): void;
  47968. /**
  47969. * Serializes the component data to the specified json object
  47970. * @param serializationObject The object to serialize to
  47971. */
  47972. serialize(serializationObject: any): void;
  47973. /**
  47974. * Disposes the component and the associated ressources.
  47975. */
  47976. dispose(): void;
  47977. private _draw;
  47978. }
  47979. }
  47980. declare module "babylonjs/LensFlares/index" {
  47981. export * from "babylonjs/LensFlares/lensFlare";
  47982. export * from "babylonjs/LensFlares/lensFlareSystem";
  47983. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  47984. }
  47985. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  47986. import { Scene } from "babylonjs/scene";
  47987. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  47988. import { AbstractScene } from "babylonjs/abstractScene";
  47989. /**
  47990. * Defines the shadow generator component responsible to manage any shadow generators
  47991. * in a given scene.
  47992. */
  47993. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  47994. /**
  47995. * The component name helpfull to identify the component in the list of scene components.
  47996. */
  47997. readonly name: string;
  47998. /**
  47999. * The scene the component belongs to.
  48000. */
  48001. scene: Scene;
  48002. /**
  48003. * Creates a new instance of the component for the given scene
  48004. * @param scene Defines the scene to register the component in
  48005. */
  48006. constructor(scene: Scene);
  48007. /**
  48008. * Registers the component in a given scene
  48009. */
  48010. register(): void;
  48011. /**
  48012. * Rebuilds the elements related to this component in case of
  48013. * context lost for instance.
  48014. */
  48015. rebuild(): void;
  48016. /**
  48017. * Serializes the component data to the specified json object
  48018. * @param serializationObject The object to serialize to
  48019. */
  48020. serialize(serializationObject: any): void;
  48021. /**
  48022. * Adds all the element from the container to the scene
  48023. * @param container the container holding the elements
  48024. */
  48025. addFromContainer(container: AbstractScene): void;
  48026. /**
  48027. * Removes all the elements in the container from the scene
  48028. * @param container contains the elements to remove
  48029. */
  48030. removeFromContainer(container: AbstractScene): void;
  48031. /**
  48032. * Rebuilds the elements related to this component in case of
  48033. * context lost for instance.
  48034. */
  48035. dispose(): void;
  48036. private _gatherRenderTargets;
  48037. }
  48038. }
  48039. declare module "babylonjs/Lights/Shadows/index" {
  48040. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  48041. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  48042. }
  48043. declare module "babylonjs/Lights/directionalLight" {
  48044. import { Camera } from "babylonjs/Cameras/camera";
  48045. import { Scene } from "babylonjs/scene";
  48046. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  48047. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48048. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  48049. import { Effect } from "babylonjs/Materials/effect";
  48050. /**
  48051. * A directional light is defined by a direction (what a surprise!).
  48052. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  48053. * 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.
  48054. * Documentation: https://doc.babylonjs.com/babylon101/lights
  48055. */
  48056. export class DirectionalLight extends ShadowLight {
  48057. private _shadowFrustumSize;
  48058. /**
  48059. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  48060. */
  48061. /**
  48062. * Specifies a fix frustum size for the shadow generation.
  48063. */
  48064. shadowFrustumSize: number;
  48065. private _shadowOrthoScale;
  48066. /**
  48067. * Gets the shadow projection scale against the optimal computed one.
  48068. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  48069. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  48070. */
  48071. /**
  48072. * Sets the shadow projection scale against the optimal computed one.
  48073. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  48074. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  48075. */
  48076. shadowOrthoScale: number;
  48077. /**
  48078. * Automatically compute the projection matrix to best fit (including all the casters)
  48079. * on each frame.
  48080. */
  48081. autoUpdateExtends: boolean;
  48082. private _orthoLeft;
  48083. private _orthoRight;
  48084. private _orthoTop;
  48085. private _orthoBottom;
  48086. /**
  48087. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  48088. * The directional light is emitted from everywhere in the given direction.
  48089. * It can cast shadows.
  48090. * Documentation : https://doc.babylonjs.com/babylon101/lights
  48091. * @param name The friendly name of the light
  48092. * @param direction The direction of the light
  48093. * @param scene The scene the light belongs to
  48094. */
  48095. constructor(name: string, direction: Vector3, scene: Scene);
  48096. /**
  48097. * Returns the string "DirectionalLight".
  48098. * @return The class name
  48099. */
  48100. getClassName(): string;
  48101. /**
  48102. * Returns the integer 1.
  48103. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  48104. */
  48105. getTypeID(): number;
  48106. /**
  48107. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  48108. * Returns the DirectionalLight Shadow projection matrix.
  48109. */
  48110. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48111. /**
  48112. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  48113. * Returns the DirectionalLight Shadow projection matrix.
  48114. */
  48115. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  48116. /**
  48117. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  48118. * Returns the DirectionalLight Shadow projection matrix.
  48119. */
  48120. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48121. protected _buildUniformLayout(): void;
  48122. /**
  48123. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  48124. * @param effect The effect to update
  48125. * @param lightIndex The index of the light in the effect to update
  48126. * @returns The directional light
  48127. */
  48128. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  48129. /**
  48130. * Gets the minZ used for shadow according to both the scene and the light.
  48131. *
  48132. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  48133. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  48134. * @param activeCamera The camera we are returning the min for
  48135. * @returns the depth min z
  48136. */
  48137. getDepthMinZ(activeCamera: Camera): number;
  48138. /**
  48139. * Gets the maxZ used for shadow according to both the scene and the light.
  48140. *
  48141. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  48142. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  48143. * @param activeCamera The camera we are returning the max for
  48144. * @returns the depth max z
  48145. */
  48146. getDepthMaxZ(activeCamera: Camera): number;
  48147. /**
  48148. * Prepares the list of defines specific to the light type.
  48149. * @param defines the list of defines
  48150. * @param lightIndex defines the index of the light for the effect
  48151. */
  48152. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  48153. }
  48154. }
  48155. declare module "babylonjs/Lights/pointLight" {
  48156. import { Scene } from "babylonjs/scene";
  48157. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  48158. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48159. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  48160. import { Effect } from "babylonjs/Materials/effect";
  48161. /**
  48162. * A point light is a light defined by an unique point in world space.
  48163. * The light is emitted in every direction from this point.
  48164. * A good example of a point light is a standard light bulb.
  48165. * Documentation: https://doc.babylonjs.com/babylon101/lights
  48166. */
  48167. export class PointLight extends ShadowLight {
  48168. private _shadowAngle;
  48169. /**
  48170. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  48171. * This specifies what angle the shadow will use to be created.
  48172. *
  48173. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  48174. */
  48175. /**
  48176. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  48177. * This specifies what angle the shadow will use to be created.
  48178. *
  48179. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  48180. */
  48181. shadowAngle: number;
  48182. /**
  48183. * Gets the direction if it has been set.
  48184. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  48185. */
  48186. /**
  48187. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  48188. */
  48189. direction: Vector3;
  48190. /**
  48191. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  48192. * A PointLight emits the light in every direction.
  48193. * It can cast shadows.
  48194. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  48195. * ```javascript
  48196. * var pointLight = new PointLight("pl", camera.position, scene);
  48197. * ```
  48198. * Documentation : https://doc.babylonjs.com/babylon101/lights
  48199. * @param name The light friendly name
  48200. * @param position The position of the point light in the scene
  48201. * @param scene The scene the lights belongs to
  48202. */
  48203. constructor(name: string, position: Vector3, scene: Scene);
  48204. /**
  48205. * Returns the string "PointLight"
  48206. * @returns the class name
  48207. */
  48208. getClassName(): string;
  48209. /**
  48210. * Returns the integer 0.
  48211. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  48212. */
  48213. getTypeID(): number;
  48214. /**
  48215. * Specifies wether or not the shadowmap should be a cube texture.
  48216. * @returns true if the shadowmap needs to be a cube texture.
  48217. */
  48218. needCube(): boolean;
  48219. /**
  48220. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  48221. * @param faceIndex The index of the face we are computed the direction to generate shadow
  48222. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  48223. */
  48224. getShadowDirection(faceIndex?: number): Vector3;
  48225. /**
  48226. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  48227. * - fov = PI / 2
  48228. * - aspect ratio : 1.0
  48229. * - z-near and far equal to the active camera minZ and maxZ.
  48230. * Returns the PointLight.
  48231. */
  48232. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48233. protected _buildUniformLayout(): void;
  48234. /**
  48235. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  48236. * @param effect The effect to update
  48237. * @param lightIndex The index of the light in the effect to update
  48238. * @returns The point light
  48239. */
  48240. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  48241. /**
  48242. * Prepares the list of defines specific to the light type.
  48243. * @param defines the list of defines
  48244. * @param lightIndex defines the index of the light for the effect
  48245. */
  48246. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  48247. }
  48248. }
  48249. declare module "babylonjs/Lights/spotLight" {
  48250. import { Nullable } from "babylonjs/types";
  48251. import { Scene } from "babylonjs/scene";
  48252. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  48253. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48254. import { Effect } from "babylonjs/Materials/effect";
  48255. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48256. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  48257. /**
  48258. * A spot light is defined by a position, a direction, an angle, and an exponent.
  48259. * These values define a cone of light starting from the position, emitting toward the direction.
  48260. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  48261. * and the exponent defines the speed of the decay of the light with distance (reach).
  48262. * Documentation: https://doc.babylonjs.com/babylon101/lights
  48263. */
  48264. export class SpotLight extends ShadowLight {
  48265. private _angle;
  48266. private _innerAngle;
  48267. private _cosHalfAngle;
  48268. private _lightAngleScale;
  48269. private _lightAngleOffset;
  48270. /**
  48271. * Gets the cone angle of the spot light in Radians.
  48272. */
  48273. /**
  48274. * Sets the cone angle of the spot light in Radians.
  48275. */
  48276. angle: number;
  48277. /**
  48278. * Only used in gltf falloff mode, this defines the angle where
  48279. * the directional falloff will start before cutting at angle which could be seen
  48280. * as outer angle.
  48281. */
  48282. /**
  48283. * Only used in gltf falloff mode, this defines the angle where
  48284. * the directional falloff will start before cutting at angle which could be seen
  48285. * as outer angle.
  48286. */
  48287. innerAngle: number;
  48288. private _shadowAngleScale;
  48289. /**
  48290. * Allows scaling the angle of the light for shadow generation only.
  48291. */
  48292. /**
  48293. * Allows scaling the angle of the light for shadow generation only.
  48294. */
  48295. shadowAngleScale: number;
  48296. /**
  48297. * The light decay speed with the distance from the emission spot.
  48298. */
  48299. exponent: number;
  48300. private _projectionTextureMatrix;
  48301. /**
  48302. * Allows reading the projecton texture
  48303. */
  48304. readonly projectionTextureMatrix: Matrix;
  48305. protected _projectionTextureLightNear: number;
  48306. /**
  48307. * Gets the near clip of the Spotlight for texture projection.
  48308. */
  48309. /**
  48310. * Sets the near clip of the Spotlight for texture projection.
  48311. */
  48312. projectionTextureLightNear: number;
  48313. protected _projectionTextureLightFar: number;
  48314. /**
  48315. * Gets the far clip of the Spotlight for texture projection.
  48316. */
  48317. /**
  48318. * Sets the far clip of the Spotlight for texture projection.
  48319. */
  48320. projectionTextureLightFar: number;
  48321. protected _projectionTextureUpDirection: Vector3;
  48322. /**
  48323. * Gets the Up vector of the Spotlight for texture projection.
  48324. */
  48325. /**
  48326. * Sets the Up vector of the Spotlight for texture projection.
  48327. */
  48328. projectionTextureUpDirection: Vector3;
  48329. private _projectionTexture;
  48330. /**
  48331. * Gets the projection texture of the light.
  48332. */
  48333. /**
  48334. * Sets the projection texture of the light.
  48335. */
  48336. projectionTexture: Nullable<BaseTexture>;
  48337. private _projectionTextureViewLightDirty;
  48338. private _projectionTextureProjectionLightDirty;
  48339. private _projectionTextureDirty;
  48340. private _projectionTextureViewTargetVector;
  48341. private _projectionTextureViewLightMatrix;
  48342. private _projectionTextureProjectionLightMatrix;
  48343. private _projectionTextureScalingMatrix;
  48344. /**
  48345. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  48346. * It can cast shadows.
  48347. * Documentation : https://doc.babylonjs.com/babylon101/lights
  48348. * @param name The light friendly name
  48349. * @param position The position of the spot light in the scene
  48350. * @param direction The direction of the light in the scene
  48351. * @param angle The cone angle of the light in Radians
  48352. * @param exponent The light decay speed with the distance from the emission spot
  48353. * @param scene The scene the lights belongs to
  48354. */
  48355. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  48356. /**
  48357. * Returns the string "SpotLight".
  48358. * @returns the class name
  48359. */
  48360. getClassName(): string;
  48361. /**
  48362. * Returns the integer 2.
  48363. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  48364. */
  48365. getTypeID(): number;
  48366. /**
  48367. * Overrides the direction setter to recompute the projection texture view light Matrix.
  48368. */
  48369. protected _setDirection(value: Vector3): void;
  48370. /**
  48371. * Overrides the position setter to recompute the projection texture view light Matrix.
  48372. */
  48373. protected _setPosition(value: Vector3): void;
  48374. /**
  48375. * 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.
  48376. * Returns the SpotLight.
  48377. */
  48378. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48379. protected _computeProjectionTextureViewLightMatrix(): void;
  48380. protected _computeProjectionTextureProjectionLightMatrix(): void;
  48381. /**
  48382. * Main function for light texture projection matrix computing.
  48383. */
  48384. protected _computeProjectionTextureMatrix(): void;
  48385. protected _buildUniformLayout(): void;
  48386. private _computeAngleValues;
  48387. /**
  48388. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  48389. * @param effect The effect to update
  48390. * @param lightIndex The index of the light in the effect to update
  48391. * @returns The spot light
  48392. */
  48393. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  48394. /**
  48395. * Disposes the light and the associated resources.
  48396. */
  48397. dispose(): void;
  48398. /**
  48399. * Prepares the list of defines specific to the light type.
  48400. * @param defines the list of defines
  48401. * @param lightIndex defines the index of the light for the effect
  48402. */
  48403. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  48404. }
  48405. }
  48406. declare module "babylonjs/Lights/index" {
  48407. export * from "babylonjs/Lights/light";
  48408. export * from "babylonjs/Lights/shadowLight";
  48409. export * from "babylonjs/Lights/Shadows/index";
  48410. export * from "babylonjs/Lights/directionalLight";
  48411. export * from "babylonjs/Lights/hemisphericLight";
  48412. export * from "babylonjs/Lights/pointLight";
  48413. export * from "babylonjs/Lights/spotLight";
  48414. }
  48415. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  48416. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  48417. /**
  48418. * Header information of HDR texture files.
  48419. */
  48420. export interface HDRInfo {
  48421. /**
  48422. * The height of the texture in pixels.
  48423. */
  48424. height: number;
  48425. /**
  48426. * The width of the texture in pixels.
  48427. */
  48428. width: number;
  48429. /**
  48430. * The index of the beginning of the data in the binary file.
  48431. */
  48432. dataPosition: number;
  48433. }
  48434. /**
  48435. * This groups tools to convert HDR texture to native colors array.
  48436. */
  48437. export class HDRTools {
  48438. private static Ldexp;
  48439. private static Rgbe2float;
  48440. private static readStringLine;
  48441. /**
  48442. * Reads header information from an RGBE texture stored in a native array.
  48443. * More information on this format are available here:
  48444. * https://en.wikipedia.org/wiki/RGBE_image_format
  48445. *
  48446. * @param uint8array The binary file stored in native array.
  48447. * @return The header information.
  48448. */
  48449. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  48450. /**
  48451. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  48452. * This RGBE texture needs to store the information as a panorama.
  48453. *
  48454. * More information on this format are available here:
  48455. * https://en.wikipedia.org/wiki/RGBE_image_format
  48456. *
  48457. * @param buffer The binary file stored in an array buffer.
  48458. * @param size The expected size of the extracted cubemap.
  48459. * @return The Cube Map information.
  48460. */
  48461. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  48462. /**
  48463. * Returns the pixels data extracted from an RGBE texture.
  48464. * This pixels will be stored left to right up to down in the R G B order in one array.
  48465. *
  48466. * More information on this format are available here:
  48467. * https://en.wikipedia.org/wiki/RGBE_image_format
  48468. *
  48469. * @param uint8array The binary file stored in an array buffer.
  48470. * @param hdrInfo The header information of the file.
  48471. * @return The pixels data in RGB right to left up to down order.
  48472. */
  48473. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  48474. private static RGBE_ReadPixels_RLE;
  48475. }
  48476. }
  48477. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  48478. import { Nullable } from "babylonjs/types";
  48479. import { Scene } from "babylonjs/scene";
  48480. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  48481. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48482. /**
  48483. * This represents a texture coming from an HDR input.
  48484. *
  48485. * The only supported format is currently panorama picture stored in RGBE format.
  48486. * Example of such files can be found on HDRLib: http://hdrlib.com/
  48487. */
  48488. export class HDRCubeTexture extends BaseTexture {
  48489. private static _facesMapping;
  48490. private _generateHarmonics;
  48491. private _noMipmap;
  48492. private _textureMatrix;
  48493. private _size;
  48494. private _onLoad;
  48495. private _onError;
  48496. /**
  48497. * The texture URL.
  48498. */
  48499. url: string;
  48500. /**
  48501. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  48502. */
  48503. coordinatesMode: number;
  48504. protected _isBlocking: boolean;
  48505. /**
  48506. * Sets wether or not the texture is blocking during loading.
  48507. */
  48508. /**
  48509. * Gets wether or not the texture is blocking during loading.
  48510. */
  48511. isBlocking: boolean;
  48512. protected _rotationY: number;
  48513. /**
  48514. * Sets texture matrix rotation angle around Y axis in radians.
  48515. */
  48516. /**
  48517. * Gets texture matrix rotation angle around Y axis radians.
  48518. */
  48519. rotationY: number;
  48520. /**
  48521. * Gets or sets the center of the bounding box associated with the cube texture
  48522. * It must define where the camera used to render the texture was set
  48523. */
  48524. boundingBoxPosition: Vector3;
  48525. private _boundingBoxSize;
  48526. /**
  48527. * Gets or sets the size of the bounding box associated with the cube texture
  48528. * When defined, the cubemap will switch to local mode
  48529. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  48530. * @example https://www.babylonjs-playground.com/#RNASML
  48531. */
  48532. boundingBoxSize: Vector3;
  48533. /**
  48534. * Instantiates an HDRTexture from the following parameters.
  48535. *
  48536. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  48537. * @param scene The scene the texture will be used in
  48538. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  48539. * @param noMipmap Forces to not generate the mipmap if true
  48540. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  48541. * @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)
  48542. * @param reserved Reserved flag for internal use.
  48543. */
  48544. 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>);
  48545. /**
  48546. * Get the current class name of the texture useful for serialization or dynamic coding.
  48547. * @returns "HDRCubeTexture"
  48548. */
  48549. getClassName(): string;
  48550. /**
  48551. * Occurs when the file is raw .hdr file.
  48552. */
  48553. private loadTexture;
  48554. clone(): HDRCubeTexture;
  48555. delayLoad(): void;
  48556. /**
  48557. * Get the texture reflection matrix used to rotate/transform the reflection.
  48558. * @returns the reflection matrix
  48559. */
  48560. getReflectionTextureMatrix(): Matrix;
  48561. /**
  48562. * Set the texture reflection matrix used to rotate/transform the reflection.
  48563. * @param value Define the reflection matrix to set
  48564. */
  48565. setReflectionTextureMatrix(value: Matrix): void;
  48566. /**
  48567. * Parses a JSON representation of an HDR Texture in order to create the texture
  48568. * @param parsedTexture Define the JSON representation
  48569. * @param scene Define the scene the texture should be created in
  48570. * @param rootUrl Define the root url in case we need to load relative dependencies
  48571. * @returns the newly created texture after parsing
  48572. */
  48573. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  48574. serialize(): any;
  48575. }
  48576. }
  48577. declare module "babylonjs/Physics/physicsEngine" {
  48578. import { Nullable } from "babylonjs/types";
  48579. import { Vector3 } from "babylonjs/Maths/math";
  48580. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  48581. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  48582. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  48583. /**
  48584. * Class used to control physics engine
  48585. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  48586. */
  48587. export class PhysicsEngine implements IPhysicsEngine {
  48588. private _physicsPlugin;
  48589. /**
  48590. * Global value used to control the smallest number supported by the simulation
  48591. */
  48592. static Epsilon: number;
  48593. private _impostors;
  48594. private _joints;
  48595. /**
  48596. * Gets the gravity vector used by the simulation
  48597. */
  48598. gravity: Vector3;
  48599. /**
  48600. * Factory used to create the default physics plugin.
  48601. * @returns The default physics plugin
  48602. */
  48603. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  48604. /**
  48605. * Creates a new Physics Engine
  48606. * @param gravity defines the gravity vector used by the simulation
  48607. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  48608. */
  48609. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  48610. /**
  48611. * Sets the gravity vector used by the simulation
  48612. * @param gravity defines the gravity vector to use
  48613. */
  48614. setGravity(gravity: Vector3): void;
  48615. /**
  48616. * Set the time step of the physics engine.
  48617. * Default is 1/60.
  48618. * To slow it down, enter 1/600 for example.
  48619. * To speed it up, 1/30
  48620. * @param newTimeStep defines the new timestep to apply to this world.
  48621. */
  48622. setTimeStep(newTimeStep?: number): void;
  48623. /**
  48624. * Get the time step of the physics engine.
  48625. * @returns the current time step
  48626. */
  48627. getTimeStep(): number;
  48628. /**
  48629. * Release all resources
  48630. */
  48631. dispose(): void;
  48632. /**
  48633. * Gets the name of the current physics plugin
  48634. * @returns the name of the plugin
  48635. */
  48636. getPhysicsPluginName(): string;
  48637. /**
  48638. * Adding a new impostor for the impostor tracking.
  48639. * This will be done by the impostor itself.
  48640. * @param impostor the impostor to add
  48641. */
  48642. addImpostor(impostor: PhysicsImpostor): void;
  48643. /**
  48644. * Remove an impostor from the engine.
  48645. * This impostor and its mesh will not longer be updated by the physics engine.
  48646. * @param impostor the impostor to remove
  48647. */
  48648. removeImpostor(impostor: PhysicsImpostor): void;
  48649. /**
  48650. * Add a joint to the physics engine
  48651. * @param mainImpostor defines the main impostor to which the joint is added.
  48652. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  48653. * @param joint defines the joint that will connect both impostors.
  48654. */
  48655. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  48656. /**
  48657. * Removes a joint from the simulation
  48658. * @param mainImpostor defines the impostor used with the joint
  48659. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  48660. * @param joint defines the joint to remove
  48661. */
  48662. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  48663. /**
  48664. * Called by the scene. No need to call it.
  48665. * @param delta defines the timespam between frames
  48666. */
  48667. _step(delta: number): void;
  48668. /**
  48669. * Gets the current plugin used to run the simulation
  48670. * @returns current plugin
  48671. */
  48672. getPhysicsPlugin(): IPhysicsEnginePlugin;
  48673. /**
  48674. * Gets the list of physic impostors
  48675. * @returns an array of PhysicsImpostor
  48676. */
  48677. getImpostors(): Array<PhysicsImpostor>;
  48678. /**
  48679. * Gets the impostor for a physics enabled object
  48680. * @param object defines the object impersonated by the impostor
  48681. * @returns the PhysicsImpostor or null if not found
  48682. */
  48683. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  48684. /**
  48685. * Gets the impostor for a physics body object
  48686. * @param body defines physics body used by the impostor
  48687. * @returns the PhysicsImpostor or null if not found
  48688. */
  48689. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  48690. }
  48691. }
  48692. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  48693. import { Nullable } from "babylonjs/types";
  48694. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  48695. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48696. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  48697. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  48698. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  48699. /** @hidden */
  48700. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  48701. private _useDeltaForWorldStep;
  48702. world: any;
  48703. name: string;
  48704. private _physicsMaterials;
  48705. private _fixedTimeStep;
  48706. BJSCANNON: any;
  48707. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  48708. setGravity(gravity: Vector3): void;
  48709. setTimeStep(timeStep: number): void;
  48710. getTimeStep(): number;
  48711. executeStep(delta: number): void;
  48712. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48713. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48714. generatePhysicsBody(impostor: PhysicsImpostor): void;
  48715. private _processChildMeshes;
  48716. removePhysicsBody(impostor: PhysicsImpostor): void;
  48717. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  48718. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  48719. private _addMaterial;
  48720. private _checkWithEpsilon;
  48721. private _createShape;
  48722. private _createHeightmap;
  48723. private _minus90X;
  48724. private _plus90X;
  48725. private _tmpPosition;
  48726. private _tmpDeltaPosition;
  48727. private _tmpUnityRotation;
  48728. private _updatePhysicsBodyTransformation;
  48729. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  48730. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  48731. isSupported(): boolean;
  48732. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48733. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48734. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48735. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48736. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  48737. getBodyMass(impostor: PhysicsImpostor): number;
  48738. getBodyFriction(impostor: PhysicsImpostor): number;
  48739. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  48740. getBodyRestitution(impostor: PhysicsImpostor): number;
  48741. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  48742. sleepBody(impostor: PhysicsImpostor): void;
  48743. wakeUpBody(impostor: PhysicsImpostor): void;
  48744. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  48745. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  48746. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  48747. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  48748. getRadius(impostor: PhysicsImpostor): number;
  48749. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  48750. dispose(): void;
  48751. private _extendNamespace;
  48752. }
  48753. }
  48754. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  48755. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  48756. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  48757. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  48758. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48759. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  48760. import { Nullable } from "babylonjs/types";
  48761. /** @hidden */
  48762. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  48763. world: any;
  48764. name: string;
  48765. BJSOIMO: any;
  48766. constructor(iterations?: number, oimoInjection?: any);
  48767. setGravity(gravity: Vector3): void;
  48768. setTimeStep(timeStep: number): void;
  48769. getTimeStep(): number;
  48770. private _tmpImpostorsArray;
  48771. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  48772. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48773. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48774. generatePhysicsBody(impostor: PhysicsImpostor): void;
  48775. private _tmpPositionVector;
  48776. removePhysicsBody(impostor: PhysicsImpostor): void;
  48777. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  48778. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  48779. isSupported(): boolean;
  48780. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  48781. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  48782. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48783. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48784. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48785. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48786. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  48787. getBodyMass(impostor: PhysicsImpostor): number;
  48788. getBodyFriction(impostor: PhysicsImpostor): number;
  48789. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  48790. getBodyRestitution(impostor: PhysicsImpostor): number;
  48791. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  48792. sleepBody(impostor: PhysicsImpostor): void;
  48793. wakeUpBody(impostor: PhysicsImpostor): void;
  48794. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  48795. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  48796. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  48797. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  48798. getRadius(impostor: PhysicsImpostor): number;
  48799. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  48800. dispose(): void;
  48801. }
  48802. }
  48803. declare module "babylonjs/Probes/reflectionProbe" {
  48804. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  48805. import { Vector3 } from "babylonjs/Maths/math";
  48806. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48807. import { Nullable } from "babylonjs/types";
  48808. import { Scene } from "babylonjs/scene";
  48809. module "babylonjs/abstractScene" {
  48810. interface AbstractScene {
  48811. /**
  48812. * The list of reflection probes added to the scene
  48813. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  48814. */
  48815. reflectionProbes: Array<ReflectionProbe>;
  48816. /**
  48817. * Removes the given reflection probe from this scene.
  48818. * @param toRemove The reflection probe to remove
  48819. * @returns The index of the removed reflection probe
  48820. */
  48821. removeReflectionProbe(toRemove: ReflectionProbe): number;
  48822. /**
  48823. * Adds the given reflection probe to this scene.
  48824. * @param newReflectionProbe The reflection probe to add
  48825. */
  48826. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  48827. }
  48828. }
  48829. /**
  48830. * Class used to generate realtime reflection / refraction cube textures
  48831. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  48832. */
  48833. export class ReflectionProbe {
  48834. /** defines the name of the probe */
  48835. name: string;
  48836. private _scene;
  48837. private _renderTargetTexture;
  48838. private _projectionMatrix;
  48839. private _viewMatrix;
  48840. private _target;
  48841. private _add;
  48842. private _attachedMesh;
  48843. private _invertYAxis;
  48844. /** Gets or sets probe position (center of the cube map) */
  48845. position: Vector3;
  48846. /**
  48847. * Creates a new reflection probe
  48848. * @param name defines the name of the probe
  48849. * @param size defines the texture resolution (for each face)
  48850. * @param scene defines the hosting scene
  48851. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  48852. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  48853. */
  48854. constructor(
  48855. /** defines the name of the probe */
  48856. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  48857. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  48858. samples: number;
  48859. /** Gets or sets the refresh rate to use (on every frame by default) */
  48860. refreshRate: number;
  48861. /**
  48862. * Gets the hosting scene
  48863. * @returns a Scene
  48864. */
  48865. getScene(): Scene;
  48866. /** Gets the internal CubeTexture used to render to */
  48867. readonly cubeTexture: RenderTargetTexture;
  48868. /** Gets the list of meshes to render */
  48869. readonly renderList: Nullable<AbstractMesh[]>;
  48870. /**
  48871. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  48872. * @param mesh defines the mesh to attach to
  48873. */
  48874. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  48875. /**
  48876. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  48877. * @param renderingGroupId The rendering group id corresponding to its index
  48878. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  48879. */
  48880. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  48881. /**
  48882. * Clean all associated resources
  48883. */
  48884. dispose(): void;
  48885. /**
  48886. * Converts the reflection probe information to a readable string for debug purpose.
  48887. * @param fullDetails Supports for multiple levels of logging within scene loading
  48888. * @returns the human readable reflection probe info
  48889. */
  48890. toString(fullDetails?: boolean): string;
  48891. /**
  48892. * Get the class name of the relfection probe.
  48893. * @returns "ReflectionProbe"
  48894. */
  48895. getClassName(): string;
  48896. /**
  48897. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  48898. * @returns The JSON representation of the texture
  48899. */
  48900. serialize(): any;
  48901. /**
  48902. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  48903. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  48904. * @param scene Define the scene the parsed reflection probe should be instantiated in
  48905. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  48906. * @returns The parsed reflection probe if successful
  48907. */
  48908. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  48909. }
  48910. }
  48911. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  48912. /** @hidden */
  48913. export var _BabylonLoaderRegistered: boolean;
  48914. }
  48915. declare module "babylonjs/Loading/Plugins/index" {
  48916. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  48917. }
  48918. declare module "babylonjs/Loading/index" {
  48919. export * from "babylonjs/Loading/loadingScreen";
  48920. export * from "babylonjs/Loading/Plugins/index";
  48921. export * from "babylonjs/Loading/sceneLoader";
  48922. export * from "babylonjs/Loading/sceneLoaderFlags";
  48923. }
  48924. declare module "babylonjs/Materials/Background/index" {
  48925. export * from "babylonjs/Materials/Background/backgroundMaterial";
  48926. }
  48927. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  48928. import { Scene } from "babylonjs/scene";
  48929. import { Color3 } from "babylonjs/Maths/math";
  48930. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  48931. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48932. /**
  48933. * The Physically based simple base material of BJS.
  48934. *
  48935. * This enables better naming and convention enforcements on top of the pbrMaterial.
  48936. * It is used as the base class for both the specGloss and metalRough conventions.
  48937. */
  48938. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  48939. /**
  48940. * Number of Simultaneous lights allowed on the material.
  48941. */
  48942. maxSimultaneousLights: number;
  48943. /**
  48944. * If sets to true, disables all the lights affecting the material.
  48945. */
  48946. disableLighting: boolean;
  48947. /**
  48948. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  48949. */
  48950. environmentTexture: BaseTexture;
  48951. /**
  48952. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  48953. */
  48954. invertNormalMapX: boolean;
  48955. /**
  48956. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  48957. */
  48958. invertNormalMapY: boolean;
  48959. /**
  48960. * Normal map used in the model.
  48961. */
  48962. normalTexture: BaseTexture;
  48963. /**
  48964. * Emissivie color used to self-illuminate the model.
  48965. */
  48966. emissiveColor: Color3;
  48967. /**
  48968. * Emissivie texture used to self-illuminate the model.
  48969. */
  48970. emissiveTexture: BaseTexture;
  48971. /**
  48972. * Occlusion Channel Strenght.
  48973. */
  48974. occlusionStrength: number;
  48975. /**
  48976. * Occlusion Texture of the material (adding extra occlusion effects).
  48977. */
  48978. occlusionTexture: BaseTexture;
  48979. /**
  48980. * Defines the alpha limits in alpha test mode.
  48981. */
  48982. alphaCutOff: number;
  48983. /**
  48984. * Gets the current double sided mode.
  48985. */
  48986. /**
  48987. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  48988. */
  48989. doubleSided: boolean;
  48990. /**
  48991. * Stores the pre-calculated light information of a mesh in a texture.
  48992. */
  48993. lightmapTexture: BaseTexture;
  48994. /**
  48995. * If true, the light map contains occlusion information instead of lighting info.
  48996. */
  48997. useLightmapAsShadowmap: boolean;
  48998. /**
  48999. * Instantiates a new PBRMaterial instance.
  49000. *
  49001. * @param name The material name
  49002. * @param scene The scene the material will be use in.
  49003. */
  49004. constructor(name: string, scene: Scene);
  49005. getClassName(): string;
  49006. }
  49007. }
  49008. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  49009. import { Scene } from "babylonjs/scene";
  49010. import { Color3 } from "babylonjs/Maths/math";
  49011. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49012. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  49013. /**
  49014. * The PBR material of BJS following the metal roughness convention.
  49015. *
  49016. * This fits to the PBR convention in the GLTF definition:
  49017. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  49018. */
  49019. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  49020. /**
  49021. * The base color has two different interpretations depending on the value of metalness.
  49022. * When the material is a metal, the base color is the specific measured reflectance value
  49023. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  49024. * of the material.
  49025. */
  49026. baseColor: Color3;
  49027. /**
  49028. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  49029. * well as opacity information in the alpha channel.
  49030. */
  49031. baseTexture: BaseTexture;
  49032. /**
  49033. * Specifies the metallic scalar value of the material.
  49034. * Can also be used to scale the metalness values of the metallic texture.
  49035. */
  49036. metallic: number;
  49037. /**
  49038. * Specifies the roughness scalar value of the material.
  49039. * Can also be used to scale the roughness values of the metallic texture.
  49040. */
  49041. roughness: number;
  49042. /**
  49043. * Texture containing both the metallic value in the B channel and the
  49044. * roughness value in the G channel to keep better precision.
  49045. */
  49046. metallicRoughnessTexture: BaseTexture;
  49047. /**
  49048. * Instantiates a new PBRMetalRoughnessMaterial instance.
  49049. *
  49050. * @param name The material name
  49051. * @param scene The scene the material will be use in.
  49052. */
  49053. constructor(name: string, scene: Scene);
  49054. /**
  49055. * Return the currrent class name of the material.
  49056. */
  49057. getClassName(): string;
  49058. /**
  49059. * Makes a duplicate of the current material.
  49060. * @param name - name to use for the new material.
  49061. */
  49062. clone(name: string): PBRMetallicRoughnessMaterial;
  49063. /**
  49064. * Serialize the material to a parsable JSON object.
  49065. */
  49066. serialize(): any;
  49067. /**
  49068. * Parses a JSON object correponding to the serialize function.
  49069. */
  49070. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  49071. }
  49072. }
  49073. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  49074. import { Scene } from "babylonjs/scene";
  49075. import { Color3 } from "babylonjs/Maths/math";
  49076. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49077. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  49078. /**
  49079. * The PBR material of BJS following the specular glossiness convention.
  49080. *
  49081. * This fits to the PBR convention in the GLTF definition:
  49082. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  49083. */
  49084. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  49085. /**
  49086. * Specifies the diffuse color of the material.
  49087. */
  49088. diffuseColor: Color3;
  49089. /**
  49090. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  49091. * channel.
  49092. */
  49093. diffuseTexture: BaseTexture;
  49094. /**
  49095. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  49096. */
  49097. specularColor: Color3;
  49098. /**
  49099. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  49100. */
  49101. glossiness: number;
  49102. /**
  49103. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  49104. */
  49105. specularGlossinessTexture: BaseTexture;
  49106. /**
  49107. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  49108. *
  49109. * @param name The material name
  49110. * @param scene The scene the material will be use in.
  49111. */
  49112. constructor(name: string, scene: Scene);
  49113. /**
  49114. * Return the currrent class name of the material.
  49115. */
  49116. getClassName(): string;
  49117. /**
  49118. * Makes a duplicate of the current material.
  49119. * @param name - name to use for the new material.
  49120. */
  49121. clone(name: string): PBRSpecularGlossinessMaterial;
  49122. /**
  49123. * Serialize the material to a parsable JSON object.
  49124. */
  49125. serialize(): any;
  49126. /**
  49127. * Parses a JSON object correponding to the serialize function.
  49128. */
  49129. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  49130. }
  49131. }
  49132. declare module "babylonjs/Materials/PBR/index" {
  49133. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  49134. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  49135. export * from "babylonjs/Materials/PBR/pbrMaterial";
  49136. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  49137. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  49138. }
  49139. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  49140. import { Nullable } from "babylonjs/types";
  49141. import { Scene } from "babylonjs/scene";
  49142. import { Matrix } from "babylonjs/Maths/math";
  49143. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49144. /**
  49145. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  49146. * It can help converting any input color in a desired output one. This can then be used to create effects
  49147. * from sepia, black and white to sixties or futuristic rendering...
  49148. *
  49149. * The only supported format is currently 3dl.
  49150. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  49151. */
  49152. export class ColorGradingTexture extends BaseTexture {
  49153. /**
  49154. * The current texture matrix. (will always be identity in color grading texture)
  49155. */
  49156. private _textureMatrix;
  49157. /**
  49158. * The texture URL.
  49159. */
  49160. url: string;
  49161. /**
  49162. * Empty line regex stored for GC.
  49163. */
  49164. private static _noneEmptyLineRegex;
  49165. private _engine;
  49166. /**
  49167. * Instantiates a ColorGradingTexture from the following parameters.
  49168. *
  49169. * @param url The location of the color gradind data (currently only supporting 3dl)
  49170. * @param scene The scene the texture will be used in
  49171. */
  49172. constructor(url: string, scene: Scene);
  49173. /**
  49174. * Returns the texture matrix used in most of the material.
  49175. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  49176. */
  49177. getTextureMatrix(): Matrix;
  49178. /**
  49179. * Occurs when the file being loaded is a .3dl LUT file.
  49180. */
  49181. private load3dlTexture;
  49182. /**
  49183. * Starts the loading process of the texture.
  49184. */
  49185. private loadTexture;
  49186. /**
  49187. * Clones the color gradind texture.
  49188. */
  49189. clone(): ColorGradingTexture;
  49190. /**
  49191. * Called during delayed load for textures.
  49192. */
  49193. delayLoad(): void;
  49194. /**
  49195. * Parses a color grading texture serialized by Babylon.
  49196. * @param parsedTexture The texture information being parsedTexture
  49197. * @param scene The scene to load the texture in
  49198. * @param rootUrl The root url of the data assets to load
  49199. * @return A color gradind texture
  49200. */
  49201. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  49202. /**
  49203. * Serializes the LUT texture to json format.
  49204. */
  49205. serialize(): any;
  49206. }
  49207. }
  49208. declare module "babylonjs/Misc/tga" {
  49209. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49210. /**
  49211. * Based on jsTGALoader - Javascript loader for TGA file
  49212. * By Vincent Thibault
  49213. * @see http://blog.robrowser.com/javascript-tga-loader.html
  49214. */
  49215. export class TGATools {
  49216. private static _TYPE_INDEXED;
  49217. private static _TYPE_RGB;
  49218. private static _TYPE_GREY;
  49219. private static _TYPE_RLE_INDEXED;
  49220. private static _TYPE_RLE_RGB;
  49221. private static _TYPE_RLE_GREY;
  49222. private static _ORIGIN_MASK;
  49223. private static _ORIGIN_SHIFT;
  49224. private static _ORIGIN_BL;
  49225. private static _ORIGIN_BR;
  49226. private static _ORIGIN_UL;
  49227. private static _ORIGIN_UR;
  49228. /**
  49229. * Gets the header of a TGA file
  49230. * @param data defines the TGA data
  49231. * @returns the header
  49232. */
  49233. static GetTGAHeader(data: Uint8Array): any;
  49234. /**
  49235. * Uploads TGA content to a Babylon Texture
  49236. * @hidden
  49237. */
  49238. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  49239. /** @hidden */
  49240. 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;
  49241. /** @hidden */
  49242. 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;
  49243. /** @hidden */
  49244. 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;
  49245. /** @hidden */
  49246. 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;
  49247. /** @hidden */
  49248. 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;
  49249. /** @hidden */
  49250. 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;
  49251. }
  49252. }
  49253. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  49254. import { Nullable } from "babylonjs/types";
  49255. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49256. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  49257. /**
  49258. * Implementation of the TGA Texture Loader.
  49259. * @hidden
  49260. */
  49261. export class _TGATextureLoader implements IInternalTextureLoader {
  49262. /**
  49263. * Defines wether the loader supports cascade loading the different faces.
  49264. */
  49265. readonly supportCascades: boolean;
  49266. /**
  49267. * This returns if the loader support the current file information.
  49268. * @param extension defines the file extension of the file being loaded
  49269. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49270. * @param fallback defines the fallback internal texture if any
  49271. * @param isBase64 defines whether the texture is encoded as a base64
  49272. * @param isBuffer defines whether the texture data are stored as a buffer
  49273. * @returns true if the loader can load the specified file
  49274. */
  49275. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  49276. /**
  49277. * Transform the url before loading if required.
  49278. * @param rootUrl the url of the texture
  49279. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49280. * @returns the transformed texture
  49281. */
  49282. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  49283. /**
  49284. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  49285. * @param rootUrl the url of the texture
  49286. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49287. * @returns the fallback texture
  49288. */
  49289. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  49290. /**
  49291. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  49292. * @param data contains the texture data
  49293. * @param texture defines the BabylonJS internal texture
  49294. * @param createPolynomials will be true if polynomials have been requested
  49295. * @param onLoad defines the callback to trigger once the texture is ready
  49296. * @param onError defines the callback to trigger in case of error
  49297. */
  49298. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  49299. /**
  49300. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  49301. * @param data contains the texture data
  49302. * @param texture defines the BabylonJS internal texture
  49303. * @param callback defines the method to call once ready to upload
  49304. */
  49305. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  49306. }
  49307. }
  49308. declare module "babylonjs/Materials/Textures/Loaders/index" {
  49309. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  49310. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  49311. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  49312. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  49313. }
  49314. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  49315. import { Scene } from "babylonjs/scene";
  49316. import { Texture } from "babylonjs/Materials/Textures/texture";
  49317. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  49318. /**
  49319. * 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.
  49320. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  49321. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  49322. */
  49323. export class CustomProceduralTexture extends ProceduralTexture {
  49324. private _animate;
  49325. private _time;
  49326. private _config;
  49327. private _texturePath;
  49328. /**
  49329. * Instantiates a new Custom Procedural Texture.
  49330. * 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.
  49331. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  49332. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  49333. * @param name Define the name of the texture
  49334. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  49335. * @param size Define the size of the texture to create
  49336. * @param scene Define the scene the texture belongs to
  49337. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  49338. * @param generateMipMaps Define if the texture should creates mip maps or not
  49339. */
  49340. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  49341. private _loadJson;
  49342. /**
  49343. * Is the texture ready to be used ? (rendered at least once)
  49344. * @returns true if ready, otherwise, false.
  49345. */
  49346. isReady(): boolean;
  49347. /**
  49348. * Render the texture to its associated render target.
  49349. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  49350. */
  49351. render(useCameraPostProcess?: boolean): void;
  49352. /**
  49353. * Update the list of dependant textures samplers in the shader.
  49354. */
  49355. updateTextures(): void;
  49356. /**
  49357. * Update the uniform values of the procedural texture in the shader.
  49358. */
  49359. updateShaderUniforms(): void;
  49360. /**
  49361. * Define if the texture animates or not.
  49362. */
  49363. animate: boolean;
  49364. }
  49365. }
  49366. declare module "babylonjs/Shaders/noise.fragment" {
  49367. /** @hidden */
  49368. export var noisePixelShader: {
  49369. name: string;
  49370. shader: string;
  49371. };
  49372. }
  49373. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  49374. import { Nullable } from "babylonjs/types";
  49375. import { Scene } from "babylonjs/scene";
  49376. import { Texture } from "babylonjs/Materials/Textures/texture";
  49377. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  49378. import "babylonjs/Shaders/noise.fragment";
  49379. /**
  49380. * Class used to generate noise procedural textures
  49381. */
  49382. export class NoiseProceduralTexture extends ProceduralTexture {
  49383. private _time;
  49384. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  49385. brightness: number;
  49386. /** Defines the number of octaves to process */
  49387. octaves: number;
  49388. /** Defines the level of persistence (0.8 by default) */
  49389. persistence: number;
  49390. /** Gets or sets animation speed factor (default is 1) */
  49391. animationSpeedFactor: number;
  49392. /**
  49393. * Creates a new NoiseProceduralTexture
  49394. * @param name defines the name fo the texture
  49395. * @param size defines the size of the texture (default is 256)
  49396. * @param scene defines the hosting scene
  49397. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  49398. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  49399. */
  49400. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  49401. private _updateShaderUniforms;
  49402. protected _getDefines(): string;
  49403. /** Generate the current state of the procedural texture */
  49404. render(useCameraPostProcess?: boolean): void;
  49405. /**
  49406. * Serializes this noise procedural texture
  49407. * @returns a serialized noise procedural texture object
  49408. */
  49409. serialize(): any;
  49410. /**
  49411. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  49412. * @param parsedTexture defines parsed texture data
  49413. * @param scene defines the current scene
  49414. * @param rootUrl defines the root URL containing noise procedural texture information
  49415. * @returns a parsed NoiseProceduralTexture
  49416. */
  49417. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  49418. }
  49419. }
  49420. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  49421. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  49422. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  49423. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  49424. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  49425. }
  49426. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  49427. import { Nullable } from "babylonjs/types";
  49428. import { Scene } from "babylonjs/scene";
  49429. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49430. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49431. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  49432. /**
  49433. * Raw cube texture where the raw buffers are passed in
  49434. */
  49435. export class RawCubeTexture extends CubeTexture {
  49436. /**
  49437. * Creates a cube texture where the raw buffers are passed in.
  49438. * @param scene defines the scene the texture is attached to
  49439. * @param data defines the array of data to use to create each face
  49440. * @param size defines the size of the textures
  49441. * @param format defines the format of the data
  49442. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  49443. * @param generateMipMaps defines if the engine should generate the mip levels
  49444. * @param invertY defines if data must be stored with Y axis inverted
  49445. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  49446. * @param compression defines the compression used (null by default)
  49447. */
  49448. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  49449. /**
  49450. * Updates the raw cube texture.
  49451. * @param data defines the data to store
  49452. * @param format defines the data format
  49453. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  49454. * @param invertY defines if data must be stored with Y axis inverted
  49455. * @param compression defines the compression used (null by default)
  49456. * @param level defines which level of the texture to update
  49457. */
  49458. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  49459. /**
  49460. * Updates a raw cube texture with RGBD encoded data.
  49461. * @param data defines the array of data [mipmap][face] to use to create each face
  49462. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  49463. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  49464. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  49465. * @returns a promsie that resolves when the operation is complete
  49466. */
  49467. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  49468. /**
  49469. * Clones the raw cube texture.
  49470. * @return a new cube texture
  49471. */
  49472. clone(): CubeTexture;
  49473. /** @hidden */
  49474. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  49475. }
  49476. }
  49477. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  49478. import { Scene } from "babylonjs/scene";
  49479. import { Texture } from "babylonjs/Materials/Textures/texture";
  49480. /**
  49481. * Class used to store 3D textures containing user data
  49482. */
  49483. export class RawTexture3D extends Texture {
  49484. /** Gets or sets the texture format to use */
  49485. format: number;
  49486. private _engine;
  49487. /**
  49488. * Create a new RawTexture3D
  49489. * @param data defines the data of the texture
  49490. * @param width defines the width of the texture
  49491. * @param height defines the height of the texture
  49492. * @param depth defines the depth of the texture
  49493. * @param format defines the texture format to use
  49494. * @param scene defines the hosting scene
  49495. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  49496. * @param invertY defines if texture must be stored with Y axis inverted
  49497. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  49498. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  49499. */
  49500. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  49501. /** Gets or sets the texture format to use */
  49502. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  49503. /**
  49504. * Update the texture with new data
  49505. * @param data defines the data to store in the texture
  49506. */
  49507. update(data: ArrayBufferView): void;
  49508. }
  49509. }
  49510. declare module "babylonjs/Materials/Textures/refractionTexture" {
  49511. import { Scene } from "babylonjs/scene";
  49512. import { Plane } from "babylonjs/Maths/math";
  49513. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  49514. /**
  49515. * Creates a refraction texture used by refraction channel of the standard material.
  49516. * It is like a mirror but to see through a material.
  49517. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  49518. */
  49519. export class RefractionTexture extends RenderTargetTexture {
  49520. /**
  49521. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  49522. * 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.
  49523. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  49524. */
  49525. refractionPlane: Plane;
  49526. /**
  49527. * Define how deep under the surface we should see.
  49528. */
  49529. depth: number;
  49530. /**
  49531. * Creates a refraction texture used by refraction channel of the standard material.
  49532. * It is like a mirror but to see through a material.
  49533. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  49534. * @param name Define the texture name
  49535. * @param size Define the size of the underlying texture
  49536. * @param scene Define the scene the refraction belongs to
  49537. * @param generateMipMaps Define if we need to generate mips level for the refraction
  49538. */
  49539. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  49540. /**
  49541. * Clone the refraction texture.
  49542. * @returns the cloned texture
  49543. */
  49544. clone(): RefractionTexture;
  49545. /**
  49546. * Serialize the texture to a JSON representation you could use in Parse later on
  49547. * @returns the serialized JSON representation
  49548. */
  49549. serialize(): any;
  49550. }
  49551. }
  49552. declare module "babylonjs/Materials/Textures/index" {
  49553. export * from "babylonjs/Materials/Textures/baseTexture";
  49554. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  49555. export * from "babylonjs/Materials/Textures/cubeTexture";
  49556. export * from "babylonjs/Materials/Textures/dynamicTexture";
  49557. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  49558. export * from "babylonjs/Materials/Textures/internalTexture";
  49559. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  49560. export * from "babylonjs/Materials/Textures/internalTextureTracker";
  49561. export * from "babylonjs/Materials/Textures/Loaders/index";
  49562. export * from "babylonjs/Materials/Textures/mirrorTexture";
  49563. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  49564. export * from "babylonjs/Materials/Textures/Procedurals/index";
  49565. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  49566. export * from "babylonjs/Materials/Textures/rawTexture";
  49567. export * from "babylonjs/Materials/Textures/rawTexture3D";
  49568. export * from "babylonjs/Materials/Textures/refractionTexture";
  49569. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  49570. export * from "babylonjs/Materials/Textures/texture";
  49571. export * from "babylonjs/Materials/Textures/videoTexture";
  49572. }
  49573. declare module "babylonjs/Materials/index" {
  49574. export * from "babylonjs/Materials/Background/index";
  49575. export * from "babylonjs/Materials/colorCurves";
  49576. export * from "babylonjs/Materials/effect";
  49577. export * from "babylonjs/Materials/fresnelParameters";
  49578. export * from "babylonjs/Materials/imageProcessingConfiguration";
  49579. export * from "babylonjs/Materials/material";
  49580. export * from "babylonjs/Materials/materialDefines";
  49581. export * from "babylonjs/Materials/materialHelper";
  49582. export * from "babylonjs/Materials/multiMaterial";
  49583. export * from "babylonjs/Materials/PBR/index";
  49584. export * from "babylonjs/Materials/pushMaterial";
  49585. export * from "babylonjs/Materials/shaderMaterial";
  49586. export * from "babylonjs/Materials/standardMaterial";
  49587. export * from "babylonjs/Materials/Textures/index";
  49588. export * from "babylonjs/Materials/uniformBuffer";
  49589. export * from "babylonjs/Materials/materialFlags";
  49590. }
  49591. declare module "babylonjs/Maths/index" {
  49592. export * from "babylonjs/Maths/math.scalar";
  49593. export * from "babylonjs/Maths/math";
  49594. export * from "babylonjs/Maths/sphericalPolynomial";
  49595. }
  49596. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  49597. import { IDisposable } from "babylonjs/scene";
  49598. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  49599. /**
  49600. * Configuration for Draco compression
  49601. */
  49602. export interface IDracoCompressionConfiguration {
  49603. /**
  49604. * Configuration for the decoder.
  49605. */
  49606. decoder?: {
  49607. /**
  49608. * The url to the WebAssembly module.
  49609. */
  49610. wasmUrl?: string;
  49611. /**
  49612. * The url to the WebAssembly binary.
  49613. */
  49614. wasmBinaryUrl?: string;
  49615. /**
  49616. * The url to the fallback JavaScript module.
  49617. */
  49618. fallbackUrl?: string;
  49619. };
  49620. }
  49621. /**
  49622. * Draco compression (https://google.github.io/draco/)
  49623. *
  49624. * This class wraps the Draco module.
  49625. *
  49626. * **Encoder**
  49627. *
  49628. * The encoder is not currently implemented.
  49629. *
  49630. * **Decoder**
  49631. *
  49632. * 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.
  49633. *
  49634. * To update the configuration, use the following code:
  49635. * ```javascript
  49636. * DracoCompression.Configuration = {
  49637. * decoder: {
  49638. * wasmUrl: "<url to the WebAssembly library>",
  49639. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  49640. * fallbackUrl: "<url to the fallback JavaScript library>",
  49641. * }
  49642. * };
  49643. * ```
  49644. *
  49645. * 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.
  49646. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  49647. * Use `DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  49648. *
  49649. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  49650. * ```javascript
  49651. * var dracoCompression = new DracoCompression();
  49652. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  49653. * [VertexBuffer.PositionKind]: 0
  49654. * });
  49655. * ```
  49656. *
  49657. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  49658. */
  49659. export class DracoCompression implements IDisposable {
  49660. private static _DecoderModulePromise;
  49661. /**
  49662. * The configuration. Defaults to the following urls:
  49663. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  49664. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  49665. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  49666. */
  49667. static Configuration: IDracoCompressionConfiguration;
  49668. /**
  49669. * Returns true if the decoder is available.
  49670. */
  49671. static readonly DecoderAvailable: boolean;
  49672. /**
  49673. * Constructor
  49674. */
  49675. constructor();
  49676. /**
  49677. * Stop all async operations and release resources.
  49678. */
  49679. dispose(): void;
  49680. /**
  49681. * Decode Draco compressed mesh data to vertex data.
  49682. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  49683. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  49684. * @returns A promise that resolves with the decoded vertex data
  49685. */
  49686. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes: {
  49687. [kind: string]: number;
  49688. }): Promise<VertexData>;
  49689. private static _GetDecoderModule;
  49690. private static _LoadScriptAsync;
  49691. private static _LoadFileAsync;
  49692. }
  49693. }
  49694. declare module "babylonjs/Meshes/Compression/index" {
  49695. export * from "babylonjs/Meshes/Compression/dracoCompression";
  49696. }
  49697. declare module "babylonjs/Meshes/csg" {
  49698. import { Nullable } from "babylonjs/types";
  49699. import { Scene } from "babylonjs/scene";
  49700. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  49701. import { Mesh } from "babylonjs/Meshes/mesh";
  49702. import { Material } from "babylonjs/Materials/material";
  49703. /**
  49704. * Class for building Constructive Solid Geometry
  49705. */
  49706. export class CSG {
  49707. private polygons;
  49708. /**
  49709. * The world matrix
  49710. */
  49711. matrix: Matrix;
  49712. /**
  49713. * Stores the position
  49714. */
  49715. position: Vector3;
  49716. /**
  49717. * Stores the rotation
  49718. */
  49719. rotation: Vector3;
  49720. /**
  49721. * Stores the rotation quaternion
  49722. */
  49723. rotationQuaternion: Nullable<Quaternion>;
  49724. /**
  49725. * Stores the scaling vector
  49726. */
  49727. scaling: Vector3;
  49728. /**
  49729. * Convert the Mesh to CSG
  49730. * @param mesh The Mesh to convert to CSG
  49731. * @returns A new CSG from the Mesh
  49732. */
  49733. static FromMesh(mesh: Mesh): CSG;
  49734. /**
  49735. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  49736. * @param polygons Polygons used to construct a CSG solid
  49737. */
  49738. private static FromPolygons;
  49739. /**
  49740. * Clones, or makes a deep copy, of the CSG
  49741. * @returns A new CSG
  49742. */
  49743. clone(): CSG;
  49744. /**
  49745. * Unions this CSG with another CSG
  49746. * @param csg The CSG to union against this CSG
  49747. * @returns The unioned CSG
  49748. */
  49749. union(csg: CSG): CSG;
  49750. /**
  49751. * Unions this CSG with another CSG in place
  49752. * @param csg The CSG to union against this CSG
  49753. */
  49754. unionInPlace(csg: CSG): void;
  49755. /**
  49756. * Subtracts this CSG with another CSG
  49757. * @param csg The CSG to subtract against this CSG
  49758. * @returns A new CSG
  49759. */
  49760. subtract(csg: CSG): CSG;
  49761. /**
  49762. * Subtracts this CSG with another CSG in place
  49763. * @param csg The CSG to subtact against this CSG
  49764. */
  49765. subtractInPlace(csg: CSG): void;
  49766. /**
  49767. * Intersect this CSG with another CSG
  49768. * @param csg The CSG to intersect against this CSG
  49769. * @returns A new CSG
  49770. */
  49771. intersect(csg: CSG): CSG;
  49772. /**
  49773. * Intersects this CSG with another CSG in place
  49774. * @param csg The CSG to intersect against this CSG
  49775. */
  49776. intersectInPlace(csg: CSG): void;
  49777. /**
  49778. * Return a new CSG solid with solid and empty space switched. This solid is
  49779. * not modified.
  49780. * @returns A new CSG solid with solid and empty space switched
  49781. */
  49782. inverse(): CSG;
  49783. /**
  49784. * Inverses the CSG in place
  49785. */
  49786. inverseInPlace(): void;
  49787. /**
  49788. * This is used to keep meshes transformations so they can be restored
  49789. * when we build back a Babylon Mesh
  49790. * NB : All CSG operations are performed in world coordinates
  49791. * @param csg The CSG to copy the transform attributes from
  49792. * @returns This CSG
  49793. */
  49794. copyTransformAttributes(csg: CSG): CSG;
  49795. /**
  49796. * Build Raw mesh from CSG
  49797. * Coordinates here are in world space
  49798. * @param name The name of the mesh geometry
  49799. * @param scene The Scene
  49800. * @param keepSubMeshes Specifies if the submeshes should be kept
  49801. * @returns A new Mesh
  49802. */
  49803. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  49804. /**
  49805. * Build Mesh from CSG taking material and transforms into account
  49806. * @param name The name of the Mesh
  49807. * @param material The material of the Mesh
  49808. * @param scene The Scene
  49809. * @param keepSubMeshes Specifies if submeshes should be kept
  49810. * @returns The new Mesh
  49811. */
  49812. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  49813. }
  49814. }
  49815. declare module "babylonjs/Meshes/trailMesh" {
  49816. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49817. import { Mesh } from "babylonjs/Meshes/mesh";
  49818. import { Scene } from "babylonjs/scene";
  49819. /**
  49820. * Class used to create a trail following a mesh
  49821. */
  49822. export class TrailMesh extends Mesh {
  49823. private _generator;
  49824. private _autoStart;
  49825. private _running;
  49826. private _diameter;
  49827. private _length;
  49828. private _sectionPolygonPointsCount;
  49829. private _sectionVectors;
  49830. private _sectionNormalVectors;
  49831. private _beforeRenderObserver;
  49832. /**
  49833. * @constructor
  49834. * @param name The value used by scene.getMeshByName() to do a lookup.
  49835. * @param generator The mesh to generate a trail.
  49836. * @param scene The scene to add this mesh to.
  49837. * @param diameter Diameter of trailing mesh. Default is 1.
  49838. * @param length Length of trailing mesh. Default is 60.
  49839. * @param autoStart Automatically start trailing mesh. Default true.
  49840. */
  49841. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  49842. /**
  49843. * "TrailMesh"
  49844. * @returns "TrailMesh"
  49845. */
  49846. getClassName(): string;
  49847. private _createMesh;
  49848. /**
  49849. * Start trailing mesh.
  49850. */
  49851. start(): void;
  49852. /**
  49853. * Stop trailing mesh.
  49854. */
  49855. stop(): void;
  49856. /**
  49857. * Update trailing mesh geometry.
  49858. */
  49859. update(): void;
  49860. /**
  49861. * Returns a new TrailMesh object.
  49862. * @param name is a string, the name given to the new mesh
  49863. * @param newGenerator use new generator object for cloned trail mesh
  49864. * @returns a new mesh
  49865. */
  49866. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  49867. /**
  49868. * Serializes this trail mesh
  49869. * @param serializationObject object to write serialization to
  49870. */
  49871. serialize(serializationObject: any): void;
  49872. /**
  49873. * Parses a serialized trail mesh
  49874. * @param parsedMesh the serialized mesh
  49875. * @param scene the scene to create the trail mesh in
  49876. * @returns the created trail mesh
  49877. */
  49878. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  49879. }
  49880. }
  49881. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  49882. import { Nullable } from "babylonjs/types";
  49883. import { Scene } from "babylonjs/scene";
  49884. import { Vector3, Vector2, Color4, Vector4 } from "babylonjs/Maths/math";
  49885. import { Mesh } from "babylonjs/Meshes/mesh";
  49886. /**
  49887. * Class containing static functions to help procedurally build meshes
  49888. */
  49889. export class RibbonBuilder {
  49890. /**
  49891. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  49892. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  49893. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  49894. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  49895. * * 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
  49896. * * 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
  49897. * * 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
  49898. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49899. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49900. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49901. * * 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
  49902. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  49903. * * 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
  49904. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  49905. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49906. * @param name defines the name of the mesh
  49907. * @param options defines the options used to create the mesh
  49908. * @param scene defines the hosting scene
  49909. * @returns the ribbon mesh
  49910. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  49911. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49912. */
  49913. static CreateRibbon(name: string, options: {
  49914. pathArray: Vector3[][];
  49915. closeArray?: boolean;
  49916. closePath?: boolean;
  49917. offset?: number;
  49918. updatable?: boolean;
  49919. sideOrientation?: number;
  49920. frontUVs?: Vector4;
  49921. backUVs?: Vector4;
  49922. instance?: Mesh;
  49923. invertUV?: boolean;
  49924. uvs?: Vector2[];
  49925. colors?: Color4[];
  49926. }, scene?: Nullable<Scene>): Mesh;
  49927. }
  49928. }
  49929. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  49930. import { Vector4 } from "babylonjs/Maths/math";
  49931. import { Mesh } from "babylonjs/Meshes/mesh";
  49932. /**
  49933. * Class containing static functions to help procedurally build meshes
  49934. */
  49935. export class TorusKnotBuilder {
  49936. /**
  49937. * Creates a torus knot mesh
  49938. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  49939. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  49940. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  49941. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  49942. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49943. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49944. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49945. * @param name defines the name of the mesh
  49946. * @param options defines the options used to create the mesh
  49947. * @param scene defines the hosting scene
  49948. * @returns the torus knot mesh
  49949. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  49950. */
  49951. static CreateTorusKnot(name: string, options: {
  49952. radius?: number;
  49953. tube?: number;
  49954. radialSegments?: number;
  49955. tubularSegments?: number;
  49956. p?: number;
  49957. q?: number;
  49958. updatable?: boolean;
  49959. sideOrientation?: number;
  49960. frontUVs?: Vector4;
  49961. backUVs?: Vector4;
  49962. }, scene: any): Mesh;
  49963. }
  49964. }
  49965. declare module "babylonjs/Meshes/polygonMesh" {
  49966. import { Scene } from "babylonjs/scene";
  49967. import { Vector2, Path2 } from "babylonjs/Maths/math";
  49968. import { Mesh } from "babylonjs/Meshes/mesh";
  49969. /**
  49970. * Polygon
  49971. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  49972. */
  49973. export class Polygon {
  49974. /**
  49975. * Creates a rectangle
  49976. * @param xmin bottom X coord
  49977. * @param ymin bottom Y coord
  49978. * @param xmax top X coord
  49979. * @param ymax top Y coord
  49980. * @returns points that make the resulting rectation
  49981. */
  49982. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  49983. /**
  49984. * Creates a circle
  49985. * @param radius radius of circle
  49986. * @param cx scale in x
  49987. * @param cy scale in y
  49988. * @param numberOfSides number of sides that make up the circle
  49989. * @returns points that make the resulting circle
  49990. */
  49991. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  49992. /**
  49993. * Creates a polygon from input string
  49994. * @param input Input polygon data
  49995. * @returns the parsed points
  49996. */
  49997. static Parse(input: string): Vector2[];
  49998. /**
  49999. * Starts building a polygon from x and y coordinates
  50000. * @param x x coordinate
  50001. * @param y y coordinate
  50002. * @returns the started path2
  50003. */
  50004. static StartingAt(x: number, y: number): Path2;
  50005. }
  50006. /**
  50007. * Builds a polygon
  50008. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  50009. */
  50010. export class PolygonMeshBuilder {
  50011. private _points;
  50012. private _outlinepoints;
  50013. private _holes;
  50014. private _name;
  50015. private _scene;
  50016. private _epoints;
  50017. private _eholes;
  50018. private _addToepoint;
  50019. /**
  50020. * Babylon reference to the earcut plugin.
  50021. */
  50022. bjsEarcut: any;
  50023. /**
  50024. * Creates a PolygonMeshBuilder
  50025. * @param name name of the builder
  50026. * @param contours Path of the polygon
  50027. * @param scene scene to add to
  50028. * @param earcutInjection can be used to inject your own earcut reference
  50029. */
  50030. constructor(name: string, contours: Path2 | Vector2[] | any, scene: Scene, earcutInjection?: any);
  50031. /**
  50032. * Adds a whole within the polygon
  50033. * @param hole Array of points defining the hole
  50034. * @returns this
  50035. */
  50036. addHole(hole: Vector2[]): PolygonMeshBuilder;
  50037. /**
  50038. * Creates the polygon
  50039. * @param updatable If the mesh should be updatable
  50040. * @param depth The depth of the mesh created
  50041. * @returns the created mesh
  50042. */
  50043. build(updatable?: boolean, depth?: number): Mesh;
  50044. /**
  50045. * Adds a side to the polygon
  50046. * @param positions points that make the polygon
  50047. * @param normals normals of the polygon
  50048. * @param uvs uvs of the polygon
  50049. * @param indices indices of the polygon
  50050. * @param bounds bounds of the polygon
  50051. * @param points points of the polygon
  50052. * @param depth depth of the polygon
  50053. * @param flip flip of the polygon
  50054. */
  50055. private addSide;
  50056. }
  50057. }
  50058. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  50059. import { Scene } from "babylonjs/scene";
  50060. import { Vector3, Color4, Vector4 } from "babylonjs/Maths/math";
  50061. import { Mesh } from "babylonjs/Meshes/mesh";
  50062. /**
  50063. * Class containing static functions to help procedurally build meshes
  50064. */
  50065. export class PolygonBuilder {
  50066. /**
  50067. * Creates a polygon mesh
  50068. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  50069. * * 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
  50070. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  50071. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50072. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  50073. * * Remember you can only change the shape positions, not their number when updating a polygon
  50074. * @param name defines the name of the mesh
  50075. * @param options defines the options used to create the mesh
  50076. * @param scene defines the hosting scene
  50077. * @param earcutInjection can be used to inject your own earcut reference
  50078. * @returns the polygon mesh
  50079. */
  50080. static CreatePolygon(name: string, options: {
  50081. shape: Vector3[];
  50082. holes?: Vector3[][];
  50083. depth?: number;
  50084. faceUV?: Vector4[];
  50085. faceColors?: Color4[];
  50086. updatable?: boolean;
  50087. sideOrientation?: number;
  50088. frontUVs?: Vector4;
  50089. backUVs?: Vector4;
  50090. }, scene: Scene, earcutInjection?: any): Mesh;
  50091. /**
  50092. * Creates an extruded polygon mesh, with depth in the Y direction.
  50093. * * 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)
  50094. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  50095. * @param name defines the name of the mesh
  50096. * @param options defines the options used to create the mesh
  50097. * @param scene defines the hosting scene
  50098. * @param earcutInjection can be used to inject your own earcut reference
  50099. * @returns the polygon mesh
  50100. */
  50101. static ExtrudePolygon(name: string, options: {
  50102. shape: Vector3[];
  50103. holes?: Vector3[][];
  50104. depth?: number;
  50105. faceUV?: Vector4[];
  50106. faceColors?: Color4[];
  50107. updatable?: boolean;
  50108. sideOrientation?: number;
  50109. frontUVs?: Vector4;
  50110. backUVs?: Vector4;
  50111. }, scene: Scene, earcutInjection?: any): Mesh;
  50112. }
  50113. }
  50114. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  50115. import { Nullable } from "babylonjs/types";
  50116. import { Scene } from "babylonjs/scene";
  50117. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  50118. import { Mesh } from "babylonjs/Meshes/mesh";
  50119. /**
  50120. * Class containing static functions to help procedurally build meshes
  50121. */
  50122. export class ShapeBuilder {
  50123. /**
  50124. * 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.
  50125. * * 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.
  50126. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50127. * * 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.
  50128. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  50129. * * 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
  50130. * * 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
  50131. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  50132. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50133. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50134. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  50135. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50136. * @param name defines the name of the mesh
  50137. * @param options defines the options used to create the mesh
  50138. * @param scene defines the hosting scene
  50139. * @returns the extruded shape mesh
  50140. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50141. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50142. */
  50143. static ExtrudeShape(name: string, options: {
  50144. shape: Vector3[];
  50145. path: Vector3[];
  50146. scale?: number;
  50147. rotation?: number;
  50148. cap?: number;
  50149. updatable?: boolean;
  50150. sideOrientation?: number;
  50151. frontUVs?: Vector4;
  50152. backUVs?: Vector4;
  50153. instance?: Mesh;
  50154. invertUV?: boolean;
  50155. }, scene?: Nullable<Scene>): Mesh;
  50156. /**
  50157. * Creates an custom extruded shape mesh.
  50158. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  50159. * * 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.
  50160. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50161. * * 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
  50162. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  50163. * * 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
  50164. * * It must returns a float value that will be the scale value applied to the shape on each path point
  50165. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  50166. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  50167. * * 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
  50168. * * 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
  50169. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  50170. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50171. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50172. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50173. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50174. * @param name defines the name of the mesh
  50175. * @param options defines the options used to create the mesh
  50176. * @param scene defines the hosting scene
  50177. * @returns the custom extruded shape mesh
  50178. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  50179. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50180. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50181. */
  50182. static ExtrudeShapeCustom(name: string, options: {
  50183. shape: Vector3[];
  50184. path: Vector3[];
  50185. scaleFunction?: any;
  50186. rotationFunction?: any;
  50187. ribbonCloseArray?: boolean;
  50188. ribbonClosePath?: boolean;
  50189. cap?: number;
  50190. updatable?: boolean;
  50191. sideOrientation?: number;
  50192. frontUVs?: Vector4;
  50193. backUVs?: Vector4;
  50194. instance?: Mesh;
  50195. invertUV?: boolean;
  50196. }, scene: Scene): Mesh;
  50197. private static _ExtrudeShapeGeneric;
  50198. }
  50199. }
  50200. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  50201. import { Scene } from "babylonjs/scene";
  50202. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  50203. import { Mesh } from "babylonjs/Meshes/mesh";
  50204. /**
  50205. * Class containing static functions to help procedurally build meshes
  50206. */
  50207. export class LatheBuilder {
  50208. /**
  50209. * Creates lathe mesh.
  50210. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  50211. * * 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
  50212. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  50213. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  50214. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  50215. * * 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
  50216. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  50217. * * 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
  50218. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50219. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50220. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50221. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50222. * @param name defines the name of the mesh
  50223. * @param options defines the options used to create the mesh
  50224. * @param scene defines the hosting scene
  50225. * @returns the lathe mesh
  50226. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  50227. */
  50228. static CreateLathe(name: string, options: {
  50229. shape: Vector3[];
  50230. radius?: number;
  50231. tessellation?: number;
  50232. clip?: number;
  50233. arc?: number;
  50234. closed?: boolean;
  50235. updatable?: boolean;
  50236. sideOrientation?: number;
  50237. frontUVs?: Vector4;
  50238. backUVs?: Vector4;
  50239. cap?: number;
  50240. invertUV?: boolean;
  50241. }, scene: Scene): Mesh;
  50242. }
  50243. }
  50244. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  50245. import { Scene } from "babylonjs/scene";
  50246. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  50247. import { Mesh } from "babylonjs/Meshes/mesh";
  50248. /**
  50249. * Class containing static functions to help procedurally build meshes
  50250. */
  50251. export class TubeBuilder {
  50252. /**
  50253. * Creates a tube mesh.
  50254. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  50255. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  50256. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  50257. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  50258. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  50259. * * 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)
  50260. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  50261. * * 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
  50262. * * 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
  50263. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50264. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50265. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50266. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50267. * @param name defines the name of the mesh
  50268. * @param options defines the options used to create the mesh
  50269. * @param scene defines the hosting scene
  50270. * @returns the tube mesh
  50271. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50272. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  50273. */
  50274. static CreateTube(name: string, options: {
  50275. path: Vector3[];
  50276. radius?: number;
  50277. tessellation?: number;
  50278. radiusFunction?: {
  50279. (i: number, distance: number): number;
  50280. };
  50281. cap?: number;
  50282. arc?: number;
  50283. updatable?: boolean;
  50284. sideOrientation?: number;
  50285. frontUVs?: Vector4;
  50286. backUVs?: Vector4;
  50287. instance?: Mesh;
  50288. invertUV?: boolean;
  50289. }, scene: Scene): Mesh;
  50290. }
  50291. }
  50292. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  50293. import { Scene } from "babylonjs/scene";
  50294. import { Vector4 } from "babylonjs/Maths/math";
  50295. import { Mesh } from "babylonjs/Meshes/mesh";
  50296. /**
  50297. * Class containing static functions to help procedurally build meshes
  50298. */
  50299. export class IcoSphereBuilder {
  50300. /**
  50301. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  50302. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  50303. * * 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`)
  50304. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  50305. * * 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
  50306. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50307. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50308. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50309. * @param name defines the name of the mesh
  50310. * @param options defines the options used to create the mesh
  50311. * @param scene defines the hosting scene
  50312. * @returns the icosahedron mesh
  50313. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  50314. */
  50315. static CreateIcoSphere(name: string, options: {
  50316. radius?: number;
  50317. radiusX?: number;
  50318. radiusY?: number;
  50319. radiusZ?: number;
  50320. flat?: boolean;
  50321. subdivisions?: number;
  50322. sideOrientation?: number;
  50323. frontUVs?: Vector4;
  50324. backUVs?: Vector4;
  50325. updatable?: boolean;
  50326. }, scene: Scene): Mesh;
  50327. }
  50328. }
  50329. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  50330. import { Vector3 } from "babylonjs/Maths/math";
  50331. import { Mesh } from "babylonjs/Meshes/mesh";
  50332. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50333. /**
  50334. * Class containing static functions to help procedurally build meshes
  50335. */
  50336. export class DecalBuilder {
  50337. /**
  50338. * Creates a decal mesh.
  50339. * 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
  50340. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  50341. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  50342. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  50343. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  50344. * @param name defines the name of the mesh
  50345. * @param sourceMesh defines the mesh where the decal must be applied
  50346. * @param options defines the options used to create the mesh
  50347. * @param scene defines the hosting scene
  50348. * @returns the decal mesh
  50349. * @see https://doc.babylonjs.com/how_to/decals
  50350. */
  50351. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  50352. position?: Vector3;
  50353. normal?: Vector3;
  50354. size?: Vector3;
  50355. angle?: number;
  50356. }): Mesh;
  50357. }
  50358. }
  50359. declare module "babylonjs/Meshes/meshBuilder" {
  50360. import { Vector4, Color4, Vector3, Vector2, Plane, Color3 } from "babylonjs/Maths/math";
  50361. import { Nullable } from "babylonjs/types";
  50362. import { Scene } from "babylonjs/scene";
  50363. import { Mesh } from "babylonjs/Meshes/mesh";
  50364. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  50365. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  50366. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50367. /**
  50368. * Class containing static functions to help procedurally build meshes
  50369. */
  50370. export class MeshBuilder {
  50371. /**
  50372. * Creates a box mesh
  50373. * * The parameter `size` sets the size (float) of each box side (default 1)
  50374. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  50375. * * 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)
  50376. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  50377. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50378. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50379. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50380. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  50381. * @param name defines the name of the mesh
  50382. * @param options defines the options used to create the mesh
  50383. * @param scene defines the hosting scene
  50384. * @returns the box mesh
  50385. */
  50386. static CreateBox(name: string, options: {
  50387. size?: number;
  50388. width?: number;
  50389. height?: number;
  50390. depth?: number;
  50391. faceUV?: Vector4[];
  50392. faceColors?: Color4[];
  50393. sideOrientation?: number;
  50394. frontUVs?: Vector4;
  50395. backUVs?: Vector4;
  50396. updatable?: boolean;
  50397. }, scene?: Nullable<Scene>): Mesh;
  50398. /**
  50399. * Creates a sphere mesh
  50400. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  50401. * * 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`)
  50402. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  50403. * * 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
  50404. * * 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)
  50405. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50406. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50407. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50408. * @param name defines the name of the mesh
  50409. * @param options defines the options used to create the mesh
  50410. * @param scene defines the hosting scene
  50411. * @returns the sphere mesh
  50412. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  50413. */
  50414. static CreateSphere(name: string, options: {
  50415. segments?: number;
  50416. diameter?: number;
  50417. diameterX?: number;
  50418. diameterY?: number;
  50419. diameterZ?: number;
  50420. arc?: number;
  50421. slice?: number;
  50422. sideOrientation?: number;
  50423. frontUVs?: Vector4;
  50424. backUVs?: Vector4;
  50425. updatable?: boolean;
  50426. }, scene: any): Mesh;
  50427. /**
  50428. * Creates a plane polygonal mesh. By default, this is a disc
  50429. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  50430. * * 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
  50431. * * 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
  50432. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50433. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50434. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50435. * @param name defines the name of the mesh
  50436. * @param options defines the options used to create the mesh
  50437. * @param scene defines the hosting scene
  50438. * @returns the plane polygonal mesh
  50439. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  50440. */
  50441. static CreateDisc(name: string, options: {
  50442. radius?: number;
  50443. tessellation?: number;
  50444. arc?: number;
  50445. updatable?: boolean;
  50446. sideOrientation?: number;
  50447. frontUVs?: Vector4;
  50448. backUVs?: Vector4;
  50449. }, scene?: Nullable<Scene>): Mesh;
  50450. /**
  50451. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  50452. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  50453. * * 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`)
  50454. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  50455. * * 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
  50456. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50457. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50458. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50459. * @param name defines the name of the mesh
  50460. * @param options defines the options used to create the mesh
  50461. * @param scene defines the hosting scene
  50462. * @returns the icosahedron mesh
  50463. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  50464. */
  50465. static CreateIcoSphere(name: string, options: {
  50466. radius?: number;
  50467. radiusX?: number;
  50468. radiusY?: number;
  50469. radiusZ?: number;
  50470. flat?: boolean;
  50471. subdivisions?: number;
  50472. sideOrientation?: number;
  50473. frontUVs?: Vector4;
  50474. backUVs?: Vector4;
  50475. updatable?: boolean;
  50476. }, scene: Scene): Mesh;
  50477. /**
  50478. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  50479. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  50480. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  50481. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  50482. * * 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
  50483. * * 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
  50484. * * 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
  50485. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50486. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50487. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50488. * * 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
  50489. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  50490. * * 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
  50491. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  50492. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50493. * @param name defines the name of the mesh
  50494. * @param options defines the options used to create the mesh
  50495. * @param scene defines the hosting scene
  50496. * @returns the ribbon mesh
  50497. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  50498. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50499. */
  50500. static CreateRibbon(name: string, options: {
  50501. pathArray: Vector3[][];
  50502. closeArray?: boolean;
  50503. closePath?: boolean;
  50504. offset?: number;
  50505. updatable?: boolean;
  50506. sideOrientation?: number;
  50507. frontUVs?: Vector4;
  50508. backUVs?: Vector4;
  50509. instance?: Mesh;
  50510. invertUV?: boolean;
  50511. uvs?: Vector2[];
  50512. colors?: Color4[];
  50513. }, scene?: Nullable<Scene>): Mesh;
  50514. /**
  50515. * Creates a cylinder or a cone mesh
  50516. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  50517. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  50518. * * 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.
  50519. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  50520. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  50521. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  50522. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  50523. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  50524. * * 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).
  50525. * * 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
  50526. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  50527. * * 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
  50528. * * 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.
  50529. * * If `enclose` is false, a ring surface is one element.
  50530. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  50531. * * 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
  50532. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50533. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50534. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50535. * @param name defines the name of the mesh
  50536. * @param options defines the options used to create the mesh
  50537. * @param scene defines the hosting scene
  50538. * @returns the cylinder mesh
  50539. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  50540. */
  50541. static CreateCylinder(name: string, options: {
  50542. height?: number;
  50543. diameterTop?: number;
  50544. diameterBottom?: number;
  50545. diameter?: number;
  50546. tessellation?: number;
  50547. subdivisions?: number;
  50548. arc?: number;
  50549. faceColors?: Color4[];
  50550. faceUV?: Vector4[];
  50551. updatable?: boolean;
  50552. hasRings?: boolean;
  50553. enclose?: boolean;
  50554. sideOrientation?: number;
  50555. frontUVs?: Vector4;
  50556. backUVs?: Vector4;
  50557. }, scene: any): Mesh;
  50558. /**
  50559. * Creates a torus mesh
  50560. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  50561. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  50562. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  50563. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50564. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50565. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50566. * @param name defines the name of the mesh
  50567. * @param options defines the options used to create the mesh
  50568. * @param scene defines the hosting scene
  50569. * @returns the torus mesh
  50570. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  50571. */
  50572. static CreateTorus(name: string, options: {
  50573. diameter?: number;
  50574. thickness?: number;
  50575. tessellation?: number;
  50576. updatable?: boolean;
  50577. sideOrientation?: number;
  50578. frontUVs?: Vector4;
  50579. backUVs?: Vector4;
  50580. }, scene: any): Mesh;
  50581. /**
  50582. * Creates a torus knot mesh
  50583. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  50584. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  50585. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  50586. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  50587. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50588. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50589. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50590. * @param name defines the name of the mesh
  50591. * @param options defines the options used to create the mesh
  50592. * @param scene defines the hosting scene
  50593. * @returns the torus knot mesh
  50594. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  50595. */
  50596. static CreateTorusKnot(name: string, options: {
  50597. radius?: number;
  50598. tube?: number;
  50599. radialSegments?: number;
  50600. tubularSegments?: number;
  50601. p?: number;
  50602. q?: number;
  50603. updatable?: boolean;
  50604. sideOrientation?: number;
  50605. frontUVs?: Vector4;
  50606. backUVs?: Vector4;
  50607. }, scene: any): Mesh;
  50608. /**
  50609. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  50610. * * 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
  50611. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  50612. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  50613. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  50614. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  50615. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  50616. * * 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
  50617. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  50618. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50619. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  50620. * @param name defines the name of the new line system
  50621. * @param options defines the options used to create the line system
  50622. * @param scene defines the hosting scene
  50623. * @returns a new line system mesh
  50624. */
  50625. static CreateLineSystem(name: string, options: {
  50626. lines: Vector3[][];
  50627. updatable?: boolean;
  50628. instance?: Nullable<LinesMesh>;
  50629. colors?: Nullable<Color4[][]>;
  50630. useVertexAlpha?: boolean;
  50631. }, scene: Nullable<Scene>): LinesMesh;
  50632. /**
  50633. * Creates a line mesh
  50634. * 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
  50635. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  50636. * * The parameter `points` is an array successive Vector3
  50637. * * 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
  50638. * * The optional parameter `colors` is an array of successive Color4, one per line point
  50639. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  50640. * * When updating an instance, remember that only point positions can change, not the number of points
  50641. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50642. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  50643. * @param name defines the name of the new line system
  50644. * @param options defines the options used to create the line system
  50645. * @param scene defines the hosting scene
  50646. * @returns a new line mesh
  50647. */
  50648. static CreateLines(name: string, options: {
  50649. points: Vector3[];
  50650. updatable?: boolean;
  50651. instance?: Nullable<LinesMesh>;
  50652. colors?: Color4[];
  50653. useVertexAlpha?: boolean;
  50654. }, scene?: Nullable<Scene>): LinesMesh;
  50655. /**
  50656. * Creates a dashed line mesh
  50657. * * 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
  50658. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  50659. * * The parameter `points` is an array successive Vector3
  50660. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  50661. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  50662. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  50663. * * 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
  50664. * * When updating an instance, remember that only point positions can change, not the number of points
  50665. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50666. * @param name defines the name of the mesh
  50667. * @param options defines the options used to create the mesh
  50668. * @param scene defines the hosting scene
  50669. * @returns the dashed line mesh
  50670. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  50671. */
  50672. static CreateDashedLines(name: string, options: {
  50673. points: Vector3[];
  50674. dashSize?: number;
  50675. gapSize?: number;
  50676. dashNb?: number;
  50677. updatable?: boolean;
  50678. instance?: LinesMesh;
  50679. }, scene?: Nullable<Scene>): LinesMesh;
  50680. /**
  50681. * 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.
  50682. * * 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.
  50683. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50684. * * 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.
  50685. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  50686. * * 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
  50687. * * 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
  50688. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  50689. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50690. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50691. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  50692. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50693. * @param name defines the name of the mesh
  50694. * @param options defines the options used to create the mesh
  50695. * @param scene defines the hosting scene
  50696. * @returns the extruded shape mesh
  50697. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50698. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50699. */
  50700. static ExtrudeShape(name: string, options: {
  50701. shape: Vector3[];
  50702. path: Vector3[];
  50703. scale?: number;
  50704. rotation?: number;
  50705. cap?: number;
  50706. updatable?: boolean;
  50707. sideOrientation?: number;
  50708. frontUVs?: Vector4;
  50709. backUVs?: Vector4;
  50710. instance?: Mesh;
  50711. invertUV?: boolean;
  50712. }, scene?: Nullable<Scene>): Mesh;
  50713. /**
  50714. * Creates an custom extruded shape mesh.
  50715. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  50716. * * 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.
  50717. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50718. * * 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
  50719. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  50720. * * 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
  50721. * * It must returns a float value that will be the scale value applied to the shape on each path point
  50722. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  50723. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  50724. * * 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
  50725. * * 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
  50726. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  50727. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50728. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50729. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50730. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50731. * @param name defines the name of the mesh
  50732. * @param options defines the options used to create the mesh
  50733. * @param scene defines the hosting scene
  50734. * @returns the custom extruded shape mesh
  50735. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  50736. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50737. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50738. */
  50739. static ExtrudeShapeCustom(name: string, options: {
  50740. shape: Vector3[];
  50741. path: Vector3[];
  50742. scaleFunction?: any;
  50743. rotationFunction?: any;
  50744. ribbonCloseArray?: boolean;
  50745. ribbonClosePath?: boolean;
  50746. cap?: number;
  50747. updatable?: boolean;
  50748. sideOrientation?: number;
  50749. frontUVs?: Vector4;
  50750. backUVs?: Vector4;
  50751. instance?: Mesh;
  50752. invertUV?: boolean;
  50753. }, scene: Scene): Mesh;
  50754. /**
  50755. * Creates lathe mesh.
  50756. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  50757. * * 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
  50758. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  50759. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  50760. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  50761. * * 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
  50762. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  50763. * * 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
  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 optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50767. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50768. * @param name defines the name of the mesh
  50769. * @param options defines the options used to create the mesh
  50770. * @param scene defines the hosting scene
  50771. * @returns the lathe mesh
  50772. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  50773. */
  50774. static CreateLathe(name: string, options: {
  50775. shape: Vector3[];
  50776. radius?: number;
  50777. tessellation?: number;
  50778. clip?: number;
  50779. arc?: number;
  50780. closed?: boolean;
  50781. updatable?: boolean;
  50782. sideOrientation?: number;
  50783. frontUVs?: Vector4;
  50784. backUVs?: Vector4;
  50785. cap?: number;
  50786. invertUV?: boolean;
  50787. }, scene: Scene): Mesh;
  50788. /**
  50789. * Creates a plane mesh
  50790. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  50791. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  50792. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  50793. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50794. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50795. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50796. * @param name defines the name of the mesh
  50797. * @param options defines the options used to create the mesh
  50798. * @param scene defines the hosting scene
  50799. * @returns the plane mesh
  50800. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  50801. */
  50802. static CreatePlane(name: string, options: {
  50803. size?: number;
  50804. width?: number;
  50805. height?: number;
  50806. sideOrientation?: number;
  50807. frontUVs?: Vector4;
  50808. backUVs?: Vector4;
  50809. updatable?: boolean;
  50810. sourcePlane?: Plane;
  50811. }, scene: Scene): Mesh;
  50812. /**
  50813. * Creates a ground mesh
  50814. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  50815. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  50816. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50817. * @param name defines the name of the mesh
  50818. * @param options defines the options used to create the mesh
  50819. * @param scene defines the hosting scene
  50820. * @returns the ground mesh
  50821. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  50822. */
  50823. static CreateGround(name: string, options: {
  50824. width?: number;
  50825. height?: number;
  50826. subdivisions?: number;
  50827. subdivisionsX?: number;
  50828. subdivisionsY?: number;
  50829. updatable?: boolean;
  50830. }, scene: any): Mesh;
  50831. /**
  50832. * Creates a tiled ground mesh
  50833. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  50834. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  50835. * * 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
  50836. * * 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
  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. * @param name defines the name of the mesh
  50839. * @param options defines the options used to create the mesh
  50840. * @param scene defines the hosting scene
  50841. * @returns the tiled ground mesh
  50842. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  50843. */
  50844. static CreateTiledGround(name: string, options: {
  50845. xmin: number;
  50846. zmin: number;
  50847. xmax: number;
  50848. zmax: number;
  50849. subdivisions?: {
  50850. w: number;
  50851. h: number;
  50852. };
  50853. precision?: {
  50854. w: number;
  50855. h: number;
  50856. };
  50857. updatable?: boolean;
  50858. }, scene: Scene): Mesh;
  50859. /**
  50860. * Creates a ground mesh from a height map
  50861. * * The parameter `url` sets the URL of the height map image resource.
  50862. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  50863. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  50864. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  50865. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  50866. * * 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.
  50867. * * 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).
  50868. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  50869. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50870. * @param name defines the name of the mesh
  50871. * @param url defines the url to the height map
  50872. * @param options defines the options used to create the mesh
  50873. * @param scene defines the hosting scene
  50874. * @returns the ground mesh
  50875. * @see https://doc.babylonjs.com/babylon101/height_map
  50876. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  50877. */
  50878. static CreateGroundFromHeightMap(name: string, url: string, options: {
  50879. width?: number;
  50880. height?: number;
  50881. subdivisions?: number;
  50882. minHeight?: number;
  50883. maxHeight?: number;
  50884. colorFilter?: Color3;
  50885. alphaFilter?: number;
  50886. updatable?: boolean;
  50887. onReady?: (mesh: GroundMesh) => void;
  50888. }, scene: Scene): GroundMesh;
  50889. /**
  50890. * Creates a polygon mesh
  50891. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  50892. * * 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
  50893. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  50894. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50895. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  50896. * * Remember you can only change the shape positions, not their number when updating a polygon
  50897. * @param name defines the name of the mesh
  50898. * @param options defines the options used to create the mesh
  50899. * @param scene defines the hosting scene
  50900. * @param earcutInjection can be used to inject your own earcut reference
  50901. * @returns the polygon mesh
  50902. */
  50903. static CreatePolygon(name: string, options: {
  50904. shape: Vector3[];
  50905. holes?: Vector3[][];
  50906. depth?: number;
  50907. faceUV?: Vector4[];
  50908. faceColors?: Color4[];
  50909. updatable?: boolean;
  50910. sideOrientation?: number;
  50911. frontUVs?: Vector4;
  50912. backUVs?: Vector4;
  50913. }, scene: Scene, earcutInjection?: any): Mesh;
  50914. /**
  50915. * Creates an extruded polygon mesh, with depth in the Y direction.
  50916. * * 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)
  50917. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  50918. * @param name defines the name of the mesh
  50919. * @param options defines the options used to create the mesh
  50920. * @param scene defines the hosting scene
  50921. * @param earcutInjection can be used to inject your own earcut reference
  50922. * @returns the polygon mesh
  50923. */
  50924. static ExtrudePolygon(name: string, options: {
  50925. shape: Vector3[];
  50926. holes?: Vector3[][];
  50927. depth?: number;
  50928. faceUV?: Vector4[];
  50929. faceColors?: Color4[];
  50930. updatable?: boolean;
  50931. sideOrientation?: number;
  50932. frontUVs?: Vector4;
  50933. backUVs?: Vector4;
  50934. }, scene: Scene, earcutInjection?: any): Mesh;
  50935. /**
  50936. * Creates a tube mesh.
  50937. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  50938. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  50939. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  50940. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  50941. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  50942. * * 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)
  50943. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  50944. * * 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
  50945. * * 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
  50946. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50947. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50948. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50949. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50950. * @param name defines the name of the mesh
  50951. * @param options defines the options used to create the mesh
  50952. * @param scene defines the hosting scene
  50953. * @returns the tube mesh
  50954. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50955. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  50956. */
  50957. static CreateTube(name: string, options: {
  50958. path: Vector3[];
  50959. radius?: number;
  50960. tessellation?: number;
  50961. radiusFunction?: {
  50962. (i: number, distance: number): number;
  50963. };
  50964. cap?: number;
  50965. arc?: number;
  50966. updatable?: boolean;
  50967. sideOrientation?: number;
  50968. frontUVs?: Vector4;
  50969. backUVs?: Vector4;
  50970. instance?: Mesh;
  50971. invertUV?: boolean;
  50972. }, scene: Scene): Mesh;
  50973. /**
  50974. * Creates a polyhedron mesh
  50975. * * 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
  50976. * * The parameter `size` (positive float, default 1) sets the polygon size
  50977. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  50978. * * 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`
  50979. * * 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
  50980. * * 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)`)
  50981. * * 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
  50982. * * 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
  50983. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50984. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50985. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50986. * @param name defines the name of the mesh
  50987. * @param options defines the options used to create the mesh
  50988. * @param scene defines the hosting scene
  50989. * @returns the polyhedron mesh
  50990. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  50991. */
  50992. static CreatePolyhedron(name: string, options: {
  50993. type?: number;
  50994. size?: number;
  50995. sizeX?: number;
  50996. sizeY?: number;
  50997. sizeZ?: number;
  50998. custom?: any;
  50999. faceUV?: Vector4[];
  51000. faceColors?: Color4[];
  51001. flat?: boolean;
  51002. updatable?: boolean;
  51003. sideOrientation?: number;
  51004. frontUVs?: Vector4;
  51005. backUVs?: Vector4;
  51006. }, scene: Scene): Mesh;
  51007. /**
  51008. * Creates a decal mesh.
  51009. * 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
  51010. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  51011. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  51012. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  51013. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  51014. * @param name defines the name of the mesh
  51015. * @param sourceMesh defines the mesh where the decal must be applied
  51016. * @param options defines the options used to create the mesh
  51017. * @param scene defines the hosting scene
  51018. * @returns the decal mesh
  51019. * @see https://doc.babylonjs.com/how_to/decals
  51020. */
  51021. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  51022. position?: Vector3;
  51023. normal?: Vector3;
  51024. size?: Vector3;
  51025. angle?: number;
  51026. }): Mesh;
  51027. }
  51028. }
  51029. declare module "babylonjs/Meshes/meshSimplification" {
  51030. import { Mesh } from "babylonjs/Meshes/mesh";
  51031. /**
  51032. * A simplifier interface for future simplification implementations
  51033. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  51034. */
  51035. export interface ISimplifier {
  51036. /**
  51037. * Simplification of a given mesh according to the given settings.
  51038. * Since this requires computation, it is assumed that the function runs async.
  51039. * @param settings The settings of the simplification, including quality and distance
  51040. * @param successCallback A callback that will be called after the mesh was simplified.
  51041. * @param errorCallback in case of an error, this callback will be called. optional.
  51042. */
  51043. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  51044. }
  51045. /**
  51046. * Expected simplification settings.
  51047. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  51048. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  51049. */
  51050. export interface ISimplificationSettings {
  51051. /**
  51052. * Gets or sets the expected quality
  51053. */
  51054. quality: number;
  51055. /**
  51056. * Gets or sets the distance when this optimized version should be used
  51057. */
  51058. distance: number;
  51059. /**
  51060. * Gets an already optimized mesh
  51061. */
  51062. optimizeMesh?: boolean;
  51063. }
  51064. /**
  51065. * Class used to specify simplification options
  51066. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  51067. */
  51068. export class SimplificationSettings implements ISimplificationSettings {
  51069. /** expected quality */
  51070. quality: number;
  51071. /** distance when this optimized version should be used */
  51072. distance: number;
  51073. /** already optimized mesh */
  51074. optimizeMesh?: boolean | undefined;
  51075. /**
  51076. * Creates a SimplificationSettings
  51077. * @param quality expected quality
  51078. * @param distance distance when this optimized version should be used
  51079. * @param optimizeMesh already optimized mesh
  51080. */
  51081. constructor(
  51082. /** expected quality */
  51083. quality: number,
  51084. /** distance when this optimized version should be used */
  51085. distance: number,
  51086. /** already optimized mesh */
  51087. optimizeMesh?: boolean | undefined);
  51088. }
  51089. /**
  51090. * Interface used to define a simplification task
  51091. */
  51092. export interface ISimplificationTask {
  51093. /**
  51094. * Array of settings
  51095. */
  51096. settings: Array<ISimplificationSettings>;
  51097. /**
  51098. * Simplification type
  51099. */
  51100. simplificationType: SimplificationType;
  51101. /**
  51102. * Mesh to simplify
  51103. */
  51104. mesh: Mesh;
  51105. /**
  51106. * Callback called on success
  51107. */
  51108. successCallback?: () => void;
  51109. /**
  51110. * Defines if parallel processing can be used
  51111. */
  51112. parallelProcessing: boolean;
  51113. }
  51114. /**
  51115. * Queue used to order the simplification tasks
  51116. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  51117. */
  51118. export class SimplificationQueue {
  51119. private _simplificationArray;
  51120. /**
  51121. * Gets a boolean indicating that the process is still running
  51122. */
  51123. running: boolean;
  51124. /**
  51125. * Creates a new queue
  51126. */
  51127. constructor();
  51128. /**
  51129. * Adds a new simplification task
  51130. * @param task defines a task to add
  51131. */
  51132. addTask(task: ISimplificationTask): void;
  51133. /**
  51134. * Execute next task
  51135. */
  51136. executeNext(): void;
  51137. /**
  51138. * Execute a simplification task
  51139. * @param task defines the task to run
  51140. */
  51141. runSimplification(task: ISimplificationTask): void;
  51142. private getSimplifier;
  51143. }
  51144. /**
  51145. * The implemented types of simplification
  51146. * At the moment only Quadratic Error Decimation is implemented
  51147. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  51148. */
  51149. export enum SimplificationType {
  51150. /** Quadratic error decimation */
  51151. QUADRATIC = 0
  51152. }
  51153. }
  51154. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  51155. import { Scene } from "babylonjs/scene";
  51156. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  51157. import { ISceneComponent } from "babylonjs/sceneComponent";
  51158. module "babylonjs/scene" {
  51159. interface Scene {
  51160. /** @hidden (Backing field) */
  51161. _simplificationQueue: SimplificationQueue;
  51162. /**
  51163. * Gets or sets the simplification queue attached to the scene
  51164. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  51165. */
  51166. simplificationQueue: SimplificationQueue;
  51167. }
  51168. }
  51169. module "babylonjs/Meshes/mesh" {
  51170. interface Mesh {
  51171. /**
  51172. * Simplify the mesh according to the given array of settings.
  51173. * Function will return immediately and will simplify async
  51174. * @param settings a collection of simplification settings
  51175. * @param parallelProcessing should all levels calculate parallel or one after the other
  51176. * @param simplificationType the type of simplification to run
  51177. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  51178. * @returns the current mesh
  51179. */
  51180. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  51181. }
  51182. }
  51183. /**
  51184. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  51185. * created in a scene
  51186. */
  51187. export class SimplicationQueueSceneComponent implements ISceneComponent {
  51188. /**
  51189. * The component name helpfull to identify the component in the list of scene components.
  51190. */
  51191. readonly name: string;
  51192. /**
  51193. * The scene the component belongs to.
  51194. */
  51195. scene: Scene;
  51196. /**
  51197. * Creates a new instance of the component for the given scene
  51198. * @param scene Defines the scene to register the component in
  51199. */
  51200. constructor(scene: Scene);
  51201. /**
  51202. * Registers the component in a given scene
  51203. */
  51204. register(): void;
  51205. /**
  51206. * Rebuilds the elements related to this component in case of
  51207. * context lost for instance.
  51208. */
  51209. rebuild(): void;
  51210. /**
  51211. * Disposes the component and the associated ressources
  51212. */
  51213. dispose(): void;
  51214. private _beforeCameraUpdate;
  51215. }
  51216. }
  51217. declare module "babylonjs/Meshes/Builders/index" {
  51218. export * from "babylonjs/Meshes/Builders/boxBuilder";
  51219. export * from "babylonjs/Meshes/Builders/discBuilder";
  51220. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  51221. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  51222. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  51223. export * from "babylonjs/Meshes/Builders/torusBuilder";
  51224. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  51225. export * from "babylonjs/Meshes/Builders/linesBuilder";
  51226. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  51227. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  51228. export * from "babylonjs/Meshes/Builders/latheBuilder";
  51229. export * from "babylonjs/Meshes/Builders/planeBuilder";
  51230. export * from "babylonjs/Meshes/Builders/groundBuilder";
  51231. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  51232. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  51233. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  51234. export * from "babylonjs/Meshes/Builders/decalBuilder";
  51235. }
  51236. declare module "babylonjs/Meshes/index" {
  51237. export * from "babylonjs/Meshes/abstractMesh";
  51238. export * from "babylonjs/Meshes/buffer";
  51239. export * from "babylonjs/Meshes/Compression/index";
  51240. export * from "babylonjs/Meshes/csg";
  51241. export * from "babylonjs/Meshes/geometry";
  51242. export * from "babylonjs/Meshes/groundMesh";
  51243. export * from "babylonjs/Meshes/trailMesh";
  51244. export * from "babylonjs/Meshes/instancedMesh";
  51245. export * from "babylonjs/Meshes/linesMesh";
  51246. export * from "babylonjs/Meshes/mesh";
  51247. export * from "babylonjs/Meshes/mesh.vertexData";
  51248. export * from "babylonjs/Meshes/meshBuilder";
  51249. export * from "babylonjs/Meshes/meshSimplification";
  51250. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  51251. export * from "babylonjs/Meshes/polygonMesh";
  51252. export * from "babylonjs/Meshes/subMesh";
  51253. export * from "babylonjs/Meshes/transformNode";
  51254. export * from "babylonjs/Meshes/Builders/index";
  51255. }
  51256. declare module "babylonjs/Morph/index" {
  51257. export * from "babylonjs/Morph/morphTarget";
  51258. export * from "babylonjs/Morph/morphTargetManager";
  51259. }
  51260. declare module "babylonjs/Offline/database" {
  51261. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  51262. /**
  51263. * Class used to enable access to IndexedDB
  51264. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  51265. */
  51266. export class Database implements IOfflineProvider {
  51267. private _callbackManifestChecked;
  51268. private _currentSceneUrl;
  51269. private _db;
  51270. private _enableSceneOffline;
  51271. private _enableTexturesOffline;
  51272. private _manifestVersionFound;
  51273. private _mustUpdateRessources;
  51274. private _hasReachedQuota;
  51275. private _isSupported;
  51276. private _idbFactory;
  51277. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  51278. private static IsUASupportingBlobStorage;
  51279. /**
  51280. * Gets a boolean indicating if Database storate is enabled (off by default)
  51281. */
  51282. static IDBStorageEnabled: boolean;
  51283. /**
  51284. * Gets a boolean indicating if scene must be saved in the database
  51285. */
  51286. readonly enableSceneOffline: boolean;
  51287. /**
  51288. * Gets a boolean indicating if textures must be saved in the database
  51289. */
  51290. readonly enableTexturesOffline: boolean;
  51291. /**
  51292. * Creates a new Database
  51293. * @param urlToScene defines the url to load the scene
  51294. * @param callbackManifestChecked defines the callback to use when manifest is checked
  51295. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  51296. */
  51297. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  51298. private static _ParseURL;
  51299. private static _ReturnFullUrlLocation;
  51300. private _checkManifestFile;
  51301. /**
  51302. * Open the database and make it available
  51303. * @param successCallback defines the callback to call on success
  51304. * @param errorCallback defines the callback to call on error
  51305. */
  51306. open(successCallback: () => void, errorCallback: () => void): void;
  51307. /**
  51308. * Loads an image from the database
  51309. * @param url defines the url to load from
  51310. * @param image defines the target DOM image
  51311. */
  51312. loadImage(url: string, image: HTMLImageElement): void;
  51313. private _loadImageFromDBAsync;
  51314. private _saveImageIntoDBAsync;
  51315. private _checkVersionFromDB;
  51316. private _loadVersionFromDBAsync;
  51317. private _saveVersionIntoDBAsync;
  51318. /**
  51319. * Loads a file from database
  51320. * @param url defines the URL to load from
  51321. * @param sceneLoaded defines a callback to call on success
  51322. * @param progressCallBack defines a callback to call when progress changed
  51323. * @param errorCallback defines a callback to call on error
  51324. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  51325. */
  51326. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  51327. private _loadFileAsync;
  51328. private _saveFileAsync;
  51329. /**
  51330. * Validates if xhr data is correct
  51331. * @param xhr defines the request to validate
  51332. * @param dataType defines the expected data type
  51333. * @returns true if data is correct
  51334. */
  51335. private static _ValidateXHRData;
  51336. }
  51337. }
  51338. declare module "babylonjs/Offline/index" {
  51339. export * from "babylonjs/Offline/database";
  51340. export * from "babylonjs/Offline/IOfflineProvider";
  51341. }
  51342. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  51343. /** @hidden */
  51344. export var gpuUpdateParticlesPixelShader: {
  51345. name: string;
  51346. shader: string;
  51347. };
  51348. }
  51349. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  51350. /** @hidden */
  51351. export var gpuUpdateParticlesVertexShader: {
  51352. name: string;
  51353. shader: string;
  51354. };
  51355. }
  51356. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  51357. /** @hidden */
  51358. export var clipPlaneFragmentDeclaration2: {
  51359. name: string;
  51360. shader: string;
  51361. };
  51362. }
  51363. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  51364. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  51365. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  51366. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  51367. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  51368. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  51369. /** @hidden */
  51370. export var gpuRenderParticlesPixelShader: {
  51371. name: string;
  51372. shader: string;
  51373. };
  51374. }
  51375. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  51376. /** @hidden */
  51377. export var clipPlaneVertexDeclaration2: {
  51378. name: string;
  51379. shader: string;
  51380. };
  51381. }
  51382. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  51383. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  51384. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  51385. /** @hidden */
  51386. export var gpuRenderParticlesVertexShader: {
  51387. name: string;
  51388. shader: string;
  51389. };
  51390. }
  51391. declare module "babylonjs/Particles/gpuParticleSystem" {
  51392. import { Nullable } from "babylonjs/types";
  51393. import { IAnimatable, IValueGradient, Color3Gradient } from "babylonjs/Misc/tools";
  51394. import { Observable } from "babylonjs/Misc/observable";
  51395. import { Color4, Color3 } from "babylonjs/Maths/math";
  51396. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  51397. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  51398. import { Scene, IDisposable } from "babylonjs/scene";
  51399. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  51400. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  51401. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  51402. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  51403. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  51404. /**
  51405. * This represents a GPU particle system in Babylon
  51406. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  51407. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  51408. */
  51409. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  51410. /**
  51411. * The layer mask we are rendering the particles through.
  51412. */
  51413. layerMask: number;
  51414. private _capacity;
  51415. private _activeCount;
  51416. private _currentActiveCount;
  51417. private _accumulatedCount;
  51418. private _renderEffect;
  51419. private _updateEffect;
  51420. private _buffer0;
  51421. private _buffer1;
  51422. private _spriteBuffer;
  51423. private _updateVAO;
  51424. private _renderVAO;
  51425. private _targetIndex;
  51426. private _sourceBuffer;
  51427. private _targetBuffer;
  51428. private _engine;
  51429. private _currentRenderId;
  51430. private _started;
  51431. private _stopped;
  51432. private _timeDelta;
  51433. private _randomTexture;
  51434. private _randomTexture2;
  51435. private _attributesStrideSize;
  51436. private _updateEffectOptions;
  51437. private _randomTextureSize;
  51438. private _actualFrame;
  51439. private readonly _rawTextureWidth;
  51440. /**
  51441. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  51442. */
  51443. static readonly IsSupported: boolean;
  51444. /**
  51445. * An event triggered when the system is disposed.
  51446. */
  51447. onDisposeObservable: Observable<GPUParticleSystem>;
  51448. /**
  51449. * Gets the maximum number of particles active at the same time.
  51450. * @returns The max number of active particles.
  51451. */
  51452. getCapacity(): number;
  51453. /**
  51454. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  51455. * to override the particles.
  51456. */
  51457. forceDepthWrite: boolean;
  51458. /**
  51459. * Gets or set the number of active particles
  51460. */
  51461. activeParticleCount: number;
  51462. private _preWarmDone;
  51463. /**
  51464. * Is this system ready to be used/rendered
  51465. * @return true if the system is ready
  51466. */
  51467. isReady(): boolean;
  51468. /**
  51469. * Gets if the system has been started. (Note: this will still be true after stop is called)
  51470. * @returns True if it has been started, otherwise false.
  51471. */
  51472. isStarted(): boolean;
  51473. /**
  51474. * Starts the particle system and begins to emit
  51475. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  51476. */
  51477. start(delay?: number): void;
  51478. /**
  51479. * Stops the particle system.
  51480. */
  51481. stop(): void;
  51482. /**
  51483. * Remove all active particles
  51484. */
  51485. reset(): void;
  51486. /**
  51487. * Returns the string "GPUParticleSystem"
  51488. * @returns a string containing the class name
  51489. */
  51490. getClassName(): string;
  51491. private _colorGradientsTexture;
  51492. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  51493. /**
  51494. * Adds a new color gradient
  51495. * @param gradient defines the gradient to use (between 0 and 1)
  51496. * @param color1 defines the color to affect to the specified gradient
  51497. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  51498. * @returns the current particle system
  51499. */
  51500. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  51501. /**
  51502. * Remove a specific color gradient
  51503. * @param gradient defines the gradient to remove
  51504. * @returns the current particle system
  51505. */
  51506. removeColorGradient(gradient: number): GPUParticleSystem;
  51507. private _angularSpeedGradientsTexture;
  51508. private _sizeGradientsTexture;
  51509. private _velocityGradientsTexture;
  51510. private _limitVelocityGradientsTexture;
  51511. private _dragGradientsTexture;
  51512. private _addFactorGradient;
  51513. /**
  51514. * Adds a new size gradient
  51515. * @param gradient defines the gradient to use (between 0 and 1)
  51516. * @param factor defines the size factor to affect to the specified gradient
  51517. * @returns the current particle system
  51518. */
  51519. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  51520. /**
  51521. * Remove a specific size gradient
  51522. * @param gradient defines the gradient to remove
  51523. * @returns the current particle system
  51524. */
  51525. removeSizeGradient(gradient: number): GPUParticleSystem;
  51526. /**
  51527. * Adds a new angular speed gradient
  51528. * @param gradient defines the gradient to use (between 0 and 1)
  51529. * @param factor defines the angular speed to affect to the specified gradient
  51530. * @returns the current particle system
  51531. */
  51532. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  51533. /**
  51534. * Remove a specific angular speed gradient
  51535. * @param gradient defines the gradient to remove
  51536. * @returns the current particle system
  51537. */
  51538. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  51539. /**
  51540. * Adds a new velocity gradient
  51541. * @param gradient defines the gradient to use (between 0 and 1)
  51542. * @param factor defines the velocity to affect to the specified gradient
  51543. * @returns the current particle system
  51544. */
  51545. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  51546. /**
  51547. * Remove a specific velocity gradient
  51548. * @param gradient defines the gradient to remove
  51549. * @returns the current particle system
  51550. */
  51551. removeVelocityGradient(gradient: number): GPUParticleSystem;
  51552. /**
  51553. * Adds a new limit velocity gradient
  51554. * @param gradient defines the gradient to use (between 0 and 1)
  51555. * @param factor defines the limit velocity value to affect to the specified gradient
  51556. * @returns the current particle system
  51557. */
  51558. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  51559. /**
  51560. * Remove a specific limit velocity gradient
  51561. * @param gradient defines the gradient to remove
  51562. * @returns the current particle system
  51563. */
  51564. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  51565. /**
  51566. * Adds a new drag gradient
  51567. * @param gradient defines the gradient to use (between 0 and 1)
  51568. * @param factor defines the drag value to affect to the specified gradient
  51569. * @returns the current particle system
  51570. */
  51571. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  51572. /**
  51573. * Remove a specific drag gradient
  51574. * @param gradient defines the gradient to remove
  51575. * @returns the current particle system
  51576. */
  51577. removeDragGradient(gradient: number): GPUParticleSystem;
  51578. /**
  51579. * Not supported by GPUParticleSystem
  51580. * @param gradient defines the gradient to use (between 0 and 1)
  51581. * @param factor defines the emit rate value to affect to the specified gradient
  51582. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  51583. * @returns the current particle system
  51584. */
  51585. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  51586. /**
  51587. * Not supported by GPUParticleSystem
  51588. * @param gradient defines the gradient to remove
  51589. * @returns the current particle system
  51590. */
  51591. removeEmitRateGradient(gradient: number): IParticleSystem;
  51592. /**
  51593. * Not supported by GPUParticleSystem
  51594. * @param gradient defines the gradient to use (between 0 and 1)
  51595. * @param factor defines the start size value to affect to the specified gradient
  51596. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  51597. * @returns the current particle system
  51598. */
  51599. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  51600. /**
  51601. * Not supported by GPUParticleSystem
  51602. * @param gradient defines the gradient to remove
  51603. * @returns the current particle system
  51604. */
  51605. removeStartSizeGradient(gradient: number): IParticleSystem;
  51606. /**
  51607. * Not supported by GPUParticleSystem
  51608. * @param gradient defines the gradient to use (between 0 and 1)
  51609. * @param min defines the color remap minimal range
  51610. * @param max defines the color remap maximal range
  51611. * @returns the current particle system
  51612. */
  51613. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  51614. /**
  51615. * Not supported by GPUParticleSystem
  51616. * @param gradient defines the gradient to remove
  51617. * @returns the current particle system
  51618. */
  51619. removeColorRemapGradient(): IParticleSystem;
  51620. /**
  51621. * Not supported by GPUParticleSystem
  51622. * @param gradient defines the gradient to use (between 0 and 1)
  51623. * @param min defines the alpha remap minimal range
  51624. * @param max defines the alpha remap maximal range
  51625. * @returns the current particle system
  51626. */
  51627. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  51628. /**
  51629. * Not supported by GPUParticleSystem
  51630. * @param gradient defines the gradient to remove
  51631. * @returns the current particle system
  51632. */
  51633. removeAlphaRemapGradient(): IParticleSystem;
  51634. /**
  51635. * Not supported by GPUParticleSystem
  51636. * @param gradient defines the gradient to use (between 0 and 1)
  51637. * @param color defines the color to affect to the specified gradient
  51638. * @returns the current particle system
  51639. */
  51640. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  51641. /**
  51642. * Not supported by GPUParticleSystem
  51643. * @param gradient defines the gradient to remove
  51644. * @returns the current particle system
  51645. */
  51646. removeRampGradient(): IParticleSystem;
  51647. /**
  51648. * Not supported by GPUParticleSystem
  51649. * @returns the list of ramp gradients
  51650. */
  51651. getRampGradients(): Nullable<Array<Color3Gradient>>;
  51652. /**
  51653. * Not supported by GPUParticleSystem
  51654. * Gets or sets a boolean indicating that ramp gradients must be used
  51655. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  51656. */
  51657. useRampGradients: boolean;
  51658. /**
  51659. * Not supported by GPUParticleSystem
  51660. * @param gradient defines the gradient to use (between 0 and 1)
  51661. * @param factor defines the life time factor to affect to the specified gradient
  51662. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  51663. * @returns the current particle system
  51664. */
  51665. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  51666. /**
  51667. * Not supported by GPUParticleSystem
  51668. * @param gradient defines the gradient to remove
  51669. * @returns the current particle system
  51670. */
  51671. removeLifeTimeGradient(gradient: number): IParticleSystem;
  51672. /**
  51673. * Instantiates a GPU particle system.
  51674. * 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.
  51675. * @param name The name of the particle system
  51676. * @param options The options used to create the system
  51677. * @param scene The scene the particle system belongs to
  51678. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  51679. */
  51680. constructor(name: string, options: Partial<{
  51681. capacity: number;
  51682. randomTextureSize: number;
  51683. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  51684. protected _reset(): void;
  51685. private _createUpdateVAO;
  51686. private _createRenderVAO;
  51687. private _initialize;
  51688. /** @hidden */
  51689. _recreateUpdateEffect(): void;
  51690. /** @hidden */
  51691. _recreateRenderEffect(): void;
  51692. /**
  51693. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  51694. * @param preWarm defines if we are in the pre-warmimg phase
  51695. */
  51696. animate(preWarm?: boolean): void;
  51697. private _createFactorGradientTexture;
  51698. private _createSizeGradientTexture;
  51699. private _createAngularSpeedGradientTexture;
  51700. private _createVelocityGradientTexture;
  51701. private _createLimitVelocityGradientTexture;
  51702. private _createDragGradientTexture;
  51703. private _createColorGradientTexture;
  51704. /**
  51705. * Renders the particle system in its current state
  51706. * @param preWarm defines if the system should only update the particles but not render them
  51707. * @returns the current number of particles
  51708. */
  51709. render(preWarm?: boolean): number;
  51710. /**
  51711. * Rebuilds the particle system
  51712. */
  51713. rebuild(): void;
  51714. private _releaseBuffers;
  51715. private _releaseVAOs;
  51716. /**
  51717. * Disposes the particle system and free the associated resources
  51718. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  51719. */
  51720. dispose(disposeTexture?: boolean): void;
  51721. /**
  51722. * Clones the particle system.
  51723. * @param name The name of the cloned object
  51724. * @param newEmitter The new emitter to use
  51725. * @returns the cloned particle system
  51726. */
  51727. clone(name: string, newEmitter: any): GPUParticleSystem;
  51728. /**
  51729. * Serializes the particle system to a JSON object.
  51730. * @returns the JSON object
  51731. */
  51732. serialize(): any;
  51733. /**
  51734. * Parses a JSON object to create a GPU particle system.
  51735. * @param parsedParticleSystem The JSON object to parse
  51736. * @param scene The scene to create the particle system in
  51737. * @param rootUrl The root url to use to load external dependencies like texture
  51738. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  51739. * @returns the parsed GPU particle system
  51740. */
  51741. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  51742. }
  51743. }
  51744. declare module "babylonjs/Particles/particleSystemSet" {
  51745. import { Nullable } from "babylonjs/types";
  51746. import { Color3 } from "babylonjs/Maths/math";
  51747. import { TransformNode } from "babylonjs/Meshes/transformNode";
  51748. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51749. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  51750. import { Scene, IDisposable } from "babylonjs/scene";
  51751. /**
  51752. * Represents a set of particle systems working together to create a specific effect
  51753. */
  51754. export class ParticleSystemSet implements IDisposable {
  51755. private _emitterCreationOptions;
  51756. private _emitterNode;
  51757. /**
  51758. * Gets the particle system list
  51759. */
  51760. systems: IParticleSystem[];
  51761. /**
  51762. * Gets the emitter node used with this set
  51763. */
  51764. readonly emitterNode: Nullable<TransformNode>;
  51765. /**
  51766. * Creates a new emitter mesh as a sphere
  51767. * @param options defines the options used to create the sphere
  51768. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  51769. * @param scene defines the hosting scene
  51770. */
  51771. setEmitterAsSphere(options: {
  51772. diameter: number;
  51773. segments: number;
  51774. color: Color3;
  51775. }, renderingGroupId: number, scene: Scene): void;
  51776. /**
  51777. * Starts all particle systems of the set
  51778. * @param emitter defines an optional mesh to use as emitter for the particle systems
  51779. */
  51780. start(emitter?: AbstractMesh): void;
  51781. /**
  51782. * Release all associated resources
  51783. */
  51784. dispose(): void;
  51785. /**
  51786. * Serialize the set into a JSON compatible object
  51787. * @returns a JSON compatible representation of the set
  51788. */
  51789. serialize(): any;
  51790. /**
  51791. * Parse a new ParticleSystemSet from a serialized source
  51792. * @param data defines a JSON compatible representation of the set
  51793. * @param scene defines the hosting scene
  51794. * @param gpu defines if we want GPU particles or CPU particles
  51795. * @returns a new ParticleSystemSet
  51796. */
  51797. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  51798. }
  51799. }
  51800. declare module "babylonjs/Particles/particleHelper" {
  51801. import { Nullable } from "babylonjs/types";
  51802. import { Scene } from "babylonjs/scene";
  51803. import { Vector3 } from "babylonjs/Maths/math";
  51804. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51805. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  51806. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  51807. /**
  51808. * This class is made for on one-liner static method to help creating particle system set.
  51809. */
  51810. export class ParticleHelper {
  51811. /**
  51812. * Gets or sets base Assets URL
  51813. */
  51814. static BaseAssetsUrl: string;
  51815. /**
  51816. * Create a default particle system that you can tweak
  51817. * @param emitter defines the emitter to use
  51818. * @param capacity defines the system capacity (default is 500 particles)
  51819. * @param scene defines the hosting scene
  51820. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  51821. * @returns the new Particle system
  51822. */
  51823. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  51824. /**
  51825. * This is the main static method (one-liner) of this helper to create different particle systems
  51826. * @param type This string represents the type to the particle system to create
  51827. * @param scene The scene where the particle system should live
  51828. * @param gpu If the system will use gpu
  51829. * @returns the ParticleSystemSet created
  51830. */
  51831. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  51832. /**
  51833. * Static function used to export a particle system to a ParticleSystemSet variable.
  51834. * Please note that the emitter shape is not exported
  51835. * @param systems defines the particle systems to export
  51836. * @returns the created particle system set
  51837. */
  51838. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  51839. }
  51840. }
  51841. declare module "babylonjs/Particles/particleSystemComponent" {
  51842. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  51843. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  51844. import "babylonjs/Shaders/particles.vertex";
  51845. module "babylonjs/Engines/engine" {
  51846. interface Engine {
  51847. /**
  51848. * Create an effect to use with particle systems.
  51849. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  51850. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  51851. * @param uniformsNames defines a list of attribute names
  51852. * @param samplers defines an array of string used to represent textures
  51853. * @param defines defines the string containing the defines to use to compile the shaders
  51854. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  51855. * @param onCompiled defines a function to call when the effect creation is successful
  51856. * @param onError defines a function to call when the effect creation has failed
  51857. * @returns the new Effect
  51858. */
  51859. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  51860. }
  51861. }
  51862. module "babylonjs/Meshes/mesh" {
  51863. interface Mesh {
  51864. /**
  51865. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  51866. * @returns an array of IParticleSystem
  51867. */
  51868. getEmittedParticleSystems(): IParticleSystem[];
  51869. /**
  51870. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  51871. * @returns an array of IParticleSystem
  51872. */
  51873. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  51874. }
  51875. }
  51876. /**
  51877. * @hidden
  51878. */
  51879. export var _IDoNeedToBeInTheBuild: number;
  51880. }
  51881. declare module "babylonjs/Particles/index" {
  51882. export * from "babylonjs/Particles/baseParticleSystem";
  51883. export * from "babylonjs/Particles/EmitterTypes/index";
  51884. export * from "babylonjs/Particles/gpuParticleSystem";
  51885. export * from "babylonjs/Particles/IParticleSystem";
  51886. export * from "babylonjs/Particles/particle";
  51887. export * from "babylonjs/Particles/particleHelper";
  51888. export * from "babylonjs/Particles/particleSystem";
  51889. export * from "babylonjs/Particles/particleSystemComponent";
  51890. export * from "babylonjs/Particles/particleSystemSet";
  51891. export * from "babylonjs/Particles/solidParticle";
  51892. export * from "babylonjs/Particles/solidParticleSystem";
  51893. export * from "babylonjs/Particles/subEmitter";
  51894. }
  51895. declare module "babylonjs/Physics/physicsEngineComponent" {
  51896. import { Nullable } from "babylonjs/types";
  51897. import { Observable, Observer } from "babylonjs/Misc/observable";
  51898. import { Vector3 } from "babylonjs/Maths/math";
  51899. import { Mesh } from "babylonjs/Meshes/mesh";
  51900. import { ISceneComponent } from "babylonjs/sceneComponent";
  51901. import { Scene } from "babylonjs/scene";
  51902. import { Node } from "babylonjs/node";
  51903. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  51904. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  51905. module "babylonjs/scene" {
  51906. interface Scene {
  51907. /** @hidden (Backing field) */
  51908. _physicsEngine: Nullable<IPhysicsEngine>;
  51909. /**
  51910. * Gets the current physics engine
  51911. * @returns a IPhysicsEngine or null if none attached
  51912. */
  51913. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  51914. /**
  51915. * Enables physics to the current scene
  51916. * @param gravity defines the scene's gravity for the physics engine
  51917. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  51918. * @return a boolean indicating if the physics engine was initialized
  51919. */
  51920. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  51921. /**
  51922. * Disables and disposes the physics engine associated with the scene
  51923. */
  51924. disablePhysicsEngine(): void;
  51925. /**
  51926. * Gets a boolean indicating if there is an active physics engine
  51927. * @returns a boolean indicating if there is an active physics engine
  51928. */
  51929. isPhysicsEnabled(): boolean;
  51930. /**
  51931. * Deletes a physics compound impostor
  51932. * @param compound defines the compound to delete
  51933. */
  51934. deleteCompoundImpostor(compound: any): void;
  51935. /**
  51936. * An event triggered when physic simulation is about to be run
  51937. */
  51938. onBeforePhysicsObservable: Observable<Scene>;
  51939. /**
  51940. * An event triggered when physic simulation has been done
  51941. */
  51942. onAfterPhysicsObservable: Observable<Scene>;
  51943. }
  51944. }
  51945. module "babylonjs/Meshes/abstractMesh" {
  51946. interface AbstractMesh {
  51947. /** @hidden */
  51948. _physicsImpostor: Nullable<PhysicsImpostor>;
  51949. /**
  51950. * Gets or sets impostor used for physic simulation
  51951. * @see http://doc.babylonjs.com/features/physics_engine
  51952. */
  51953. physicsImpostor: Nullable<PhysicsImpostor>;
  51954. /**
  51955. * Gets the current physics impostor
  51956. * @see http://doc.babylonjs.com/features/physics_engine
  51957. * @returns a physics impostor or null
  51958. */
  51959. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  51960. /** Apply a physic impulse to the mesh
  51961. * @param force defines the force to apply
  51962. * @param contactPoint defines where to apply the force
  51963. * @returns the current mesh
  51964. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  51965. */
  51966. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  51967. /**
  51968. * Creates a physic joint between two meshes
  51969. * @param otherMesh defines the other mesh to use
  51970. * @param pivot1 defines the pivot to use on this mesh
  51971. * @param pivot2 defines the pivot to use on the other mesh
  51972. * @param options defines additional options (can be plugin dependent)
  51973. * @returns the current mesh
  51974. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  51975. */
  51976. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  51977. /** @hidden */
  51978. _disposePhysicsObserver: Nullable<Observer<Node>>;
  51979. }
  51980. }
  51981. /**
  51982. * Defines the physics engine scene component responsible to manage a physics engine
  51983. */
  51984. export class PhysicsEngineSceneComponent implements ISceneComponent {
  51985. /**
  51986. * The component name helpful to identify the component in the list of scene components.
  51987. */
  51988. readonly name: string;
  51989. /**
  51990. * The scene the component belongs to.
  51991. */
  51992. scene: Scene;
  51993. /**
  51994. * Creates a new instance of the component for the given scene
  51995. * @param scene Defines the scene to register the component in
  51996. */
  51997. constructor(scene: Scene);
  51998. /**
  51999. * Registers the component in a given scene
  52000. */
  52001. register(): void;
  52002. /**
  52003. * Rebuilds the elements related to this component in case of
  52004. * context lost for instance.
  52005. */
  52006. rebuild(): void;
  52007. /**
  52008. * Disposes the component and the associated ressources
  52009. */
  52010. dispose(): void;
  52011. }
  52012. }
  52013. declare module "babylonjs/Physics/physicsHelper" {
  52014. import { Nullable } from "babylonjs/types";
  52015. import { Vector3 } from "babylonjs/Maths/math";
  52016. import { Mesh } from "babylonjs/Meshes/mesh";
  52017. import { Ray } from "babylonjs/Culling/ray";
  52018. import { Scene } from "babylonjs/scene";
  52019. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  52020. /**
  52021. * A helper for physics simulations
  52022. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52023. */
  52024. export class PhysicsHelper {
  52025. private _scene;
  52026. private _physicsEngine;
  52027. /**
  52028. * Initializes the Physics helper
  52029. * @param scene Babylon.js scene
  52030. */
  52031. constructor(scene: Scene);
  52032. /**
  52033. * Applies a radial explosion impulse
  52034. * @param origin the origin of the explosion
  52035. * @param radius the explosion radius
  52036. * @param strength the explosion strength
  52037. * @param falloff possible options: Constant & Linear. Defaults to Constant
  52038. * @returns A physics radial explosion event, or null
  52039. */
  52040. applyRadialExplosionImpulse(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  52041. /**
  52042. * Applies a radial explosion force
  52043. * @param origin the origin of the explosion
  52044. * @param radius the explosion radius
  52045. * @param strength the explosion strength
  52046. * @param falloff possible options: Constant & Linear. Defaults to Constant
  52047. * @returns A physics radial explosion event, or null
  52048. */
  52049. applyRadialExplosionForce(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  52050. /**
  52051. * Creates a gravitational field
  52052. * @param origin the origin of the explosion
  52053. * @param radius the explosion radius
  52054. * @param strength the explosion strength
  52055. * @param falloff possible options: Constant & Linear. Defaults to Constant
  52056. * @returns A physics gravitational field event, or null
  52057. */
  52058. gravitationalField(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  52059. /**
  52060. * Creates a physics updraft event
  52061. * @param origin the origin of the updraft
  52062. * @param radius the radius of the updraft
  52063. * @param strength the strength of the updraft
  52064. * @param height the height of the updraft
  52065. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  52066. * @returns A physics updraft event, or null
  52067. */
  52068. updraft(origin: Vector3, radius: number, strength: number, height: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  52069. /**
  52070. * Creates a physics vortex event
  52071. * @param origin the of the vortex
  52072. * @param radius the radius of the vortex
  52073. * @param strength the strength of the vortex
  52074. * @param height the height of the vortex
  52075. * @returns a Physics vortex event, or null
  52076. * A physics vortex event or null
  52077. */
  52078. vortex(origin: Vector3, radius: number, strength: number, height: number): Nullable<PhysicsVortexEvent>;
  52079. }
  52080. /**
  52081. * Represents a physics radial explosion event
  52082. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52083. */
  52084. export class PhysicsRadialExplosionEvent {
  52085. private _scene;
  52086. private _sphere;
  52087. private _sphereOptions;
  52088. private _rays;
  52089. private _dataFetched;
  52090. /**
  52091. * Initializes a radial explosioin event
  52092. * @param scene BabylonJS scene
  52093. */
  52094. constructor(scene: Scene);
  52095. /**
  52096. * Returns the data related to the radial explosion event (sphere & rays).
  52097. * @returns The radial explosion event data
  52098. */
  52099. getData(): PhysicsRadialExplosionEventData;
  52100. /**
  52101. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  52102. * @param impostor A physics imposter
  52103. * @param origin the origin of the explosion
  52104. * @param radius the explosion radius
  52105. * @param strength the explosion strength
  52106. * @param falloff possible options: Constant & Linear
  52107. * @returns {Nullable<PhysicsForceAndContactPoint>} A physics force and contact point, or null
  52108. */
  52109. getImpostorForceAndContactPoint(impostor: PhysicsImpostor, origin: Vector3, radius: number, strength: number, falloff: PhysicsRadialImpulseFalloff): Nullable<PhysicsForceAndContactPoint>;
  52110. /**
  52111. * Disposes the sphere.
  52112. * @param force Specifies if the sphere should be disposed by force
  52113. */
  52114. dispose(force?: boolean): void;
  52115. /*** Helpers ***/
  52116. private _prepareSphere;
  52117. private _intersectsWithSphere;
  52118. }
  52119. /**
  52120. * Represents a gravitational field event
  52121. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52122. */
  52123. export class PhysicsGravitationalFieldEvent {
  52124. private _physicsHelper;
  52125. private _scene;
  52126. private _origin;
  52127. private _radius;
  52128. private _strength;
  52129. private _falloff;
  52130. private _tickCallback;
  52131. private _sphere;
  52132. private _dataFetched;
  52133. /**
  52134. * Initializes the physics gravitational field event
  52135. * @param physicsHelper A physics helper
  52136. * @param scene BabylonJS scene
  52137. * @param origin The origin position of the gravitational field event
  52138. * @param radius The radius of the gravitational field event
  52139. * @param strength The strength of the gravitational field event
  52140. * @param falloff The falloff for the gravitational field event
  52141. */
  52142. constructor(physicsHelper: PhysicsHelper, scene: Scene, origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff);
  52143. /**
  52144. * Returns the data related to the gravitational field event (sphere).
  52145. * @returns A gravitational field event
  52146. */
  52147. getData(): PhysicsGravitationalFieldEventData;
  52148. /**
  52149. * Enables the gravitational field.
  52150. */
  52151. enable(): void;
  52152. /**
  52153. * Disables the gravitational field.
  52154. */
  52155. disable(): void;
  52156. /**
  52157. * Disposes the sphere.
  52158. * @param force The force to dispose from the gravitational field event
  52159. */
  52160. dispose(force?: boolean): void;
  52161. private _tick;
  52162. }
  52163. /**
  52164. * Represents a physics updraft event
  52165. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52166. */
  52167. export class PhysicsUpdraftEvent {
  52168. private _scene;
  52169. private _origin;
  52170. private _radius;
  52171. private _strength;
  52172. private _height;
  52173. private _updraftMode;
  52174. private _physicsEngine;
  52175. private _originTop;
  52176. private _originDirection;
  52177. private _tickCallback;
  52178. private _cylinder;
  52179. private _cylinderPosition;
  52180. private _dataFetched;
  52181. /**
  52182. * Initializes the physics updraft event
  52183. * @param _scene BabylonJS scene
  52184. * @param _origin The origin position of the updraft
  52185. * @param _radius The radius of the updraft
  52186. * @param _strength The strength of the updraft
  52187. * @param _height The height of the updraft
  52188. * @param _updraftMode The mode of the updraft
  52189. */
  52190. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number, _updraftMode: PhysicsUpdraftMode);
  52191. /**
  52192. * Returns the data related to the updraft event (cylinder).
  52193. * @returns A physics updraft event
  52194. */
  52195. getData(): PhysicsUpdraftEventData;
  52196. /**
  52197. * Enables the updraft.
  52198. */
  52199. enable(): void;
  52200. /**
  52201. * Disables the cortex.
  52202. */
  52203. disable(): void;
  52204. /**
  52205. * Disposes the sphere.
  52206. * @param force Specifies if the updraft should be disposed by force
  52207. */
  52208. dispose(force?: boolean): void;
  52209. private getImpostorForceAndContactPoint;
  52210. private _tick;
  52211. /*** Helpers ***/
  52212. private _prepareCylinder;
  52213. private _intersectsWithCylinder;
  52214. }
  52215. /**
  52216. * Represents a physics vortex event
  52217. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52218. */
  52219. export class PhysicsVortexEvent {
  52220. private _scene;
  52221. private _origin;
  52222. private _radius;
  52223. private _strength;
  52224. private _height;
  52225. private _physicsEngine;
  52226. private _originTop;
  52227. private _centripetalForceThreshold;
  52228. private _updraftMultiplier;
  52229. private _tickCallback;
  52230. private _cylinder;
  52231. private _cylinderPosition;
  52232. private _dataFetched;
  52233. /**
  52234. * Initializes the physics vortex event
  52235. * @param _scene The BabylonJS scene
  52236. * @param _origin The origin position of the vortex
  52237. * @param _radius The radius of the vortex
  52238. * @param _strength The strength of the vortex
  52239. * @param _height The height of the vortex
  52240. */
  52241. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number);
  52242. /**
  52243. * Returns the data related to the vortex event (cylinder).
  52244. * @returns The physics vortex event data
  52245. */
  52246. getData(): PhysicsVortexEventData;
  52247. /**
  52248. * Enables the vortex.
  52249. */
  52250. enable(): void;
  52251. /**
  52252. * Disables the cortex.
  52253. */
  52254. disable(): void;
  52255. /**
  52256. * Disposes the sphere.
  52257. * @param force
  52258. */
  52259. dispose(force?: boolean): void;
  52260. private getImpostorForceAndContactPoint;
  52261. private _tick;
  52262. /*** Helpers ***/
  52263. private _prepareCylinder;
  52264. private _intersectsWithCylinder;
  52265. }
  52266. /**
  52267. * The strenght of the force in correspondence to the distance of the affected object
  52268. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52269. */
  52270. export enum PhysicsRadialImpulseFalloff {
  52271. /** Defines that impulse is constant in strength across it's whole radius */
  52272. Constant = 0,
  52273. /** DEfines that impulse gets weaker if it's further from the origin */
  52274. Linear = 1
  52275. }
  52276. /**
  52277. * The strength of the force in correspondence to the distance of the affected object
  52278. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52279. */
  52280. export enum PhysicsUpdraftMode {
  52281. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  52282. Center = 0,
  52283. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  52284. Perpendicular = 1
  52285. }
  52286. /**
  52287. * Interface for a physics force and contact point
  52288. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52289. */
  52290. export interface PhysicsForceAndContactPoint {
  52291. /**
  52292. * The force applied at the contact point
  52293. */
  52294. force: Vector3;
  52295. /**
  52296. * The contact point
  52297. */
  52298. contactPoint: Vector3;
  52299. }
  52300. /**
  52301. * Interface for radial explosion event data
  52302. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52303. */
  52304. export interface PhysicsRadialExplosionEventData {
  52305. /**
  52306. * A sphere used for the radial explosion event
  52307. */
  52308. sphere: Mesh;
  52309. /**
  52310. * An array of rays for the radial explosion event
  52311. */
  52312. rays: Array<Ray>;
  52313. }
  52314. /**
  52315. * Interface for gravitational field event data
  52316. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52317. */
  52318. export interface PhysicsGravitationalFieldEventData {
  52319. /**
  52320. * A sphere mesh used for the gravitational field event
  52321. */
  52322. sphere: Mesh;
  52323. }
  52324. /**
  52325. * Interface for updraft event data
  52326. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52327. */
  52328. export interface PhysicsUpdraftEventData {
  52329. /**
  52330. * A cylinder used for the updraft event
  52331. */
  52332. cylinder: Mesh;
  52333. }
  52334. /**
  52335. * Interface for vortex event data
  52336. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52337. */
  52338. export interface PhysicsVortexEventData {
  52339. /**
  52340. * A cylinder used for the vortex event
  52341. */
  52342. cylinder: Mesh;
  52343. }
  52344. }
  52345. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  52346. import { Quaternion, Vector3 } from "babylonjs/Maths/math";
  52347. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  52348. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  52349. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  52350. import { Nullable } from "babylonjs/types";
  52351. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52352. /**
  52353. * AmmoJS Physics plugin
  52354. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52355. * @see https://github.com/kripken/ammo.js/
  52356. */
  52357. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  52358. private _useDeltaForWorldStep;
  52359. /**
  52360. * Reference to the Ammo library
  52361. */
  52362. bjsAMMO: any;
  52363. /**
  52364. * Created ammoJS world which physics bodies are added to
  52365. */
  52366. world: any;
  52367. /**
  52368. * Name of the plugin
  52369. */
  52370. name: string;
  52371. private _timeStep;
  52372. private _fixedTimeStep;
  52373. private _maxSteps;
  52374. private _tmpQuaternion;
  52375. private _tmpAmmoTransform;
  52376. private _tmpAmmoQuaternion;
  52377. private _tmpAmmoConcreteContactResultCallback;
  52378. private _collisionConfiguration;
  52379. private _dispatcher;
  52380. private _overlappingPairCache;
  52381. private _solver;
  52382. private _tmpAmmoVectorA;
  52383. private _tmpAmmoVectorB;
  52384. private _tmpAmmoVectorC;
  52385. private _tmpContactCallbackResult;
  52386. private static readonly DISABLE_COLLISION_FLAG;
  52387. private static readonly KINEMATIC_FLAG;
  52388. private static readonly DISABLE_DEACTIVATION_FLAG;
  52389. /**
  52390. * Initializes the ammoJS plugin
  52391. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  52392. * @param ammoInjection can be used to inject your own ammo reference
  52393. */
  52394. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any);
  52395. /**
  52396. * Sets the gravity of the physics world (m/(s^2))
  52397. * @param gravity Gravity to set
  52398. */
  52399. setGravity(gravity: Vector3): void;
  52400. /**
  52401. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  52402. * @param timeStep timestep to use in seconds
  52403. */
  52404. setTimeStep(timeStep: number): void;
  52405. /**
  52406. * 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)
  52407. * @param fixedTimeStep fixedTimeStep to use in seconds
  52408. */
  52409. setFixedTimeStep(fixedTimeStep: number): void;
  52410. /**
  52411. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  52412. * @param maxSteps the maximum number of steps by the physics engine per frame
  52413. */
  52414. setMaxSteps(maxSteps: number): void;
  52415. /**
  52416. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  52417. * @returns the current timestep in seconds
  52418. */
  52419. getTimeStep(): number;
  52420. private _isImpostorInContact;
  52421. private _isImpostorPairInContact;
  52422. private _stepSimulation;
  52423. /**
  52424. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  52425. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  52426. * After the step the babylon meshes are set to the position of the physics imposters
  52427. * @param delta amount of time to step forward
  52428. * @param impostors array of imposters to update before/after the step
  52429. */
  52430. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  52431. private _tmpVector;
  52432. private _tmpMatrix;
  52433. /**
  52434. * Applies an implulse on the imposter
  52435. * @param impostor imposter to apply impulse
  52436. * @param force amount of force to be applied to the imposter
  52437. * @param contactPoint the location to apply the impulse on the imposter
  52438. */
  52439. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52440. /**
  52441. * Applies a force on the imposter
  52442. * @param impostor imposter to apply force
  52443. * @param force amount of force to be applied to the imposter
  52444. * @param contactPoint the location to apply the force on the imposter
  52445. */
  52446. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52447. /**
  52448. * Creates a physics body using the plugin
  52449. * @param impostor the imposter to create the physics body on
  52450. */
  52451. generatePhysicsBody(impostor: PhysicsImpostor): void;
  52452. /**
  52453. * Removes the physics body from the imposter and disposes of the body's memory
  52454. * @param impostor imposter to remove the physics body from
  52455. */
  52456. removePhysicsBody(impostor: PhysicsImpostor): void;
  52457. /**
  52458. * Generates a joint
  52459. * @param impostorJoint the imposter joint to create the joint with
  52460. */
  52461. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  52462. /**
  52463. * Removes a joint
  52464. * @param impostorJoint the imposter joint to remove the joint from
  52465. */
  52466. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  52467. private _addMeshVerts;
  52468. private _createShape;
  52469. /**
  52470. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  52471. * @param impostor imposter containing the physics body and babylon object
  52472. */
  52473. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  52474. /**
  52475. * Sets the babylon object's position/rotation from the physics body's position/rotation
  52476. * @param impostor imposter containing the physics body and babylon object
  52477. * @param newPosition new position
  52478. * @param newRotation new rotation
  52479. */
  52480. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  52481. /**
  52482. * If this plugin is supported
  52483. * @returns true if its supported
  52484. */
  52485. isSupported(): boolean;
  52486. /**
  52487. * Sets the linear velocity of the physics body
  52488. * @param impostor imposter to set the velocity on
  52489. * @param velocity velocity to set
  52490. */
  52491. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52492. /**
  52493. * Sets the angular velocity of the physics body
  52494. * @param impostor imposter to set the velocity on
  52495. * @param velocity velocity to set
  52496. */
  52497. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52498. /**
  52499. * gets the linear velocity
  52500. * @param impostor imposter to get linear velocity from
  52501. * @returns linear velocity
  52502. */
  52503. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52504. /**
  52505. * gets the angular velocity
  52506. * @param impostor imposter to get angular velocity from
  52507. * @returns angular velocity
  52508. */
  52509. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52510. /**
  52511. * Sets the mass of physics body
  52512. * @param impostor imposter to set the mass on
  52513. * @param mass mass to set
  52514. */
  52515. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  52516. /**
  52517. * Gets the mass of the physics body
  52518. * @param impostor imposter to get the mass from
  52519. * @returns mass
  52520. */
  52521. getBodyMass(impostor: PhysicsImpostor): number;
  52522. /**
  52523. * Gets friction of the impostor
  52524. * @param impostor impostor to get friction from
  52525. * @returns friction value
  52526. */
  52527. getBodyFriction(impostor: PhysicsImpostor): number;
  52528. /**
  52529. * Sets friction of the impostor
  52530. * @param impostor impostor to set friction on
  52531. * @param friction friction value
  52532. */
  52533. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  52534. /**
  52535. * Gets restitution of the impostor
  52536. * @param impostor impostor to get restitution from
  52537. * @returns restitution value
  52538. */
  52539. getBodyRestitution(impostor: PhysicsImpostor): number;
  52540. /**
  52541. * Sets resitution of the impostor
  52542. * @param impostor impostor to set resitution on
  52543. * @param restitution resitution value
  52544. */
  52545. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  52546. /**
  52547. * Sleeps the physics body and stops it from being active
  52548. * @param impostor impostor to sleep
  52549. */
  52550. sleepBody(impostor: PhysicsImpostor): void;
  52551. /**
  52552. * Activates the physics body
  52553. * @param impostor impostor to activate
  52554. */
  52555. wakeUpBody(impostor: PhysicsImpostor): void;
  52556. /**
  52557. * Updates the distance parameters of the joint
  52558. * @param joint joint to update
  52559. * @param maxDistance maximum distance of the joint
  52560. * @param minDistance minimum distance of the joint
  52561. */
  52562. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  52563. /**
  52564. * Sets a motor on the joint
  52565. * @param joint joint to set motor on
  52566. * @param speed speed of the motor
  52567. * @param maxForce maximum force of the motor
  52568. * @param motorIndex index of the motor
  52569. */
  52570. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  52571. /**
  52572. * Sets the motors limit
  52573. * @param joint joint to set limit on
  52574. * @param upperLimit upper limit
  52575. * @param lowerLimit lower limit
  52576. */
  52577. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  52578. /**
  52579. * Syncs the position and rotation of a mesh with the impostor
  52580. * @param mesh mesh to sync
  52581. * @param impostor impostor to update the mesh with
  52582. */
  52583. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  52584. /**
  52585. * Gets the radius of the impostor
  52586. * @param impostor impostor to get radius from
  52587. * @returns the radius
  52588. */
  52589. getRadius(impostor: PhysicsImpostor): number;
  52590. /**
  52591. * Gets the box size of the impostor
  52592. * @param impostor impostor to get box size from
  52593. * @param result the resulting box size
  52594. */
  52595. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  52596. /**
  52597. * Disposes of the impostor
  52598. */
  52599. dispose(): void;
  52600. }
  52601. }
  52602. declare module "babylonjs/Physics/Plugins/index" {
  52603. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  52604. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  52605. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  52606. }
  52607. declare module "babylonjs/Physics/index" {
  52608. export * from "babylonjs/Physics/IPhysicsEngine";
  52609. export * from "babylonjs/Physics/physicsEngine";
  52610. export * from "babylonjs/Physics/physicsEngineComponent";
  52611. export * from "babylonjs/Physics/physicsHelper";
  52612. export * from "babylonjs/Physics/physicsImpostor";
  52613. export * from "babylonjs/Physics/physicsJoint";
  52614. export * from "babylonjs/Physics/Plugins/index";
  52615. }
  52616. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  52617. /** @hidden */
  52618. export var blackAndWhitePixelShader: {
  52619. name: string;
  52620. shader: string;
  52621. };
  52622. }
  52623. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  52624. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52625. import { Camera } from "babylonjs/Cameras/camera";
  52626. import { Engine } from "babylonjs/Engines/engine";
  52627. import "babylonjs/Shaders/blackAndWhite.fragment";
  52628. /**
  52629. * Post process used to render in black and white
  52630. */
  52631. export class BlackAndWhitePostProcess extends PostProcess {
  52632. /**
  52633. * Linear about to convert he result to black and white (default: 1)
  52634. */
  52635. degree: number;
  52636. /**
  52637. * Creates a black and white post process
  52638. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  52639. * @param name The name of the effect.
  52640. * @param options The required width/height ratio to downsize to before computing the render pass.
  52641. * @param camera The camera to apply the render pass to.
  52642. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52643. * @param engine The engine which the post process will be applied. (default: current engine)
  52644. * @param reusable If the post process can be reused on the same frame. (default: false)
  52645. */
  52646. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  52647. }
  52648. }
  52649. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  52650. import { Nullable } from "babylonjs/types";
  52651. import { Camera } from "babylonjs/Cameras/camera";
  52652. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  52653. import { Engine } from "babylonjs/Engines/engine";
  52654. /**
  52655. * This represents a set of one or more post processes in Babylon.
  52656. * A post process can be used to apply a shader to a texture after it is rendered.
  52657. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  52658. */
  52659. export class PostProcessRenderEffect {
  52660. private _postProcesses;
  52661. private _getPostProcesses;
  52662. private _singleInstance;
  52663. private _cameras;
  52664. private _indicesForCamera;
  52665. /**
  52666. * Name of the effect
  52667. * @hidden
  52668. */
  52669. _name: string;
  52670. /**
  52671. * Instantiates a post process render effect.
  52672. * A post process can be used to apply a shader to a texture after it is rendered.
  52673. * @param engine The engine the effect is tied to
  52674. * @param name The name of the effect
  52675. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  52676. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  52677. */
  52678. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  52679. /**
  52680. * Checks if all the post processes in the effect are supported.
  52681. */
  52682. readonly isSupported: boolean;
  52683. /**
  52684. * Updates the current state of the effect
  52685. * @hidden
  52686. */
  52687. _update(): void;
  52688. /**
  52689. * Attaches the effect on cameras
  52690. * @param cameras The camera to attach to.
  52691. * @hidden
  52692. */
  52693. _attachCameras(cameras: Camera): void;
  52694. /**
  52695. * Attaches the effect on cameras
  52696. * @param cameras The camera to attach to.
  52697. * @hidden
  52698. */
  52699. _attachCameras(cameras: Camera[]): void;
  52700. /**
  52701. * Detatches the effect on cameras
  52702. * @param cameras The camera to detatch from.
  52703. * @hidden
  52704. */
  52705. _detachCameras(cameras: Camera): void;
  52706. /**
  52707. * Detatches the effect on cameras
  52708. * @param cameras The camera to detatch from.
  52709. * @hidden
  52710. */
  52711. _detachCameras(cameras: Camera[]): void;
  52712. /**
  52713. * Enables the effect on given cameras
  52714. * @param cameras The camera to enable.
  52715. * @hidden
  52716. */
  52717. _enable(cameras: Camera): void;
  52718. /**
  52719. * Enables the effect on given cameras
  52720. * @param cameras The camera to enable.
  52721. * @hidden
  52722. */
  52723. _enable(cameras: Nullable<Camera[]>): void;
  52724. /**
  52725. * Disables the effect on the given cameras
  52726. * @param cameras The camera to disable.
  52727. * @hidden
  52728. */
  52729. _disable(cameras: Camera): void;
  52730. /**
  52731. * Disables the effect on the given cameras
  52732. * @param cameras The camera to disable.
  52733. * @hidden
  52734. */
  52735. _disable(cameras: Nullable<Camera[]>): void;
  52736. /**
  52737. * Gets a list of the post processes contained in the effect.
  52738. * @param camera The camera to get the post processes on.
  52739. * @returns The list of the post processes in the effect.
  52740. */
  52741. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  52742. }
  52743. }
  52744. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  52745. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  52746. /** @hidden */
  52747. export var extractHighlightsPixelShader: {
  52748. name: string;
  52749. shader: string;
  52750. };
  52751. }
  52752. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  52753. import { Nullable } from "babylonjs/types";
  52754. import { Camera } from "babylonjs/Cameras/camera";
  52755. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52756. import { Engine } from "babylonjs/Engines/engine";
  52757. import "babylonjs/Shaders/extractHighlights.fragment";
  52758. /**
  52759. * 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.
  52760. */
  52761. export class ExtractHighlightsPostProcess extends PostProcess {
  52762. /**
  52763. * The luminance threshold, pixels below this value will be set to black.
  52764. */
  52765. threshold: number;
  52766. /** @hidden */
  52767. _exposure: number;
  52768. /**
  52769. * Post process which has the input texture to be used when performing highlight extraction
  52770. * @hidden
  52771. */
  52772. _inputPostProcess: Nullable<PostProcess>;
  52773. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52774. }
  52775. }
  52776. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  52777. /** @hidden */
  52778. export var bloomMergePixelShader: {
  52779. name: string;
  52780. shader: string;
  52781. };
  52782. }
  52783. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  52784. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52785. import { Nullable } from "babylonjs/types";
  52786. import { Engine } from "babylonjs/Engines/engine";
  52787. import { Camera } from "babylonjs/Cameras/camera";
  52788. import "babylonjs/Shaders/bloomMerge.fragment";
  52789. /**
  52790. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  52791. */
  52792. export class BloomMergePostProcess extends PostProcess {
  52793. /** Weight of the bloom to be added to the original input. */
  52794. weight: number;
  52795. /**
  52796. * Creates a new instance of @see BloomMergePostProcess
  52797. * @param name The name of the effect.
  52798. * @param originalFromInput Post process which's input will be used for the merge.
  52799. * @param blurred Blurred highlights post process which's output will be used.
  52800. * @param weight Weight of the bloom to be added to the original input.
  52801. * @param options The required width/height ratio to downsize to before computing the render pass.
  52802. * @param camera The camera to apply the render pass to.
  52803. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52804. * @param engine The engine which the post process will be applied. (default: current engine)
  52805. * @param reusable If the post process can be reused on the same frame. (default: false)
  52806. * @param textureType Type of textures used when performing the post process. (default: 0)
  52807. * @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)
  52808. */
  52809. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  52810. /** Weight of the bloom to be added to the original input. */
  52811. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52812. }
  52813. }
  52814. declare module "babylonjs/PostProcesses/bloomEffect" {
  52815. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  52816. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  52817. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  52818. import { Camera } from "babylonjs/Cameras/camera";
  52819. import { Scene } from "babylonjs/scene";
  52820. /**
  52821. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  52822. */
  52823. export class BloomEffect extends PostProcessRenderEffect {
  52824. private bloomScale;
  52825. /**
  52826. * @hidden Internal
  52827. */
  52828. _effects: Array<PostProcess>;
  52829. /**
  52830. * @hidden Internal
  52831. */
  52832. _downscale: ExtractHighlightsPostProcess;
  52833. private _blurX;
  52834. private _blurY;
  52835. private _merge;
  52836. /**
  52837. * The luminance threshold to find bright areas of the image to bloom.
  52838. */
  52839. threshold: number;
  52840. /**
  52841. * The strength of the bloom.
  52842. */
  52843. weight: number;
  52844. /**
  52845. * Specifies the size of the bloom blur kernel, relative to the final output size
  52846. */
  52847. kernel: number;
  52848. /**
  52849. * Creates a new instance of @see BloomEffect
  52850. * @param scene The scene the effect belongs to.
  52851. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  52852. * @param bloomKernel The size of the kernel to be used when applying the blur.
  52853. * @param bloomWeight The the strength of bloom.
  52854. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  52855. * @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)
  52856. */
  52857. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  52858. /**
  52859. * Disposes each of the internal effects for a given camera.
  52860. * @param camera The camera to dispose the effect on.
  52861. */
  52862. disposeEffects(camera: Camera): void;
  52863. /**
  52864. * @hidden Internal
  52865. */
  52866. _updateEffects(): void;
  52867. /**
  52868. * Internal
  52869. * @returns if all the contained post processes are ready.
  52870. * @hidden
  52871. */
  52872. _isReady(): boolean;
  52873. }
  52874. }
  52875. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  52876. /** @hidden */
  52877. export var chromaticAberrationPixelShader: {
  52878. name: string;
  52879. shader: string;
  52880. };
  52881. }
  52882. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  52883. import { Vector2 } from "babylonjs/Maths/math";
  52884. import { Nullable } from "babylonjs/types";
  52885. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52886. import { Camera } from "babylonjs/Cameras/camera";
  52887. import { Engine } from "babylonjs/Engines/engine";
  52888. import "babylonjs/Shaders/chromaticAberration.fragment";
  52889. /**
  52890. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  52891. */
  52892. export class ChromaticAberrationPostProcess extends PostProcess {
  52893. /**
  52894. * The amount of seperation of rgb channels (default: 30)
  52895. */
  52896. aberrationAmount: number;
  52897. /**
  52898. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  52899. */
  52900. radialIntensity: number;
  52901. /**
  52902. * 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))
  52903. */
  52904. direction: Vector2;
  52905. /**
  52906. * 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))
  52907. */
  52908. centerPosition: Vector2;
  52909. /**
  52910. * Creates a new instance ChromaticAberrationPostProcess
  52911. * @param name The name of the effect.
  52912. * @param screenWidth The width of the screen to apply the effect on.
  52913. * @param screenHeight The height of the screen to apply the effect on.
  52914. * @param options The required width/height ratio to downsize to before computing the render pass.
  52915. * @param camera The camera to apply the render pass to.
  52916. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52917. * @param engine The engine which the post process will be applied. (default: current engine)
  52918. * @param reusable If the post process can be reused on the same frame. (default: false)
  52919. * @param textureType Type of textures used when performing the post process. (default: 0)
  52920. * @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)
  52921. */
  52922. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52923. }
  52924. }
  52925. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  52926. /** @hidden */
  52927. export var circleOfConfusionPixelShader: {
  52928. name: string;
  52929. shader: string;
  52930. };
  52931. }
  52932. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  52933. import { Nullable } from "babylonjs/types";
  52934. import { Engine } from "babylonjs/Engines/engine";
  52935. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52936. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  52937. import { Camera } from "babylonjs/Cameras/camera";
  52938. import "babylonjs/Shaders/circleOfConfusion.fragment";
  52939. /**
  52940. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  52941. */
  52942. export class CircleOfConfusionPostProcess extends PostProcess {
  52943. /**
  52944. * 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.
  52945. */
  52946. lensSize: number;
  52947. /**
  52948. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  52949. */
  52950. fStop: number;
  52951. /**
  52952. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  52953. */
  52954. focusDistance: number;
  52955. /**
  52956. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  52957. */
  52958. focalLength: number;
  52959. private _depthTexture;
  52960. /**
  52961. * Creates a new instance CircleOfConfusionPostProcess
  52962. * @param name The name of the effect.
  52963. * @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.
  52964. * @param options The required width/height ratio to downsize to before computing the render pass.
  52965. * @param camera The camera to apply the render pass to.
  52966. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52967. * @param engine The engine which the post process will be applied. (default: current engine)
  52968. * @param reusable If the post process can be reused on the same frame. (default: false)
  52969. * @param textureType Type of textures used when performing the post process. (default: 0)
  52970. * @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)
  52971. */
  52972. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52973. /**
  52974. * 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.
  52975. */
  52976. depthTexture: RenderTargetTexture;
  52977. }
  52978. }
  52979. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  52980. /** @hidden */
  52981. export var colorCorrectionPixelShader: {
  52982. name: string;
  52983. shader: string;
  52984. };
  52985. }
  52986. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  52987. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52988. import { Engine } from "babylonjs/Engines/engine";
  52989. import { Camera } from "babylonjs/Cameras/camera";
  52990. import "babylonjs/Shaders/colorCorrection.fragment";
  52991. /**
  52992. *
  52993. * This post-process allows the modification of rendered colors by using
  52994. * a 'look-up table' (LUT). This effect is also called Color Grading.
  52995. *
  52996. * The object needs to be provided an url to a texture containing the color
  52997. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  52998. * Use an image editing software to tweak the LUT to match your needs.
  52999. *
  53000. * For an example of a color LUT, see here:
  53001. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  53002. * For explanations on color grading, see here:
  53003. * @see http://udn.epicgames.com/Three/ColorGrading.html
  53004. *
  53005. */
  53006. export class ColorCorrectionPostProcess extends PostProcess {
  53007. private _colorTableTexture;
  53008. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  53009. }
  53010. }
  53011. declare module "babylonjs/Shaders/convolution.fragment" {
  53012. /** @hidden */
  53013. export var convolutionPixelShader: {
  53014. name: string;
  53015. shader: string;
  53016. };
  53017. }
  53018. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  53019. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53020. import { Nullable } from "babylonjs/types";
  53021. import { Camera } from "babylonjs/Cameras/camera";
  53022. import { Engine } from "babylonjs/Engines/engine";
  53023. import "babylonjs/Shaders/convolution.fragment";
  53024. /**
  53025. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  53026. * input texture to perform effects such as edge detection or sharpening
  53027. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  53028. */
  53029. export class ConvolutionPostProcess extends PostProcess {
  53030. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  53031. kernel: number[];
  53032. /**
  53033. * Creates a new instance ConvolutionPostProcess
  53034. * @param name The name of the effect.
  53035. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  53036. * @param options The required width/height ratio to downsize to before computing the render pass.
  53037. * @param camera The camera to apply the render pass to.
  53038. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53039. * @param engine The engine which the post process will be applied. (default: current engine)
  53040. * @param reusable If the post process can be reused on the same frame. (default: false)
  53041. * @param textureType Type of textures used when performing the post process. (default: 0)
  53042. */
  53043. constructor(name: string,
  53044. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  53045. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  53046. /**
  53047. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  53048. */
  53049. static EdgeDetect0Kernel: number[];
  53050. /**
  53051. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  53052. */
  53053. static EdgeDetect1Kernel: number[];
  53054. /**
  53055. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  53056. */
  53057. static EdgeDetect2Kernel: number[];
  53058. /**
  53059. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  53060. */
  53061. static SharpenKernel: number[];
  53062. /**
  53063. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  53064. */
  53065. static EmbossKernel: number[];
  53066. /**
  53067. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  53068. */
  53069. static GaussianKernel: number[];
  53070. }
  53071. }
  53072. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  53073. import { Nullable } from "babylonjs/types";
  53074. import { Vector2 } from "babylonjs/Maths/math";
  53075. import { Camera } from "babylonjs/Cameras/camera";
  53076. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53077. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  53078. import { Engine } from "babylonjs/Engines/engine";
  53079. import { Scene } from "babylonjs/scene";
  53080. /**
  53081. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  53082. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  53083. * based on samples that have a large difference in distance than the center pixel.
  53084. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  53085. */
  53086. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  53087. direction: Vector2;
  53088. /**
  53089. * Creates a new instance CircleOfConfusionPostProcess
  53090. * @param name The name of the effect.
  53091. * @param scene The scene the effect belongs to.
  53092. * @param direction The direction the blur should be applied.
  53093. * @param kernel The size of the kernel used to blur.
  53094. * @param options The required width/height ratio to downsize to before computing the render pass.
  53095. * @param camera The camera to apply the render pass to.
  53096. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  53097. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  53098. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53099. * @param engine The engine which the post process will be applied. (default: current engine)
  53100. * @param reusable If the post process can be reused on the same frame. (default: false)
  53101. * @param textureType Type of textures used when performing the post process. (default: 0)
  53102. * @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)
  53103. */
  53104. 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);
  53105. }
  53106. }
  53107. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  53108. /** @hidden */
  53109. export var depthOfFieldMergePixelShader: {
  53110. name: string;
  53111. shader: string;
  53112. };
  53113. }
  53114. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  53115. import { Nullable } from "babylonjs/types";
  53116. import { Camera } from "babylonjs/Cameras/camera";
  53117. import { Effect } from "babylonjs/Materials/effect";
  53118. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53119. import { Engine } from "babylonjs/Engines/engine";
  53120. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  53121. /**
  53122. * Options to be set when merging outputs from the default pipeline.
  53123. */
  53124. export class DepthOfFieldMergePostProcessOptions {
  53125. /**
  53126. * The original image to merge on top of
  53127. */
  53128. originalFromInput: PostProcess;
  53129. /**
  53130. * Parameters to perform the merge of the depth of field effect
  53131. */
  53132. depthOfField?: {
  53133. circleOfConfusion: PostProcess;
  53134. blurSteps: Array<PostProcess>;
  53135. };
  53136. /**
  53137. * Parameters to perform the merge of bloom effect
  53138. */
  53139. bloom?: {
  53140. blurred: PostProcess;
  53141. weight: number;
  53142. };
  53143. }
  53144. /**
  53145. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  53146. */
  53147. export class DepthOfFieldMergePostProcess extends PostProcess {
  53148. private blurSteps;
  53149. /**
  53150. * Creates a new instance of DepthOfFieldMergePostProcess
  53151. * @param name The name of the effect.
  53152. * @param originalFromInput Post process which's input will be used for the merge.
  53153. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  53154. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  53155. * @param options The required width/height ratio to downsize to before computing the render pass.
  53156. * @param camera The camera to apply the render pass to.
  53157. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53158. * @param engine The engine which the post process will be applied. (default: current engine)
  53159. * @param reusable If the post process can be reused on the same frame. (default: false)
  53160. * @param textureType Type of textures used when performing the post process. (default: 0)
  53161. * @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)
  53162. */
  53163. 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);
  53164. /**
  53165. * Updates the effect with the current post process compile time values and recompiles the shader.
  53166. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  53167. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  53168. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  53169. * @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
  53170. * @param onCompiled Called when the shader has been compiled.
  53171. * @param onError Called if there is an error when compiling a shader.
  53172. */
  53173. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  53174. }
  53175. }
  53176. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  53177. import { Nullable } from "babylonjs/types";
  53178. import { Camera } from "babylonjs/Cameras/camera";
  53179. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  53180. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  53181. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  53182. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  53183. import { Scene } from "babylonjs/scene";
  53184. /**
  53185. * Specifies the level of max blur that should be applied when using the depth of field effect
  53186. */
  53187. export enum DepthOfFieldEffectBlurLevel {
  53188. /**
  53189. * Subtle blur
  53190. */
  53191. Low = 0,
  53192. /**
  53193. * Medium blur
  53194. */
  53195. Medium = 1,
  53196. /**
  53197. * Large blur
  53198. */
  53199. High = 2
  53200. }
  53201. /**
  53202. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  53203. */
  53204. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  53205. private _circleOfConfusion;
  53206. /**
  53207. * @hidden Internal, blurs from high to low
  53208. */
  53209. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  53210. private _depthOfFieldBlurY;
  53211. private _dofMerge;
  53212. /**
  53213. * @hidden Internal post processes in depth of field effect
  53214. */
  53215. _effects: Array<PostProcess>;
  53216. /**
  53217. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  53218. */
  53219. focalLength: number;
  53220. /**
  53221. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  53222. */
  53223. fStop: number;
  53224. /**
  53225. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  53226. */
  53227. focusDistance: number;
  53228. /**
  53229. * 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.
  53230. */
  53231. lensSize: number;
  53232. /**
  53233. * Creates a new instance DepthOfFieldEffect
  53234. * @param scene The scene the effect belongs to.
  53235. * @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.
  53236. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  53237. * @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)
  53238. */
  53239. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  53240. /**
  53241. * 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.
  53242. */
  53243. depthTexture: RenderTargetTexture;
  53244. /**
  53245. * Disposes each of the internal effects for a given camera.
  53246. * @param camera The camera to dispose the effect on.
  53247. */
  53248. disposeEffects(camera: Camera): void;
  53249. /**
  53250. * @hidden Internal
  53251. */
  53252. _updateEffects(): void;
  53253. /**
  53254. * Internal
  53255. * @returns if all the contained post processes are ready.
  53256. * @hidden
  53257. */
  53258. _isReady(): boolean;
  53259. }
  53260. }
  53261. declare module "babylonjs/Shaders/displayPass.fragment" {
  53262. /** @hidden */
  53263. export var displayPassPixelShader: {
  53264. name: string;
  53265. shader: string;
  53266. };
  53267. }
  53268. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  53269. import { Nullable } from "babylonjs/types";
  53270. import { Camera } from "babylonjs/Cameras/camera";
  53271. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53272. import { Engine } from "babylonjs/Engines/engine";
  53273. import "babylonjs/Shaders/displayPass.fragment";
  53274. /**
  53275. * DisplayPassPostProcess which produces an output the same as it's input
  53276. */
  53277. export class DisplayPassPostProcess extends PostProcess {
  53278. /**
  53279. * Creates the DisplayPassPostProcess
  53280. * @param name The name of the effect.
  53281. * @param options The required width/height ratio to downsize to before computing the render pass.
  53282. * @param camera The camera to apply the render pass to.
  53283. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53284. * @param engine The engine which the post process will be applied. (default: current engine)
  53285. * @param reusable If the post process can be reused on the same frame. (default: false)
  53286. */
  53287. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  53288. }
  53289. }
  53290. declare module "babylonjs/Shaders/filter.fragment" {
  53291. /** @hidden */
  53292. export var filterPixelShader: {
  53293. name: string;
  53294. shader: string;
  53295. };
  53296. }
  53297. declare module "babylonjs/PostProcesses/filterPostProcess" {
  53298. import { Nullable } from "babylonjs/types";
  53299. import { Matrix } from "babylonjs/Maths/math";
  53300. import { Camera } from "babylonjs/Cameras/camera";
  53301. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53302. import { Engine } from "babylonjs/Engines/engine";
  53303. import "babylonjs/Shaders/filter.fragment";
  53304. /**
  53305. * Applies a kernel filter to the image
  53306. */
  53307. export class FilterPostProcess extends PostProcess {
  53308. /** The matrix to be applied to the image */
  53309. kernelMatrix: Matrix;
  53310. /**
  53311. *
  53312. * @param name The name of the effect.
  53313. * @param kernelMatrix The matrix to be applied to the image
  53314. * @param options The required width/height ratio to downsize to before computing the render pass.
  53315. * @param camera The camera to apply the render pass to.
  53316. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53317. * @param engine The engine which the post process will be applied. (default: current engine)
  53318. * @param reusable If the post process can be reused on the same frame. (default: false)
  53319. */
  53320. constructor(name: string,
  53321. /** The matrix to be applied to the image */
  53322. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  53323. }
  53324. }
  53325. declare module "babylonjs/Shaders/fxaa.fragment" {
  53326. /** @hidden */
  53327. export var fxaaPixelShader: {
  53328. name: string;
  53329. shader: string;
  53330. };
  53331. }
  53332. declare module "babylonjs/Shaders/fxaa.vertex" {
  53333. /** @hidden */
  53334. export var fxaaVertexShader: {
  53335. name: string;
  53336. shader: string;
  53337. };
  53338. }
  53339. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  53340. import { Nullable } from "babylonjs/types";
  53341. import { Camera } from "babylonjs/Cameras/camera";
  53342. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53343. import { Engine } from "babylonjs/Engines/engine";
  53344. import "babylonjs/Shaders/fxaa.fragment";
  53345. import "babylonjs/Shaders/fxaa.vertex";
  53346. /**
  53347. * Fxaa post process
  53348. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  53349. */
  53350. export class FxaaPostProcess extends PostProcess {
  53351. /** @hidden */
  53352. texelWidth: number;
  53353. /** @hidden */
  53354. texelHeight: number;
  53355. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  53356. private _getDefines;
  53357. }
  53358. }
  53359. declare module "babylonjs/Shaders/grain.fragment" {
  53360. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  53361. /** @hidden */
  53362. export var grainPixelShader: {
  53363. name: string;
  53364. shader: string;
  53365. };
  53366. }
  53367. declare module "babylonjs/PostProcesses/grainPostProcess" {
  53368. import { Nullable } from "babylonjs/types";
  53369. import { Camera } from "babylonjs/Cameras/camera";
  53370. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53371. import { Engine } from "babylonjs/Engines/engine";
  53372. import "babylonjs/Shaders/grain.fragment";
  53373. /**
  53374. * The GrainPostProcess adds noise to the image at mid luminance levels
  53375. */
  53376. export class GrainPostProcess extends PostProcess {
  53377. /**
  53378. * The intensity of the grain added (default: 30)
  53379. */
  53380. intensity: number;
  53381. /**
  53382. * If the grain should be randomized on every frame
  53383. */
  53384. animated: boolean;
  53385. /**
  53386. * Creates a new instance of @see GrainPostProcess
  53387. * @param name The name of the effect.
  53388. * @param options The required width/height ratio to downsize to before computing the render pass.
  53389. * @param camera The camera to apply the render pass to.
  53390. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53391. * @param engine The engine which the post process will be applied. (default: current engine)
  53392. * @param reusable If the post process can be reused on the same frame. (default: false)
  53393. * @param textureType Type of textures used when performing the post process. (default: 0)
  53394. * @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)
  53395. */
  53396. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  53397. }
  53398. }
  53399. declare module "babylonjs/Shaders/highlights.fragment" {
  53400. /** @hidden */
  53401. export var highlightsPixelShader: {
  53402. name: string;
  53403. shader: string;
  53404. };
  53405. }
  53406. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  53407. import { Nullable } from "babylonjs/types";
  53408. import { Camera } from "babylonjs/Cameras/camera";
  53409. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53410. import { Engine } from "babylonjs/Engines/engine";
  53411. import "babylonjs/Shaders/highlights.fragment";
  53412. /**
  53413. * Extracts highlights from the image
  53414. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  53415. */
  53416. export class HighlightsPostProcess extends PostProcess {
  53417. /**
  53418. * Extracts highlights from the image
  53419. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  53420. * @param name The name of the effect.
  53421. * @param options The required width/height ratio to downsize to before computing the render pass.
  53422. * @param camera The camera to apply the render pass to.
  53423. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53424. * @param engine The engine which the post process will be applied. (default: current engine)
  53425. * @param reusable If the post process can be reused on the same frame. (default: false)
  53426. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  53427. */
  53428. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  53429. }
  53430. }
  53431. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  53432. /** @hidden */
  53433. export var mrtFragmentDeclaration: {
  53434. name: string;
  53435. shader: string;
  53436. };
  53437. }
  53438. declare module "babylonjs/Shaders/geometry.fragment" {
  53439. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  53440. /** @hidden */
  53441. export var geometryPixelShader: {
  53442. name: string;
  53443. shader: string;
  53444. };
  53445. }
  53446. declare module "babylonjs/Shaders/geometry.vertex" {
  53447. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  53448. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  53449. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  53450. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  53451. /** @hidden */
  53452. export var geometryVertexShader: {
  53453. name: string;
  53454. shader: string;
  53455. };
  53456. }
  53457. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  53458. import { Matrix } from "babylonjs/Maths/math";
  53459. import { SubMesh } from "babylonjs/Meshes/subMesh";
  53460. import { Mesh } from "babylonjs/Meshes/mesh";
  53461. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  53462. import { Effect } from "babylonjs/Materials/effect";
  53463. import { Scene } from "babylonjs/scene";
  53464. import "babylonjs/Shaders/geometry.fragment";
  53465. import "babylonjs/Shaders/geometry.vertex";
  53466. /**
  53467. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  53468. */
  53469. export class GeometryBufferRenderer {
  53470. /**
  53471. * Constant used to retrieve the position texture index in the G-Buffer textures array
  53472. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  53473. */
  53474. static readonly POSITION_TEXTURE_TYPE: number;
  53475. /**
  53476. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  53477. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  53478. */
  53479. static readonly VELOCITY_TEXTURE_TYPE: number;
  53480. /**
  53481. * Dictionary used to store the previous transformation matrices of each rendered mesh
  53482. * in order to compute objects velocities when enableVelocity is set to "true"
  53483. * @hidden
  53484. */
  53485. _previousTransformationMatrices: {
  53486. [index: number]: Matrix;
  53487. };
  53488. private _scene;
  53489. private _multiRenderTarget;
  53490. private _ratio;
  53491. private _enablePosition;
  53492. private _enableVelocity;
  53493. private _positionIndex;
  53494. private _velocityIndex;
  53495. protected _effect: Effect;
  53496. protected _cachedDefines: string;
  53497. /**
  53498. * Set the render list (meshes to be rendered) used in the G buffer.
  53499. */
  53500. renderList: Mesh[];
  53501. /**
  53502. * Gets wether or not G buffer are supported by the running hardware.
  53503. * This requires draw buffer supports
  53504. */
  53505. readonly isSupported: boolean;
  53506. /**
  53507. * Returns the index of the given texture type in the G-Buffer textures array
  53508. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  53509. * @returns the index of the given texture type in the G-Buffer textures array
  53510. */
  53511. getTextureIndex(textureType: number): number;
  53512. /**
  53513. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  53514. */
  53515. /**
  53516. * Sets whether or not objects positions are enabled for the G buffer.
  53517. */
  53518. enablePosition: boolean;
  53519. /**
  53520. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  53521. */
  53522. /**
  53523. * Sets wether or not objects velocities are enabled for the G buffer.
  53524. */
  53525. enableVelocity: boolean;
  53526. /**
  53527. * Gets the scene associated with the buffer.
  53528. */
  53529. readonly scene: Scene;
  53530. /**
  53531. * Gets the ratio used by the buffer during its creation.
  53532. * How big is the buffer related to the main canvas.
  53533. */
  53534. readonly ratio: number;
  53535. /** @hidden */
  53536. static _SceneComponentInitialization: (scene: Scene) => void;
  53537. /**
  53538. * Creates a new G Buffer for the scene
  53539. * @param scene The scene the buffer belongs to
  53540. * @param ratio How big is the buffer related to the main canvas.
  53541. */
  53542. constructor(scene: Scene, ratio?: number);
  53543. /**
  53544. * Checks wether everything is ready to render a submesh to the G buffer.
  53545. * @param subMesh the submesh to check readiness for
  53546. * @param useInstances is the mesh drawn using instance or not
  53547. * @returns true if ready otherwise false
  53548. */
  53549. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  53550. /**
  53551. * Gets the current underlying G Buffer.
  53552. * @returns the buffer
  53553. */
  53554. getGBuffer(): MultiRenderTarget;
  53555. /**
  53556. * Gets the number of samples used to render the buffer (anti aliasing).
  53557. */
  53558. /**
  53559. * Sets the number of samples used to render the buffer (anti aliasing).
  53560. */
  53561. samples: number;
  53562. /**
  53563. * Disposes the renderer and frees up associated resources.
  53564. */
  53565. dispose(): void;
  53566. protected _createRenderTargets(): void;
  53567. }
  53568. }
  53569. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  53570. import { Nullable } from "babylonjs/types";
  53571. import { Scene } from "babylonjs/scene";
  53572. import { ISceneComponent } from "babylonjs/sceneComponent";
  53573. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  53574. module "babylonjs/scene" {
  53575. interface Scene {
  53576. /** @hidden (Backing field) */
  53577. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  53578. /**
  53579. * Gets or Sets the current geometry buffer associated to the scene.
  53580. */
  53581. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  53582. /**
  53583. * Enables a GeometryBufferRender and associates it with the scene
  53584. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  53585. * @returns the GeometryBufferRenderer
  53586. */
  53587. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  53588. /**
  53589. * Disables the GeometryBufferRender associated with the scene
  53590. */
  53591. disableGeometryBufferRenderer(): void;
  53592. }
  53593. }
  53594. /**
  53595. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  53596. * in several rendering techniques.
  53597. */
  53598. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  53599. /**
  53600. * The component name helpful to identify the component in the list of scene components.
  53601. */
  53602. readonly name: string;
  53603. /**
  53604. * The scene the component belongs to.
  53605. */
  53606. scene: Scene;
  53607. /**
  53608. * Creates a new instance of the component for the given scene
  53609. * @param scene Defines the scene to register the component in
  53610. */
  53611. constructor(scene: Scene);
  53612. /**
  53613. * Registers the component in a given scene
  53614. */
  53615. register(): void;
  53616. /**
  53617. * Rebuilds the elements related to this component in case of
  53618. * context lost for instance.
  53619. */
  53620. rebuild(): void;
  53621. /**
  53622. * Disposes the component and the associated ressources
  53623. */
  53624. dispose(): void;
  53625. private _gatherRenderTargets;
  53626. }
  53627. }
  53628. declare module "babylonjs/Shaders/motionBlur.fragment" {
  53629. /** @hidden */
  53630. export var motionBlurPixelShader: {
  53631. name: string;
  53632. shader: string;
  53633. };
  53634. }
  53635. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  53636. import { Nullable } from "babylonjs/types";
  53637. import { Camera } from "babylonjs/Cameras/camera";
  53638. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53639. import { Scene } from "babylonjs/scene";
  53640. import "babylonjs/Animations/animatable";
  53641. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  53642. import "babylonjs/Shaders/motionBlur.fragment";
  53643. import { Engine } from "babylonjs/Engines/engine";
  53644. /**
  53645. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  53646. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  53647. * As an example, all you have to do is to create the post-process:
  53648. * var mb = new BABYLON.MotionBlurPostProcess(
  53649. * 'mb', // The name of the effect.
  53650. * scene, // The scene containing the objects to blur according to their velocity.
  53651. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  53652. * camera // The camera to apply the render pass to.
  53653. * );
  53654. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  53655. */
  53656. export class MotionBlurPostProcess extends PostProcess {
  53657. /**
  53658. * Defines how much the image is blurred by the movement. Default value is equal to 1
  53659. */
  53660. motionStrength: number;
  53661. /**
  53662. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  53663. */
  53664. /**
  53665. * Sets the number of iterations to be used for motion blur quality
  53666. */
  53667. motionBlurSamples: number;
  53668. private _motionBlurSamples;
  53669. private _geometryBufferRenderer;
  53670. /**
  53671. * Creates a new instance MotionBlurPostProcess
  53672. * @param name The name of the effect.
  53673. * @param scene The scene containing the objects to blur according to their velocity.
  53674. * @param options The required width/height ratio to downsize to before computing the render pass.
  53675. * @param camera The camera to apply the render pass to.
  53676. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53677. * @param engine The engine which the post process will be applied. (default: current engine)
  53678. * @param reusable If the post process can be reused on the same frame. (default: false)
  53679. * @param textureType Type of textures used when performing the post process. (default: 0)
  53680. * @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)
  53681. */
  53682. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  53683. /**
  53684. * Disposes the post process.
  53685. * @param camera The camera to dispose the post process on.
  53686. */
  53687. dispose(camera?: Camera): void;
  53688. }
  53689. }
  53690. declare module "babylonjs/Shaders/refraction.fragment" {
  53691. /** @hidden */
  53692. export var refractionPixelShader: {
  53693. name: string;
  53694. shader: string;
  53695. };
  53696. }
  53697. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  53698. import { Color3 } from "babylonjs/Maths/math";
  53699. import { Camera } from "babylonjs/Cameras/camera";
  53700. import { Texture } from "babylonjs/Materials/Textures/texture";
  53701. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53702. import { Engine } from "babylonjs/Engines/engine";
  53703. import "babylonjs/Shaders/refraction.fragment";
  53704. /**
  53705. * Post process which applies a refractin texture
  53706. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  53707. */
  53708. export class RefractionPostProcess extends PostProcess {
  53709. /** the base color of the refraction (used to taint the rendering) */
  53710. color: Color3;
  53711. /** simulated refraction depth */
  53712. depth: number;
  53713. /** the coefficient of the base color (0 to remove base color tainting) */
  53714. colorLevel: number;
  53715. private _refTexture;
  53716. private _ownRefractionTexture;
  53717. /**
  53718. * Gets or sets the refraction texture
  53719. * Please note that you are responsible for disposing the texture if you set it manually
  53720. */
  53721. refractionTexture: Texture;
  53722. /**
  53723. * Initializes the RefractionPostProcess
  53724. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  53725. * @param name The name of the effect.
  53726. * @param refractionTextureUrl Url of the refraction texture to use
  53727. * @param color the base color of the refraction (used to taint the rendering)
  53728. * @param depth simulated refraction depth
  53729. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  53730. * @param camera The camera to apply the render pass to.
  53731. * @param options The required width/height ratio to downsize to before computing the render pass.
  53732. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53733. * @param engine The engine which the post process will be applied. (default: current engine)
  53734. * @param reusable If the post process can be reused on the same frame. (default: false)
  53735. */
  53736. constructor(name: string, refractionTextureUrl: string,
  53737. /** the base color of the refraction (used to taint the rendering) */
  53738. color: Color3,
  53739. /** simulated refraction depth */
  53740. depth: number,
  53741. /** the coefficient of the base color (0 to remove base color tainting) */
  53742. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  53743. /**
  53744. * Disposes of the post process
  53745. * @param camera Camera to dispose post process on
  53746. */
  53747. dispose(camera: Camera): void;
  53748. }
  53749. }
  53750. declare module "babylonjs/Shaders/sharpen.fragment" {
  53751. /** @hidden */
  53752. export var sharpenPixelShader: {
  53753. name: string;
  53754. shader: string;
  53755. };
  53756. }
  53757. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  53758. import { Nullable } from "babylonjs/types";
  53759. import { Camera } from "babylonjs/Cameras/camera";
  53760. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53761. import "babylonjs/Shaders/sharpen.fragment";
  53762. import { Engine } from "babylonjs/Engines/engine";
  53763. /**
  53764. * The SharpenPostProcess applies a sharpen kernel to every pixel
  53765. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  53766. */
  53767. export class SharpenPostProcess extends PostProcess {
  53768. /**
  53769. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  53770. */
  53771. colorAmount: number;
  53772. /**
  53773. * How much sharpness should be applied (default: 0.3)
  53774. */
  53775. edgeAmount: number;
  53776. /**
  53777. * Creates a new instance ConvolutionPostProcess
  53778. * @param name The name of the effect.
  53779. * @param options The required width/height ratio to downsize to before computing the render pass.
  53780. * @param camera The camera to apply the render pass to.
  53781. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53782. * @param engine The engine which the post process will be applied. (default: current engine)
  53783. * @param reusable If the post process can be reused on the same frame. (default: false)
  53784. * @param textureType Type of textures used when performing the post process. (default: 0)
  53785. * @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)
  53786. */
  53787. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  53788. }
  53789. }
  53790. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  53791. import { Nullable } from "babylonjs/types";
  53792. import { Camera } from "babylonjs/Cameras/camera";
  53793. import { Engine } from "babylonjs/Engines/engine";
  53794. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  53795. /**
  53796. * PostProcessRenderPipeline
  53797. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  53798. */
  53799. export class PostProcessRenderPipeline {
  53800. private engine;
  53801. private _renderEffects;
  53802. private _renderEffectsForIsolatedPass;
  53803. /**
  53804. * @hidden
  53805. */
  53806. protected _cameras: Camera[];
  53807. /** @hidden */
  53808. _name: string;
  53809. /**
  53810. * Gets pipeline name
  53811. */
  53812. readonly name: string;
  53813. /**
  53814. * Initializes a PostProcessRenderPipeline
  53815. * @param engine engine to add the pipeline to
  53816. * @param name name of the pipeline
  53817. */
  53818. constructor(engine: Engine, name: string);
  53819. /**
  53820. * Gets the class name
  53821. * @returns "PostProcessRenderPipeline"
  53822. */
  53823. getClassName(): string;
  53824. /**
  53825. * If all the render effects in the pipeline are supported
  53826. */
  53827. readonly isSupported: boolean;
  53828. /**
  53829. * Adds an effect to the pipeline
  53830. * @param renderEffect the effect to add
  53831. */
  53832. addEffect(renderEffect: PostProcessRenderEffect): void;
  53833. /** @hidden */
  53834. _rebuild(): void;
  53835. /** @hidden */
  53836. _enableEffect(renderEffectName: string, cameras: Camera): void;
  53837. /** @hidden */
  53838. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  53839. /** @hidden */
  53840. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  53841. /** @hidden */
  53842. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  53843. /** @hidden */
  53844. _attachCameras(cameras: Camera, unique: boolean): void;
  53845. /** @hidden */
  53846. _attachCameras(cameras: Camera[], unique: boolean): void;
  53847. /** @hidden */
  53848. _detachCameras(cameras: Camera): void;
  53849. /** @hidden */
  53850. _detachCameras(cameras: Nullable<Camera[]>): void;
  53851. /** @hidden */
  53852. _update(): void;
  53853. /** @hidden */
  53854. _reset(): void;
  53855. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  53856. /**
  53857. * Disposes of the pipeline
  53858. */
  53859. dispose(): void;
  53860. }
  53861. }
  53862. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  53863. import { Camera } from "babylonjs/Cameras/camera";
  53864. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  53865. /**
  53866. * PostProcessRenderPipelineManager class
  53867. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  53868. */
  53869. export class PostProcessRenderPipelineManager {
  53870. private _renderPipelines;
  53871. /**
  53872. * Initializes a PostProcessRenderPipelineManager
  53873. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  53874. */
  53875. constructor();
  53876. /**
  53877. * Gets the list of supported render pipelines
  53878. */
  53879. readonly supportedPipelines: PostProcessRenderPipeline[];
  53880. /**
  53881. * Adds a pipeline to the manager
  53882. * @param renderPipeline The pipeline to add
  53883. */
  53884. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  53885. /**
  53886. * Attaches a camera to the pipeline
  53887. * @param renderPipelineName The name of the pipeline to attach to
  53888. * @param cameras the camera to attach
  53889. * @param unique if the camera can be attached multiple times to the pipeline
  53890. */
  53891. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  53892. /**
  53893. * Detaches a camera from the pipeline
  53894. * @param renderPipelineName The name of the pipeline to detach from
  53895. * @param cameras the camera to detach
  53896. */
  53897. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  53898. /**
  53899. * Enables an effect by name on a pipeline
  53900. * @param renderPipelineName the name of the pipeline to enable the effect in
  53901. * @param renderEffectName the name of the effect to enable
  53902. * @param cameras the cameras that the effect should be enabled on
  53903. */
  53904. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  53905. /**
  53906. * Disables an effect by name on a pipeline
  53907. * @param renderPipelineName the name of the pipeline to disable the effect in
  53908. * @param renderEffectName the name of the effect to disable
  53909. * @param cameras the cameras that the effect should be disabled on
  53910. */
  53911. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  53912. /**
  53913. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  53914. */
  53915. update(): void;
  53916. /** @hidden */
  53917. _rebuild(): void;
  53918. /**
  53919. * Disposes of the manager and pipelines
  53920. */
  53921. dispose(): void;
  53922. }
  53923. }
  53924. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  53925. import { ISceneComponent } from "babylonjs/sceneComponent";
  53926. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  53927. import { Scene } from "babylonjs/scene";
  53928. module "babylonjs/scene" {
  53929. interface Scene {
  53930. /** @hidden (Backing field) */
  53931. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  53932. /**
  53933. * Gets the postprocess render pipeline manager
  53934. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  53935. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  53936. */
  53937. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  53938. }
  53939. }
  53940. /**
  53941. * Defines the Render Pipeline scene component responsible to rendering pipelines
  53942. */
  53943. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  53944. /**
  53945. * The component name helpfull to identify the component in the list of scene components.
  53946. */
  53947. readonly name: string;
  53948. /**
  53949. * The scene the component belongs to.
  53950. */
  53951. scene: Scene;
  53952. /**
  53953. * Creates a new instance of the component for the given scene
  53954. * @param scene Defines the scene to register the component in
  53955. */
  53956. constructor(scene: Scene);
  53957. /**
  53958. * Registers the component in a given scene
  53959. */
  53960. register(): void;
  53961. /**
  53962. * Rebuilds the elements related to this component in case of
  53963. * context lost for instance.
  53964. */
  53965. rebuild(): void;
  53966. /**
  53967. * Disposes the component and the associated ressources
  53968. */
  53969. dispose(): void;
  53970. private _gatherRenderTargets;
  53971. }
  53972. }
  53973. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  53974. import { IAnimatable } from "babylonjs/Misc/tools";
  53975. import { Camera } from "babylonjs/Cameras/camera";
  53976. import { IDisposable } from "babylonjs/scene";
  53977. import { Scene } from "babylonjs/scene";
  53978. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  53979. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  53980. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  53981. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  53982. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  53983. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  53984. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  53985. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  53986. import { Animation } from "babylonjs/Animations/animation";
  53987. /**
  53988. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  53989. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  53990. */
  53991. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  53992. private _scene;
  53993. private _camerasToBeAttached;
  53994. /**
  53995. * ID of the sharpen post process,
  53996. */
  53997. private readonly SharpenPostProcessId;
  53998. /**
  53999. * @ignore
  54000. * ID of the image processing post process;
  54001. */
  54002. readonly ImageProcessingPostProcessId: string;
  54003. /**
  54004. * @ignore
  54005. * ID of the Fast Approximate Anti-Aliasing post process;
  54006. */
  54007. readonly FxaaPostProcessId: string;
  54008. /**
  54009. * ID of the chromatic aberration post process,
  54010. */
  54011. private readonly ChromaticAberrationPostProcessId;
  54012. /**
  54013. * ID of the grain post process
  54014. */
  54015. private readonly GrainPostProcessId;
  54016. /**
  54017. * Sharpen post process which will apply a sharpen convolution to enhance edges
  54018. */
  54019. sharpen: SharpenPostProcess;
  54020. private _sharpenEffect;
  54021. private bloom;
  54022. /**
  54023. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  54024. */
  54025. depthOfField: DepthOfFieldEffect;
  54026. /**
  54027. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  54028. */
  54029. fxaa: FxaaPostProcess;
  54030. /**
  54031. * Image post processing pass used to perform operations such as tone mapping or color grading.
  54032. */
  54033. imageProcessing: ImageProcessingPostProcess;
  54034. /**
  54035. * Chromatic aberration post process which will shift rgb colors in the image
  54036. */
  54037. chromaticAberration: ChromaticAberrationPostProcess;
  54038. private _chromaticAberrationEffect;
  54039. /**
  54040. * Grain post process which add noise to the image
  54041. */
  54042. grain: GrainPostProcess;
  54043. private _grainEffect;
  54044. /**
  54045. * Glow post process which adds a glow to emissive areas of the image
  54046. */
  54047. private _glowLayer;
  54048. /**
  54049. * Animations which can be used to tweak settings over a period of time
  54050. */
  54051. animations: Animation[];
  54052. private _imageProcessingConfigurationObserver;
  54053. private _sharpenEnabled;
  54054. private _bloomEnabled;
  54055. private _depthOfFieldEnabled;
  54056. private _depthOfFieldBlurLevel;
  54057. private _fxaaEnabled;
  54058. private _imageProcessingEnabled;
  54059. private _defaultPipelineTextureType;
  54060. private _bloomScale;
  54061. private _chromaticAberrationEnabled;
  54062. private _grainEnabled;
  54063. private _buildAllowed;
  54064. /**
  54065. * Gets active scene
  54066. */
  54067. readonly scene: Scene;
  54068. /**
  54069. * Enable or disable the sharpen process from the pipeline
  54070. */
  54071. sharpenEnabled: boolean;
  54072. private _resizeObserver;
  54073. private _hardwareScaleLevel;
  54074. private _bloomKernel;
  54075. /**
  54076. * Specifies the size of the bloom blur kernel, relative to the final output size
  54077. */
  54078. bloomKernel: number;
  54079. /**
  54080. * Specifies the weight of the bloom in the final rendering
  54081. */
  54082. private _bloomWeight;
  54083. /**
  54084. * Specifies the luma threshold for the area that will be blurred by the bloom
  54085. */
  54086. private _bloomThreshold;
  54087. private _hdr;
  54088. /**
  54089. * The strength of the bloom.
  54090. */
  54091. bloomWeight: number;
  54092. /**
  54093. * The strength of the bloom.
  54094. */
  54095. bloomThreshold: number;
  54096. /**
  54097. * The scale of the bloom, lower value will provide better performance.
  54098. */
  54099. bloomScale: number;
  54100. /**
  54101. * Enable or disable the bloom from the pipeline
  54102. */
  54103. bloomEnabled: boolean;
  54104. private _rebuildBloom;
  54105. /**
  54106. * If the depth of field is enabled.
  54107. */
  54108. depthOfFieldEnabled: boolean;
  54109. /**
  54110. * Blur level of the depth of field effect. (Higher blur will effect performance)
  54111. */
  54112. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  54113. /**
  54114. * If the anti aliasing is enabled.
  54115. */
  54116. fxaaEnabled: boolean;
  54117. private _samples;
  54118. /**
  54119. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  54120. */
  54121. samples: number;
  54122. /**
  54123. * If image processing is enabled.
  54124. */
  54125. imageProcessingEnabled: boolean;
  54126. /**
  54127. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  54128. */
  54129. glowLayerEnabled: boolean;
  54130. /**
  54131. * Enable or disable the chromaticAberration process from the pipeline
  54132. */
  54133. chromaticAberrationEnabled: boolean;
  54134. /**
  54135. * Enable or disable the grain process from the pipeline
  54136. */
  54137. grainEnabled: boolean;
  54138. /**
  54139. * @constructor
  54140. * @param name - The rendering pipeline name (default: "")
  54141. * @param hdr - If high dynamic range textures should be used (default: true)
  54142. * @param scene - The scene linked to this pipeline (default: the last created scene)
  54143. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  54144. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  54145. */
  54146. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  54147. /**
  54148. * Get the class name
  54149. * @returns "DefaultRenderingPipeline"
  54150. */
  54151. getClassName(): string;
  54152. /**
  54153. * Force the compilation of the entire pipeline.
  54154. */
  54155. prepare(): void;
  54156. private _hasCleared;
  54157. private _prevPostProcess;
  54158. private _prevPrevPostProcess;
  54159. private _setAutoClearAndTextureSharing;
  54160. private _depthOfFieldSceneObserver;
  54161. private _buildPipeline;
  54162. private _disposePostProcesses;
  54163. /**
  54164. * Adds a camera to the pipeline
  54165. * @param camera the camera to be added
  54166. */
  54167. addCamera(camera: Camera): void;
  54168. /**
  54169. * Removes a camera from the pipeline
  54170. * @param camera the camera to remove
  54171. */
  54172. removeCamera(camera: Camera): void;
  54173. /**
  54174. * Dispose of the pipeline and stop all post processes
  54175. */
  54176. dispose(): void;
  54177. /**
  54178. * Serialize the rendering pipeline (Used when exporting)
  54179. * @returns the serialized object
  54180. */
  54181. serialize(): any;
  54182. /**
  54183. * Parse the serialized pipeline
  54184. * @param source Source pipeline.
  54185. * @param scene The scene to load the pipeline to.
  54186. * @param rootUrl The URL of the serialized pipeline.
  54187. * @returns An instantiated pipeline from the serialized object.
  54188. */
  54189. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  54190. }
  54191. }
  54192. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  54193. /** @hidden */
  54194. export var lensHighlightsPixelShader: {
  54195. name: string;
  54196. shader: string;
  54197. };
  54198. }
  54199. declare module "babylonjs/Shaders/depthOfField.fragment" {
  54200. /** @hidden */
  54201. export var depthOfFieldPixelShader: {
  54202. name: string;
  54203. shader: string;
  54204. };
  54205. }
  54206. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  54207. import { Camera } from "babylonjs/Cameras/camera";
  54208. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  54209. import { Scene } from "babylonjs/scene";
  54210. import "babylonjs/Shaders/chromaticAberration.fragment";
  54211. import "babylonjs/Shaders/lensHighlights.fragment";
  54212. import "babylonjs/Shaders/depthOfField.fragment";
  54213. /**
  54214. * BABYLON.JS Chromatic Aberration GLSL Shader
  54215. * Author: Olivier Guyot
  54216. * Separates very slightly R, G and B colors on the edges of the screen
  54217. * Inspired by Francois Tarlier & Martins Upitis
  54218. */
  54219. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  54220. /**
  54221. * @ignore
  54222. * The chromatic aberration PostProcess id in the pipeline
  54223. */
  54224. LensChromaticAberrationEffect: string;
  54225. /**
  54226. * @ignore
  54227. * The highlights enhancing PostProcess id in the pipeline
  54228. */
  54229. HighlightsEnhancingEffect: string;
  54230. /**
  54231. * @ignore
  54232. * The depth-of-field PostProcess id in the pipeline
  54233. */
  54234. LensDepthOfFieldEffect: string;
  54235. private _scene;
  54236. private _depthTexture;
  54237. private _grainTexture;
  54238. private _chromaticAberrationPostProcess;
  54239. private _highlightsPostProcess;
  54240. private _depthOfFieldPostProcess;
  54241. private _edgeBlur;
  54242. private _grainAmount;
  54243. private _chromaticAberration;
  54244. private _distortion;
  54245. private _highlightsGain;
  54246. private _highlightsThreshold;
  54247. private _dofDistance;
  54248. private _dofAperture;
  54249. private _dofDarken;
  54250. private _dofPentagon;
  54251. private _blurNoise;
  54252. /**
  54253. * @constructor
  54254. *
  54255. * Effect parameters are as follow:
  54256. * {
  54257. * chromatic_aberration: number; // from 0 to x (1 for realism)
  54258. * edge_blur: number; // from 0 to x (1 for realism)
  54259. * distortion: number; // from 0 to x (1 for realism)
  54260. * grain_amount: number; // from 0 to 1
  54261. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  54262. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  54263. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  54264. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  54265. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  54266. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  54267. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  54268. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  54269. * }
  54270. * Note: if an effect parameter is unset, effect is disabled
  54271. *
  54272. * @param name The rendering pipeline name
  54273. * @param parameters - An object containing all parameters (see above)
  54274. * @param scene The scene linked to this pipeline
  54275. * @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)
  54276. * @param cameras The array of cameras that the rendering pipeline will be attached to
  54277. */
  54278. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  54279. /**
  54280. * Sets the amount of blur at the edges
  54281. * @param amount blur amount
  54282. */
  54283. setEdgeBlur(amount: number): void;
  54284. /**
  54285. * Sets edge blur to 0
  54286. */
  54287. disableEdgeBlur(): void;
  54288. /**
  54289. * Sets the amout of grain
  54290. * @param amount Amount of grain
  54291. */
  54292. setGrainAmount(amount: number): void;
  54293. /**
  54294. * Set grain amount to 0
  54295. */
  54296. disableGrain(): void;
  54297. /**
  54298. * Sets the chromatic aberration amount
  54299. * @param amount amount of chromatic aberration
  54300. */
  54301. setChromaticAberration(amount: number): void;
  54302. /**
  54303. * Sets chromatic aberration amount to 0
  54304. */
  54305. disableChromaticAberration(): void;
  54306. /**
  54307. * Sets the EdgeDistortion amount
  54308. * @param amount amount of EdgeDistortion
  54309. */
  54310. setEdgeDistortion(amount: number): void;
  54311. /**
  54312. * Sets edge distortion to 0
  54313. */
  54314. disableEdgeDistortion(): void;
  54315. /**
  54316. * Sets the FocusDistance amount
  54317. * @param amount amount of FocusDistance
  54318. */
  54319. setFocusDistance(amount: number): void;
  54320. /**
  54321. * Disables depth of field
  54322. */
  54323. disableDepthOfField(): void;
  54324. /**
  54325. * Sets the Aperture amount
  54326. * @param amount amount of Aperture
  54327. */
  54328. setAperture(amount: number): void;
  54329. /**
  54330. * Sets the DarkenOutOfFocus amount
  54331. * @param amount amount of DarkenOutOfFocus
  54332. */
  54333. setDarkenOutOfFocus(amount: number): void;
  54334. /**
  54335. * Creates a pentagon bokeh effect
  54336. */
  54337. enablePentagonBokeh(): void;
  54338. /**
  54339. * Disables the pentagon bokeh effect
  54340. */
  54341. disablePentagonBokeh(): void;
  54342. /**
  54343. * Enables noise blur
  54344. */
  54345. enableNoiseBlur(): void;
  54346. /**
  54347. * Disables noise blur
  54348. */
  54349. disableNoiseBlur(): void;
  54350. /**
  54351. * Sets the HighlightsGain amount
  54352. * @param amount amount of HighlightsGain
  54353. */
  54354. setHighlightsGain(amount: number): void;
  54355. /**
  54356. * Sets the HighlightsThreshold amount
  54357. * @param amount amount of HighlightsThreshold
  54358. */
  54359. setHighlightsThreshold(amount: number): void;
  54360. /**
  54361. * Disables highlights
  54362. */
  54363. disableHighlights(): void;
  54364. /**
  54365. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  54366. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  54367. */
  54368. dispose(disableDepthRender?: boolean): void;
  54369. private _createChromaticAberrationPostProcess;
  54370. private _createHighlightsPostProcess;
  54371. private _createDepthOfFieldPostProcess;
  54372. private _createGrainTexture;
  54373. }
  54374. }
  54375. declare module "babylonjs/Shaders/ssao2.fragment" {
  54376. /** @hidden */
  54377. export var ssao2PixelShader: {
  54378. name: string;
  54379. shader: string;
  54380. };
  54381. }
  54382. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  54383. /** @hidden */
  54384. export var ssaoCombinePixelShader: {
  54385. name: string;
  54386. shader: string;
  54387. };
  54388. }
  54389. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  54390. import { Camera } from "babylonjs/Cameras/camera";
  54391. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  54392. import { Scene } from "babylonjs/scene";
  54393. import "babylonjs/Shaders/ssao2.fragment";
  54394. import "babylonjs/Shaders/ssaoCombine.fragment";
  54395. /**
  54396. * Render pipeline to produce ssao effect
  54397. */
  54398. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  54399. /**
  54400. * @ignore
  54401. * The PassPostProcess id in the pipeline that contains the original scene color
  54402. */
  54403. SSAOOriginalSceneColorEffect: string;
  54404. /**
  54405. * @ignore
  54406. * The SSAO PostProcess id in the pipeline
  54407. */
  54408. SSAORenderEffect: string;
  54409. /**
  54410. * @ignore
  54411. * The horizontal blur PostProcess id in the pipeline
  54412. */
  54413. SSAOBlurHRenderEffect: string;
  54414. /**
  54415. * @ignore
  54416. * The vertical blur PostProcess id in the pipeline
  54417. */
  54418. SSAOBlurVRenderEffect: string;
  54419. /**
  54420. * @ignore
  54421. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  54422. */
  54423. SSAOCombineRenderEffect: string;
  54424. /**
  54425. * The output strength of the SSAO post-process. Default value is 1.0.
  54426. */
  54427. totalStrength: number;
  54428. /**
  54429. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  54430. */
  54431. maxZ: number;
  54432. /**
  54433. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  54434. */
  54435. minZAspect: number;
  54436. private _samples;
  54437. /**
  54438. * Number of samples used for the SSAO calculations. Default value is 8
  54439. */
  54440. samples: number;
  54441. private _textureSamples;
  54442. /**
  54443. * Number of samples to use for antialiasing
  54444. */
  54445. textureSamples: number;
  54446. /**
  54447. * Ratio object used for SSAO ratio and blur ratio
  54448. */
  54449. private _ratio;
  54450. /**
  54451. * Dynamically generated sphere sampler.
  54452. */
  54453. private _sampleSphere;
  54454. /**
  54455. * Blur filter offsets
  54456. */
  54457. private _samplerOffsets;
  54458. private _expensiveBlur;
  54459. /**
  54460. * If bilateral blur should be used
  54461. */
  54462. expensiveBlur: boolean;
  54463. /**
  54464. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  54465. */
  54466. radius: number;
  54467. /**
  54468. * The base color of the SSAO post-process
  54469. * The final result is "base + ssao" between [0, 1]
  54470. */
  54471. base: number;
  54472. /**
  54473. * Support test.
  54474. */
  54475. static readonly IsSupported: boolean;
  54476. private _scene;
  54477. private _depthTexture;
  54478. private _normalTexture;
  54479. private _randomTexture;
  54480. private _originalColorPostProcess;
  54481. private _ssaoPostProcess;
  54482. private _blurHPostProcess;
  54483. private _blurVPostProcess;
  54484. private _ssaoCombinePostProcess;
  54485. private _firstUpdate;
  54486. /**
  54487. * Gets active scene
  54488. */
  54489. readonly scene: Scene;
  54490. /**
  54491. * @constructor
  54492. * @param name The rendering pipeline name
  54493. * @param scene The scene linked to this pipeline
  54494. * @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 }
  54495. * @param cameras The array of cameras that the rendering pipeline will be attached to
  54496. */
  54497. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  54498. /**
  54499. * Get the class name
  54500. * @returns "SSAO2RenderingPipeline"
  54501. */
  54502. getClassName(): string;
  54503. /**
  54504. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  54505. */
  54506. dispose(disableGeometryBufferRenderer?: boolean): void;
  54507. private _createBlurPostProcess;
  54508. /** @hidden */
  54509. _rebuild(): void;
  54510. private _bits;
  54511. private _radicalInverse_VdC;
  54512. private _hammersley;
  54513. private _hemisphereSample_uniform;
  54514. private _generateHemisphere;
  54515. private _createSSAOPostProcess;
  54516. private _createSSAOCombinePostProcess;
  54517. private _createRandomTexture;
  54518. /**
  54519. * Serialize the rendering pipeline (Used when exporting)
  54520. * @returns the serialized object
  54521. */
  54522. serialize(): any;
  54523. /**
  54524. * Parse the serialized pipeline
  54525. * @param source Source pipeline.
  54526. * @param scene The scene to load the pipeline to.
  54527. * @param rootUrl The URL of the serialized pipeline.
  54528. * @returns An instantiated pipeline from the serialized object.
  54529. */
  54530. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  54531. }
  54532. }
  54533. declare module "babylonjs/Shaders/ssao.fragment" {
  54534. /** @hidden */
  54535. export var ssaoPixelShader: {
  54536. name: string;
  54537. shader: string;
  54538. };
  54539. }
  54540. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  54541. import { Camera } from "babylonjs/Cameras/camera";
  54542. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  54543. import { Scene } from "babylonjs/scene";
  54544. import "babylonjs/Shaders/ssao.fragment";
  54545. import "babylonjs/Shaders/ssaoCombine.fragment";
  54546. /**
  54547. * Render pipeline to produce ssao effect
  54548. */
  54549. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  54550. /**
  54551. * @ignore
  54552. * The PassPostProcess id in the pipeline that contains the original scene color
  54553. */
  54554. SSAOOriginalSceneColorEffect: string;
  54555. /**
  54556. * @ignore
  54557. * The SSAO PostProcess id in the pipeline
  54558. */
  54559. SSAORenderEffect: string;
  54560. /**
  54561. * @ignore
  54562. * The horizontal blur PostProcess id in the pipeline
  54563. */
  54564. SSAOBlurHRenderEffect: string;
  54565. /**
  54566. * @ignore
  54567. * The vertical blur PostProcess id in the pipeline
  54568. */
  54569. SSAOBlurVRenderEffect: string;
  54570. /**
  54571. * @ignore
  54572. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  54573. */
  54574. SSAOCombineRenderEffect: string;
  54575. /**
  54576. * The output strength of the SSAO post-process. Default value is 1.0.
  54577. */
  54578. totalStrength: number;
  54579. /**
  54580. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  54581. */
  54582. radius: number;
  54583. /**
  54584. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  54585. * Must not be equal to fallOff and superior to fallOff.
  54586. * Default value is 0.0075
  54587. */
  54588. area: number;
  54589. /**
  54590. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  54591. * Must not be equal to area and inferior to area.
  54592. * Default value is 0.000001
  54593. */
  54594. fallOff: number;
  54595. /**
  54596. * The base color of the SSAO post-process
  54597. * The final result is "base + ssao" between [0, 1]
  54598. */
  54599. base: number;
  54600. private _scene;
  54601. private _depthTexture;
  54602. private _randomTexture;
  54603. private _originalColorPostProcess;
  54604. private _ssaoPostProcess;
  54605. private _blurHPostProcess;
  54606. private _blurVPostProcess;
  54607. private _ssaoCombinePostProcess;
  54608. private _firstUpdate;
  54609. /**
  54610. * Gets active scene
  54611. */
  54612. readonly scene: Scene;
  54613. /**
  54614. * @constructor
  54615. * @param name - The rendering pipeline name
  54616. * @param scene - The scene linked to this pipeline
  54617. * @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 }
  54618. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  54619. */
  54620. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  54621. /**
  54622. * Get the class name
  54623. * @returns "SSAORenderingPipeline"
  54624. */
  54625. getClassName(): string;
  54626. /**
  54627. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  54628. */
  54629. dispose(disableDepthRender?: boolean): void;
  54630. private _createBlurPostProcess;
  54631. /** @hidden */
  54632. _rebuild(): void;
  54633. private _createSSAOPostProcess;
  54634. private _createSSAOCombinePostProcess;
  54635. private _createRandomTexture;
  54636. }
  54637. }
  54638. declare module "babylonjs/Shaders/standard.fragment" {
  54639. /** @hidden */
  54640. export var standardPixelShader: {
  54641. name: string;
  54642. shader: string;
  54643. };
  54644. }
  54645. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  54646. import { Nullable } from "babylonjs/types";
  54647. import { IAnimatable } from "babylonjs/Misc/tools";
  54648. import { Camera } from "babylonjs/Cameras/camera";
  54649. import { Texture } from "babylonjs/Materials/Textures/texture";
  54650. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  54651. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  54652. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  54653. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  54654. import { IDisposable } from "babylonjs/scene";
  54655. import { SpotLight } from "babylonjs/Lights/spotLight";
  54656. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  54657. import { Scene } from "babylonjs/scene";
  54658. import { Animation } from "babylonjs/Animations/animation";
  54659. import "babylonjs/Shaders/standard.fragment";
  54660. /**
  54661. * Standard rendering pipeline
  54662. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  54663. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  54664. */
  54665. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  54666. /**
  54667. * Public members
  54668. */
  54669. /**
  54670. * Post-process which contains the original scene color before the pipeline applies all the effects
  54671. */
  54672. originalPostProcess: Nullable<PostProcess>;
  54673. /**
  54674. * Post-process used to down scale an image x4
  54675. */
  54676. downSampleX4PostProcess: Nullable<PostProcess>;
  54677. /**
  54678. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  54679. */
  54680. brightPassPostProcess: Nullable<PostProcess>;
  54681. /**
  54682. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  54683. */
  54684. blurHPostProcesses: PostProcess[];
  54685. /**
  54686. * Post-process array storing all the vertical blur post-processes used by the pipeline
  54687. */
  54688. blurVPostProcesses: PostProcess[];
  54689. /**
  54690. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  54691. */
  54692. textureAdderPostProcess: Nullable<PostProcess>;
  54693. /**
  54694. * Post-process used to create volumetric lighting effect
  54695. */
  54696. volumetricLightPostProcess: Nullable<PostProcess>;
  54697. /**
  54698. * Post-process used to smooth the previous volumetric light post-process on the X axis
  54699. */
  54700. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  54701. /**
  54702. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  54703. */
  54704. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  54705. /**
  54706. * Post-process used to merge the volumetric light effect and the real scene color
  54707. */
  54708. volumetricLightMergePostProces: Nullable<PostProcess>;
  54709. /**
  54710. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  54711. */
  54712. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  54713. /**
  54714. * Base post-process used to calculate the average luminance of the final image for HDR
  54715. */
  54716. luminancePostProcess: Nullable<PostProcess>;
  54717. /**
  54718. * Post-processes used to create down sample post-processes in order to get
  54719. * the average luminance of the final image for HDR
  54720. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  54721. */
  54722. luminanceDownSamplePostProcesses: PostProcess[];
  54723. /**
  54724. * Post-process used to create a HDR effect (light adaptation)
  54725. */
  54726. hdrPostProcess: Nullable<PostProcess>;
  54727. /**
  54728. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  54729. */
  54730. textureAdderFinalPostProcess: Nullable<PostProcess>;
  54731. /**
  54732. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  54733. */
  54734. lensFlareFinalPostProcess: Nullable<PostProcess>;
  54735. /**
  54736. * Post-process used to merge the final HDR post-process and the real scene color
  54737. */
  54738. hdrFinalPostProcess: Nullable<PostProcess>;
  54739. /**
  54740. * Post-process used to create a lens flare effect
  54741. */
  54742. lensFlarePostProcess: Nullable<PostProcess>;
  54743. /**
  54744. * Post-process that merges the result of the lens flare post-process and the real scene color
  54745. */
  54746. lensFlareComposePostProcess: Nullable<PostProcess>;
  54747. /**
  54748. * Post-process used to create a motion blur effect
  54749. */
  54750. motionBlurPostProcess: Nullable<PostProcess>;
  54751. /**
  54752. * Post-process used to create a depth of field effect
  54753. */
  54754. depthOfFieldPostProcess: Nullable<PostProcess>;
  54755. /**
  54756. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  54757. */
  54758. fxaaPostProcess: Nullable<FxaaPostProcess>;
  54759. /**
  54760. * Represents the brightness threshold in order to configure the illuminated surfaces
  54761. */
  54762. brightThreshold: number;
  54763. /**
  54764. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  54765. */
  54766. blurWidth: number;
  54767. /**
  54768. * Sets if the blur for highlighted surfaces must be only horizontal
  54769. */
  54770. horizontalBlur: boolean;
  54771. /**
  54772. * Sets the overall exposure used by the pipeline
  54773. */
  54774. exposure: number;
  54775. /**
  54776. * Texture used typically to simulate "dirty" on camera lens
  54777. */
  54778. lensTexture: Nullable<Texture>;
  54779. /**
  54780. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  54781. */
  54782. volumetricLightCoefficient: number;
  54783. /**
  54784. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  54785. */
  54786. volumetricLightPower: number;
  54787. /**
  54788. * Used the set the blur intensity to smooth the volumetric lights
  54789. */
  54790. volumetricLightBlurScale: number;
  54791. /**
  54792. * Light (spot or directional) used to generate the volumetric lights rays
  54793. * The source light must have a shadow generate so the pipeline can get its
  54794. * depth map
  54795. */
  54796. sourceLight: Nullable<SpotLight | DirectionalLight>;
  54797. /**
  54798. * For eye adaptation, represents the minimum luminance the eye can see
  54799. */
  54800. hdrMinimumLuminance: number;
  54801. /**
  54802. * For eye adaptation, represents the decrease luminance speed
  54803. */
  54804. hdrDecreaseRate: number;
  54805. /**
  54806. * For eye adaptation, represents the increase luminance speed
  54807. */
  54808. hdrIncreaseRate: number;
  54809. /**
  54810. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  54811. */
  54812. lensColorTexture: Nullable<Texture>;
  54813. /**
  54814. * The overall strengh for the lens flare effect
  54815. */
  54816. lensFlareStrength: number;
  54817. /**
  54818. * Dispersion coefficient for lens flare ghosts
  54819. */
  54820. lensFlareGhostDispersal: number;
  54821. /**
  54822. * Main lens flare halo width
  54823. */
  54824. lensFlareHaloWidth: number;
  54825. /**
  54826. * Based on the lens distortion effect, defines how much the lens flare result
  54827. * is distorted
  54828. */
  54829. lensFlareDistortionStrength: number;
  54830. /**
  54831. * Lens star texture must be used to simulate rays on the flares and is available
  54832. * in the documentation
  54833. */
  54834. lensStarTexture: Nullable<Texture>;
  54835. /**
  54836. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  54837. * flare effect by taking account of the dirt texture
  54838. */
  54839. lensFlareDirtTexture: Nullable<Texture>;
  54840. /**
  54841. * Represents the focal length for the depth of field effect
  54842. */
  54843. depthOfFieldDistance: number;
  54844. /**
  54845. * Represents the blur intensity for the blurred part of the depth of field effect
  54846. */
  54847. depthOfFieldBlurWidth: number;
  54848. /**
  54849. * For motion blur, defines how much the image is blurred by the movement
  54850. */
  54851. motionStrength: number;
  54852. /**
  54853. * List of animations for the pipeline (IAnimatable implementation)
  54854. */
  54855. animations: Animation[];
  54856. /**
  54857. * Private members
  54858. */
  54859. private _scene;
  54860. private _currentDepthOfFieldSource;
  54861. private _basePostProcess;
  54862. private _hdrCurrentLuminance;
  54863. private _floatTextureType;
  54864. private _ratio;
  54865. private _bloomEnabled;
  54866. private _depthOfFieldEnabled;
  54867. private _vlsEnabled;
  54868. private _lensFlareEnabled;
  54869. private _hdrEnabled;
  54870. private _motionBlurEnabled;
  54871. private _fxaaEnabled;
  54872. private _motionBlurSamples;
  54873. private _volumetricLightStepsCount;
  54874. private _samples;
  54875. /**
  54876. * @ignore
  54877. * Specifies if the bloom pipeline is enabled
  54878. */
  54879. BloomEnabled: boolean;
  54880. /**
  54881. * @ignore
  54882. * Specifies if the depth of field pipeline is enabed
  54883. */
  54884. DepthOfFieldEnabled: boolean;
  54885. /**
  54886. * @ignore
  54887. * Specifies if the lens flare pipeline is enabed
  54888. */
  54889. LensFlareEnabled: boolean;
  54890. /**
  54891. * @ignore
  54892. * Specifies if the HDR pipeline is enabled
  54893. */
  54894. HDREnabled: boolean;
  54895. /**
  54896. * @ignore
  54897. * Specifies if the volumetric lights scattering effect is enabled
  54898. */
  54899. VLSEnabled: boolean;
  54900. /**
  54901. * @ignore
  54902. * Specifies if the motion blur effect is enabled
  54903. */
  54904. MotionBlurEnabled: boolean;
  54905. /**
  54906. * Specifies if anti-aliasing is enabled
  54907. */
  54908. fxaaEnabled: boolean;
  54909. /**
  54910. * Specifies the number of steps used to calculate the volumetric lights
  54911. * Typically in interval [50, 200]
  54912. */
  54913. volumetricLightStepsCount: number;
  54914. /**
  54915. * Specifies the number of samples used for the motion blur effect
  54916. * Typically in interval [16, 64]
  54917. */
  54918. motionBlurSamples: number;
  54919. /**
  54920. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  54921. */
  54922. samples: number;
  54923. /**
  54924. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  54925. * @constructor
  54926. * @param name The rendering pipeline name
  54927. * @param scene The scene linked to this pipeline
  54928. * @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)
  54929. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  54930. * @param cameras The array of cameras that the rendering pipeline will be attached to
  54931. */
  54932. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  54933. private _buildPipeline;
  54934. private _createDownSampleX4PostProcess;
  54935. private _createBrightPassPostProcess;
  54936. private _createBlurPostProcesses;
  54937. private _createTextureAdderPostProcess;
  54938. private _createVolumetricLightPostProcess;
  54939. private _createLuminancePostProcesses;
  54940. private _createHdrPostProcess;
  54941. private _createLensFlarePostProcess;
  54942. private _createDepthOfFieldPostProcess;
  54943. private _createMotionBlurPostProcess;
  54944. private _getDepthTexture;
  54945. private _disposePostProcesses;
  54946. /**
  54947. * Dispose of the pipeline and stop all post processes
  54948. */
  54949. dispose(): void;
  54950. /**
  54951. * Serialize the rendering pipeline (Used when exporting)
  54952. * @returns the serialized object
  54953. */
  54954. serialize(): any;
  54955. /**
  54956. * Parse the serialized pipeline
  54957. * @param source Source pipeline.
  54958. * @param scene The scene to load the pipeline to.
  54959. * @param rootUrl The URL of the serialized pipeline.
  54960. * @returns An instantiated pipeline from the serialized object.
  54961. */
  54962. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  54963. /**
  54964. * Luminance steps
  54965. */
  54966. static LuminanceSteps: number;
  54967. }
  54968. }
  54969. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  54970. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  54971. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  54972. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  54973. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  54974. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  54975. }
  54976. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  54977. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  54978. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  54979. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  54980. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  54981. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  54982. }
  54983. declare module "babylonjs/Shaders/tonemap.fragment" {
  54984. /** @hidden */
  54985. export var tonemapPixelShader: {
  54986. name: string;
  54987. shader: string;
  54988. };
  54989. }
  54990. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  54991. import { Camera } from "babylonjs/Cameras/camera";
  54992. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  54993. import "babylonjs/Shaders/tonemap.fragment";
  54994. import { Engine } from "babylonjs/Engines/engine";
  54995. /** Defines operator used for tonemapping */
  54996. export enum TonemappingOperator {
  54997. /** Hable */
  54998. Hable = 0,
  54999. /** Reinhard */
  55000. Reinhard = 1,
  55001. /** HejiDawson */
  55002. HejiDawson = 2,
  55003. /** Photographic */
  55004. Photographic = 3
  55005. }
  55006. /**
  55007. * Defines a post process to apply tone mapping
  55008. */
  55009. export class TonemapPostProcess extends PostProcess {
  55010. private _operator;
  55011. /** Defines the required exposure adjustement */
  55012. exposureAdjustment: number;
  55013. /**
  55014. * Creates a new TonemapPostProcess
  55015. * @param name defines the name of the postprocess
  55016. * @param _operator defines the operator to use
  55017. * @param exposureAdjustment defines the required exposure adjustement
  55018. * @param camera defines the camera to use (can be null)
  55019. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  55020. * @param engine defines the hosting engine (can be ignore if camera is set)
  55021. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  55022. */
  55023. constructor(name: string, _operator: TonemappingOperator,
  55024. /** Defines the required exposure adjustement */
  55025. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  55026. }
  55027. }
  55028. declare module "babylonjs/Shaders/depth.vertex" {
  55029. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  55030. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  55031. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  55032. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  55033. /** @hidden */
  55034. export var depthVertexShader: {
  55035. name: string;
  55036. shader: string;
  55037. };
  55038. }
  55039. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  55040. /** @hidden */
  55041. export var volumetricLightScatteringPixelShader: {
  55042. name: string;
  55043. shader: string;
  55044. };
  55045. }
  55046. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  55047. /** @hidden */
  55048. export var volumetricLightScatteringPassPixelShader: {
  55049. name: string;
  55050. shader: string;
  55051. };
  55052. }
  55053. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  55054. import { Vector3 } from "babylonjs/Maths/math";
  55055. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55056. import { Mesh } from "babylonjs/Meshes/mesh";
  55057. import { Camera } from "babylonjs/Cameras/camera";
  55058. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  55059. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  55060. import { Scene } from "babylonjs/scene";
  55061. import "babylonjs/Meshes/Builders/planeBuilder";
  55062. import "babylonjs/Shaders/depth.vertex";
  55063. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  55064. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  55065. import { Engine } from "babylonjs/Engines/engine";
  55066. /**
  55067. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  55068. */
  55069. export class VolumetricLightScatteringPostProcess extends PostProcess {
  55070. private _volumetricLightScatteringPass;
  55071. private _volumetricLightScatteringRTT;
  55072. private _viewPort;
  55073. private _screenCoordinates;
  55074. private _cachedDefines;
  55075. /**
  55076. * If not undefined, the mesh position is computed from the attached node position
  55077. */
  55078. attachedNode: {
  55079. position: Vector3;
  55080. };
  55081. /**
  55082. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  55083. */
  55084. customMeshPosition: Vector3;
  55085. /**
  55086. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  55087. */
  55088. useCustomMeshPosition: boolean;
  55089. /**
  55090. * If the post-process should inverse the light scattering direction
  55091. */
  55092. invert: boolean;
  55093. /**
  55094. * The internal mesh used by the post-process
  55095. */
  55096. mesh: Mesh;
  55097. /**
  55098. * @hidden
  55099. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  55100. */
  55101. useDiffuseColor: boolean;
  55102. /**
  55103. * Array containing the excluded meshes not rendered in the internal pass
  55104. */
  55105. excludedMeshes: AbstractMesh[];
  55106. /**
  55107. * Controls the overall intensity of the post-process
  55108. */
  55109. exposure: number;
  55110. /**
  55111. * Dissipates each sample's contribution in range [0, 1]
  55112. */
  55113. decay: number;
  55114. /**
  55115. * Controls the overall intensity of each sample
  55116. */
  55117. weight: number;
  55118. /**
  55119. * Controls the density of each sample
  55120. */
  55121. density: number;
  55122. /**
  55123. * @constructor
  55124. * @param name The post-process name
  55125. * @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)
  55126. * @param camera The camera that the post-process will be attached to
  55127. * @param mesh The mesh used to create the light scattering
  55128. * @param samples The post-process quality, default 100
  55129. * @param samplingModeThe post-process filtering mode
  55130. * @param engine The babylon engine
  55131. * @param reusable If the post-process is reusable
  55132. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  55133. */
  55134. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  55135. /**
  55136. * Returns the string "VolumetricLightScatteringPostProcess"
  55137. * @returns "VolumetricLightScatteringPostProcess"
  55138. */
  55139. getClassName(): string;
  55140. private _isReady;
  55141. /**
  55142. * Sets the new light position for light scattering effect
  55143. * @param position The new custom light position
  55144. */
  55145. setCustomMeshPosition(position: Vector3): void;
  55146. /**
  55147. * Returns the light position for light scattering effect
  55148. * @return Vector3 The custom light position
  55149. */
  55150. getCustomMeshPosition(): Vector3;
  55151. /**
  55152. * Disposes the internal assets and detaches the post-process from the camera
  55153. */
  55154. dispose(camera: Camera): void;
  55155. /**
  55156. * Returns the render target texture used by the post-process
  55157. * @return the render target texture used by the post-process
  55158. */
  55159. getPass(): RenderTargetTexture;
  55160. private _meshExcluded;
  55161. private _createPass;
  55162. private _updateMeshScreenCoordinates;
  55163. /**
  55164. * Creates a default mesh for the Volumeric Light Scattering post-process
  55165. * @param name The mesh name
  55166. * @param scene The scene where to create the mesh
  55167. * @return the default mesh
  55168. */
  55169. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  55170. }
  55171. }
  55172. declare module "babylonjs/PostProcesses/index" {
  55173. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  55174. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  55175. export * from "babylonjs/PostProcesses/bloomEffect";
  55176. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  55177. export * from "babylonjs/PostProcesses/blurPostProcess";
  55178. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  55179. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  55180. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  55181. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  55182. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  55183. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  55184. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  55185. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  55186. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  55187. export * from "babylonjs/PostProcesses/filterPostProcess";
  55188. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  55189. export * from "babylonjs/PostProcesses/grainPostProcess";
  55190. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  55191. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  55192. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  55193. export * from "babylonjs/PostProcesses/passPostProcess";
  55194. export * from "babylonjs/PostProcesses/postProcess";
  55195. export * from "babylonjs/PostProcesses/postProcessManager";
  55196. export * from "babylonjs/PostProcesses/refractionPostProcess";
  55197. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  55198. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  55199. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  55200. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  55201. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  55202. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  55203. }
  55204. declare module "babylonjs/Probes/index" {
  55205. export * from "babylonjs/Probes/reflectionProbe";
  55206. }
  55207. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  55208. import { Scene } from "babylonjs/scene";
  55209. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55210. import { Color3 } from "babylonjs/Maths/math";
  55211. import { SmartArray } from "babylonjs/Misc/smartArray";
  55212. import { ISceneComponent } from "babylonjs/sceneComponent";
  55213. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  55214. import "babylonjs/Meshes/Builders/boxBuilder";
  55215. import "babylonjs/Shaders/color.fragment";
  55216. import "babylonjs/Shaders/color.vertex";
  55217. module "babylonjs/scene" {
  55218. interface Scene {
  55219. /** @hidden (Backing field) */
  55220. _boundingBoxRenderer: BoundingBoxRenderer;
  55221. /** @hidden (Backing field) */
  55222. _forceShowBoundingBoxes: boolean;
  55223. /**
  55224. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  55225. */
  55226. forceShowBoundingBoxes: boolean;
  55227. /**
  55228. * Gets the bounding box renderer associated with the scene
  55229. * @returns a BoundingBoxRenderer
  55230. */
  55231. getBoundingBoxRenderer(): BoundingBoxRenderer;
  55232. }
  55233. }
  55234. module "babylonjs/Meshes/abstractMesh" {
  55235. interface AbstractMesh {
  55236. /** @hidden (Backing field) */
  55237. _showBoundingBox: boolean;
  55238. /**
  55239. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  55240. */
  55241. showBoundingBox: boolean;
  55242. }
  55243. }
  55244. /**
  55245. * Component responsible of rendering the bounding box of the meshes in a scene.
  55246. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  55247. */
  55248. export class BoundingBoxRenderer implements ISceneComponent {
  55249. /**
  55250. * The component name helpfull to identify the component in the list of scene components.
  55251. */
  55252. readonly name: string;
  55253. /**
  55254. * The scene the component belongs to.
  55255. */
  55256. scene: Scene;
  55257. /**
  55258. * Color of the bounding box lines placed in front of an object
  55259. */
  55260. frontColor: Color3;
  55261. /**
  55262. * Color of the bounding box lines placed behind an object
  55263. */
  55264. backColor: Color3;
  55265. /**
  55266. * Defines if the renderer should show the back lines or not
  55267. */
  55268. showBackLines: boolean;
  55269. /**
  55270. * @hidden
  55271. */
  55272. renderList: SmartArray<BoundingBox>;
  55273. private _colorShader;
  55274. private _vertexBuffers;
  55275. private _indexBuffer;
  55276. /**
  55277. * Instantiates a new bounding box renderer in a scene.
  55278. * @param scene the scene the renderer renders in
  55279. */
  55280. constructor(scene: Scene);
  55281. /**
  55282. * Registers the component in a given scene
  55283. */
  55284. register(): void;
  55285. private _evaluateSubMesh;
  55286. private _activeMesh;
  55287. private _prepareRessources;
  55288. private _createIndexBuffer;
  55289. /**
  55290. * Rebuilds the elements related to this component in case of
  55291. * context lost for instance.
  55292. */
  55293. rebuild(): void;
  55294. /**
  55295. * @hidden
  55296. */
  55297. reset(): void;
  55298. /**
  55299. * Render the bounding boxes of a specific rendering group
  55300. * @param renderingGroupId defines the rendering group to render
  55301. */
  55302. render(renderingGroupId: number): void;
  55303. /**
  55304. * In case of occlusion queries, we can render the occlusion bounding box through this method
  55305. * @param mesh Define the mesh to render the occlusion bounding box for
  55306. */
  55307. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  55308. /**
  55309. * Dispose and release the resources attached to this renderer.
  55310. */
  55311. dispose(): void;
  55312. }
  55313. }
  55314. declare module "babylonjs/Shaders/depth.fragment" {
  55315. /** @hidden */
  55316. export var depthPixelShader: {
  55317. name: string;
  55318. shader: string;
  55319. };
  55320. }
  55321. declare module "babylonjs/Rendering/depthRenderer" {
  55322. import { Nullable } from "babylonjs/types";
  55323. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55324. import { Scene } from "babylonjs/scene";
  55325. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  55326. import { Camera } from "babylonjs/Cameras/camera";
  55327. import "babylonjs/Shaders/depth.fragment";
  55328. import "babylonjs/Shaders/depth.vertex";
  55329. /**
  55330. * This represents a depth renderer in Babylon.
  55331. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  55332. */
  55333. export class DepthRenderer {
  55334. private _scene;
  55335. private _depthMap;
  55336. private _effect;
  55337. private _cachedDefines;
  55338. private _camera;
  55339. /**
  55340. * Specifiess that the depth renderer will only be used within
  55341. * the camera it is created for.
  55342. * This can help forcing its rendering during the camera processing.
  55343. */
  55344. useOnlyInActiveCamera: boolean;
  55345. /** @hidden */
  55346. static _SceneComponentInitialization: (scene: Scene) => void;
  55347. /**
  55348. * Instantiates a depth renderer
  55349. * @param scene The scene the renderer belongs to
  55350. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  55351. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  55352. */
  55353. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  55354. /**
  55355. * Creates the depth rendering effect and checks if the effect is ready.
  55356. * @param subMesh The submesh to be used to render the depth map of
  55357. * @param useInstances If multiple world instances should be used
  55358. * @returns if the depth renderer is ready to render the depth map
  55359. */
  55360. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  55361. /**
  55362. * Gets the texture which the depth map will be written to.
  55363. * @returns The depth map texture
  55364. */
  55365. getDepthMap(): RenderTargetTexture;
  55366. /**
  55367. * Disposes of the depth renderer.
  55368. */
  55369. dispose(): void;
  55370. }
  55371. }
  55372. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  55373. import { Nullable } from "babylonjs/types";
  55374. import { Scene } from "babylonjs/scene";
  55375. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  55376. import { Camera } from "babylonjs/Cameras/camera";
  55377. import { ISceneComponent } from "babylonjs/sceneComponent";
  55378. module "babylonjs/scene" {
  55379. interface Scene {
  55380. /** @hidden (Backing field) */
  55381. _depthRenderer: {
  55382. [id: string]: DepthRenderer;
  55383. };
  55384. /**
  55385. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  55386. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  55387. * @returns the created depth renderer
  55388. */
  55389. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  55390. /**
  55391. * Disables a depth renderer for a given camera
  55392. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  55393. */
  55394. disableDepthRenderer(camera?: Nullable<Camera>): void;
  55395. }
  55396. }
  55397. /**
  55398. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  55399. * in several rendering techniques.
  55400. */
  55401. export class DepthRendererSceneComponent implements ISceneComponent {
  55402. /**
  55403. * The component name helpfull to identify the component in the list of scene components.
  55404. */
  55405. readonly name: string;
  55406. /**
  55407. * The scene the component belongs to.
  55408. */
  55409. scene: Scene;
  55410. /**
  55411. * Creates a new instance of the component for the given scene
  55412. * @param scene Defines the scene to register the component in
  55413. */
  55414. constructor(scene: Scene);
  55415. /**
  55416. * Registers the component in a given scene
  55417. */
  55418. register(): void;
  55419. /**
  55420. * Rebuilds the elements related to this component in case of
  55421. * context lost for instance.
  55422. */
  55423. rebuild(): void;
  55424. /**
  55425. * Disposes the component and the associated ressources
  55426. */
  55427. dispose(): void;
  55428. private _gatherRenderTargets;
  55429. private _gatherActiveCameraRenderTargets;
  55430. }
  55431. }
  55432. declare module "babylonjs/Shaders/outline.fragment" {
  55433. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  55434. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  55435. /** @hidden */
  55436. export var outlinePixelShader: {
  55437. name: string;
  55438. shader: string;
  55439. };
  55440. }
  55441. declare module "babylonjs/Shaders/outline.vertex" {
  55442. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  55443. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  55444. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  55445. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  55446. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  55447. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  55448. /** @hidden */
  55449. export var outlineVertexShader: {
  55450. name: string;
  55451. shader: string;
  55452. };
  55453. }
  55454. declare module "babylonjs/Rendering/outlineRenderer" {
  55455. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55456. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  55457. import { Scene } from "babylonjs/scene";
  55458. import { ISceneComponent } from "babylonjs/sceneComponent";
  55459. import "babylonjs/Shaders/outline.fragment";
  55460. import "babylonjs/Shaders/outline.vertex";
  55461. module "babylonjs/scene" {
  55462. interface Scene {
  55463. /** @hidden */
  55464. _outlineRenderer: OutlineRenderer;
  55465. /**
  55466. * Gets the outline renderer associated with the scene
  55467. * @returns a OutlineRenderer
  55468. */
  55469. getOutlineRenderer(): OutlineRenderer;
  55470. }
  55471. }
  55472. module "babylonjs/Meshes/abstractMesh" {
  55473. interface AbstractMesh {
  55474. /** @hidden (Backing field) */
  55475. _renderOutline: boolean;
  55476. /**
  55477. * Gets or sets a boolean indicating if the outline must be rendered as well
  55478. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  55479. */
  55480. renderOutline: boolean;
  55481. /** @hidden (Backing field) */
  55482. _renderOverlay: boolean;
  55483. /**
  55484. * Gets or sets a boolean indicating if the overlay must be rendered as well
  55485. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  55486. */
  55487. renderOverlay: boolean;
  55488. }
  55489. }
  55490. /**
  55491. * This class is responsible to draw bothe outline/overlay of meshes.
  55492. * It should not be used directly but through the available method on mesh.
  55493. */
  55494. export class OutlineRenderer implements ISceneComponent {
  55495. /**
  55496. * The name of the component. Each component must have a unique name.
  55497. */
  55498. name: string;
  55499. /**
  55500. * The scene the component belongs to.
  55501. */
  55502. scene: Scene;
  55503. /**
  55504. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  55505. */
  55506. zOffset: number;
  55507. private _engine;
  55508. private _effect;
  55509. private _cachedDefines;
  55510. private _savedDepthWrite;
  55511. /**
  55512. * Instantiates a new outline renderer. (There could be only one per scene).
  55513. * @param scene Defines the scene it belongs to
  55514. */
  55515. constructor(scene: Scene);
  55516. /**
  55517. * Register the component to one instance of a scene.
  55518. */
  55519. register(): void;
  55520. /**
  55521. * Rebuilds the elements related to this component in case of
  55522. * context lost for instance.
  55523. */
  55524. rebuild(): void;
  55525. /**
  55526. * Disposes the component and the associated ressources.
  55527. */
  55528. dispose(): void;
  55529. /**
  55530. * Renders the outline in the canvas.
  55531. * @param subMesh Defines the sumesh to render
  55532. * @param batch Defines the batch of meshes in case of instances
  55533. * @param useOverlay Defines if the rendering is for the overlay or the outline
  55534. */
  55535. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  55536. /**
  55537. * Returns whether or not the outline renderer is ready for a given submesh.
  55538. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  55539. * @param subMesh Defines the submesh to check readyness for
  55540. * @param useInstances Defines wheter wee are trying to render instances or not
  55541. * @returns true if ready otherwise false
  55542. */
  55543. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  55544. private _beforeRenderingMesh;
  55545. private _afterRenderingMesh;
  55546. }
  55547. }
  55548. declare module "babylonjs/Rendering/index" {
  55549. export * from "babylonjs/Rendering/boundingBoxRenderer";
  55550. export * from "babylonjs/Rendering/depthRenderer";
  55551. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  55552. export * from "babylonjs/Rendering/edgesRenderer";
  55553. export * from "babylonjs/Rendering/geometryBufferRenderer";
  55554. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  55555. export * from "babylonjs/Rendering/outlineRenderer";
  55556. export * from "babylonjs/Rendering/renderingGroup";
  55557. export * from "babylonjs/Rendering/renderingManager";
  55558. export * from "babylonjs/Rendering/utilityLayerRenderer";
  55559. }
  55560. declare module "babylonjs/Sprites/index" {
  55561. export * from "babylonjs/Sprites/sprite";
  55562. export * from "babylonjs/Sprites/spriteManager";
  55563. export * from "babylonjs/Sprites/spriteSceneComponent";
  55564. }
  55565. declare module "babylonjs/Misc/assetsManager" {
  55566. import { Scene } from "babylonjs/scene";
  55567. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55568. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  55569. import { Skeleton } from "babylonjs/Bones/skeleton";
  55570. import { Observable } from "babylonjs/Misc/observable";
  55571. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55572. import { Texture } from "babylonjs/Materials/Textures/texture";
  55573. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  55574. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  55575. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  55576. /**
  55577. * Defines the list of states available for a task inside a AssetsManager
  55578. */
  55579. export enum AssetTaskState {
  55580. /**
  55581. * Initialization
  55582. */
  55583. INIT = 0,
  55584. /**
  55585. * Running
  55586. */
  55587. RUNNING = 1,
  55588. /**
  55589. * Done
  55590. */
  55591. DONE = 2,
  55592. /**
  55593. * Error
  55594. */
  55595. ERROR = 3
  55596. }
  55597. /**
  55598. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  55599. */
  55600. export abstract class AbstractAssetTask {
  55601. /**
  55602. * Task name
  55603. */ name: string;
  55604. /**
  55605. * Callback called when the task is successful
  55606. */
  55607. onSuccess: (task: any) => void;
  55608. /**
  55609. * Callback called when the task is not successful
  55610. */
  55611. onError: (task: any, message?: string, exception?: any) => void;
  55612. /**
  55613. * Creates a new AssetsManager
  55614. * @param name defines the name of the task
  55615. */
  55616. constructor(
  55617. /**
  55618. * Task name
  55619. */ name: string);
  55620. private _isCompleted;
  55621. private _taskState;
  55622. private _errorObject;
  55623. /**
  55624. * Get if the task is completed
  55625. */
  55626. readonly isCompleted: boolean;
  55627. /**
  55628. * Gets the current state of the task
  55629. */
  55630. readonly taskState: AssetTaskState;
  55631. /**
  55632. * Gets the current error object (if task is in error)
  55633. */
  55634. readonly errorObject: {
  55635. message?: string;
  55636. exception?: any;
  55637. };
  55638. /**
  55639. * Internal only
  55640. * @hidden
  55641. */
  55642. _setErrorObject(message?: string, exception?: any): void;
  55643. /**
  55644. * Execute the current task
  55645. * @param scene defines the scene where you want your assets to be loaded
  55646. * @param onSuccess is a callback called when the task is successfully executed
  55647. * @param onError is a callback called if an error occurs
  55648. */
  55649. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55650. /**
  55651. * Execute the current task
  55652. * @param scene defines the scene where you want your assets to be loaded
  55653. * @param onSuccess is a callback called when the task is successfully executed
  55654. * @param onError is a callback called if an error occurs
  55655. */
  55656. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55657. /**
  55658. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  55659. * This can be used with failed tasks that have the reason for failure fixed.
  55660. */
  55661. reset(): void;
  55662. private onErrorCallback;
  55663. private onDoneCallback;
  55664. }
  55665. /**
  55666. * Define the interface used by progress events raised during assets loading
  55667. */
  55668. export interface IAssetsProgressEvent {
  55669. /**
  55670. * Defines the number of remaining tasks to process
  55671. */
  55672. remainingCount: number;
  55673. /**
  55674. * Defines the total number of tasks
  55675. */
  55676. totalCount: number;
  55677. /**
  55678. * Defines the task that was just processed
  55679. */
  55680. task: AbstractAssetTask;
  55681. }
  55682. /**
  55683. * Class used to share progress information about assets loading
  55684. */
  55685. export class AssetsProgressEvent implements IAssetsProgressEvent {
  55686. /**
  55687. * Defines the number of remaining tasks to process
  55688. */
  55689. remainingCount: number;
  55690. /**
  55691. * Defines the total number of tasks
  55692. */
  55693. totalCount: number;
  55694. /**
  55695. * Defines the task that was just processed
  55696. */
  55697. task: AbstractAssetTask;
  55698. /**
  55699. * Creates a AssetsProgressEvent
  55700. * @param remainingCount defines the number of remaining tasks to process
  55701. * @param totalCount defines the total number of tasks
  55702. * @param task defines the task that was just processed
  55703. */
  55704. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  55705. }
  55706. /**
  55707. * Define a task used by AssetsManager to load meshes
  55708. */
  55709. export class MeshAssetTask extends AbstractAssetTask {
  55710. /**
  55711. * Defines the name of the task
  55712. */
  55713. name: string;
  55714. /**
  55715. * Defines the list of mesh's names you want to load
  55716. */
  55717. meshesNames: any;
  55718. /**
  55719. * Defines the root url to use as a base to load your meshes and associated resources
  55720. */
  55721. rootUrl: string;
  55722. /**
  55723. * Defines the filename of the scene to load from
  55724. */
  55725. sceneFilename: string;
  55726. /**
  55727. * Gets the list of loaded meshes
  55728. */
  55729. loadedMeshes: Array<AbstractMesh>;
  55730. /**
  55731. * Gets the list of loaded particle systems
  55732. */
  55733. loadedParticleSystems: Array<IParticleSystem>;
  55734. /**
  55735. * Gets the list of loaded skeletons
  55736. */
  55737. loadedSkeletons: Array<Skeleton>;
  55738. /**
  55739. * Gets the list of loaded animation groups
  55740. */
  55741. loadedAnimationGroups: Array<AnimationGroup>;
  55742. /**
  55743. * Callback called when the task is successful
  55744. */
  55745. onSuccess: (task: MeshAssetTask) => void;
  55746. /**
  55747. * Callback called when the task is successful
  55748. */
  55749. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  55750. /**
  55751. * Creates a new MeshAssetTask
  55752. * @param name defines the name of the task
  55753. * @param meshesNames defines the list of mesh's names you want to load
  55754. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  55755. * @param sceneFilename defines the filename of the scene to load from
  55756. */
  55757. constructor(
  55758. /**
  55759. * Defines the name of the task
  55760. */
  55761. name: string,
  55762. /**
  55763. * Defines the list of mesh's names you want to load
  55764. */
  55765. meshesNames: any,
  55766. /**
  55767. * Defines the root url to use as a base to load your meshes and associated resources
  55768. */
  55769. rootUrl: string,
  55770. /**
  55771. * Defines the filename of the scene to load from
  55772. */
  55773. sceneFilename: string);
  55774. /**
  55775. * Execute the current task
  55776. * @param scene defines the scene where you want your assets to be loaded
  55777. * @param onSuccess is a callback called when the task is successfully executed
  55778. * @param onError is a callback called if an error occurs
  55779. */
  55780. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55781. }
  55782. /**
  55783. * Define a task used by AssetsManager to load text content
  55784. */
  55785. export class TextFileAssetTask extends AbstractAssetTask {
  55786. /**
  55787. * Defines the name of the task
  55788. */
  55789. name: string;
  55790. /**
  55791. * Defines the location of the file to load
  55792. */
  55793. url: string;
  55794. /**
  55795. * Gets the loaded text string
  55796. */
  55797. text: string;
  55798. /**
  55799. * Callback called when the task is successful
  55800. */
  55801. onSuccess: (task: TextFileAssetTask) => void;
  55802. /**
  55803. * Callback called when the task is successful
  55804. */
  55805. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  55806. /**
  55807. * Creates a new TextFileAssetTask object
  55808. * @param name defines the name of the task
  55809. * @param url defines the location of the file to load
  55810. */
  55811. constructor(
  55812. /**
  55813. * Defines the name of the task
  55814. */
  55815. name: string,
  55816. /**
  55817. * Defines the location of the file to load
  55818. */
  55819. url: string);
  55820. /**
  55821. * Execute the current task
  55822. * @param scene defines the scene where you want your assets to be loaded
  55823. * @param onSuccess is a callback called when the task is successfully executed
  55824. * @param onError is a callback called if an error occurs
  55825. */
  55826. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55827. }
  55828. /**
  55829. * Define a task used by AssetsManager to load binary data
  55830. */
  55831. export class BinaryFileAssetTask extends AbstractAssetTask {
  55832. /**
  55833. * Defines the name of the task
  55834. */
  55835. name: string;
  55836. /**
  55837. * Defines the location of the file to load
  55838. */
  55839. url: string;
  55840. /**
  55841. * Gets the lodaded data (as an array buffer)
  55842. */
  55843. data: ArrayBuffer;
  55844. /**
  55845. * Callback called when the task is successful
  55846. */
  55847. onSuccess: (task: BinaryFileAssetTask) => void;
  55848. /**
  55849. * Callback called when the task is successful
  55850. */
  55851. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  55852. /**
  55853. * Creates a new BinaryFileAssetTask object
  55854. * @param name defines the name of the new task
  55855. * @param url defines the location of the file to load
  55856. */
  55857. constructor(
  55858. /**
  55859. * Defines the name of the task
  55860. */
  55861. name: string,
  55862. /**
  55863. * Defines the location of the file to load
  55864. */
  55865. url: string);
  55866. /**
  55867. * Execute the current task
  55868. * @param scene defines the scene where you want your assets to be loaded
  55869. * @param onSuccess is a callback called when the task is successfully executed
  55870. * @param onError is a callback called if an error occurs
  55871. */
  55872. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55873. }
  55874. /**
  55875. * Define a task used by AssetsManager to load images
  55876. */
  55877. export class ImageAssetTask extends AbstractAssetTask {
  55878. /**
  55879. * Defines the name of the task
  55880. */
  55881. name: string;
  55882. /**
  55883. * Defines the location of the image to load
  55884. */
  55885. url: string;
  55886. /**
  55887. * Gets the loaded images
  55888. */
  55889. image: HTMLImageElement;
  55890. /**
  55891. * Callback called when the task is successful
  55892. */
  55893. onSuccess: (task: ImageAssetTask) => void;
  55894. /**
  55895. * Callback called when the task is successful
  55896. */
  55897. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  55898. /**
  55899. * Creates a new ImageAssetTask
  55900. * @param name defines the name of the task
  55901. * @param url defines the location of the image to load
  55902. */
  55903. constructor(
  55904. /**
  55905. * Defines the name of the task
  55906. */
  55907. name: string,
  55908. /**
  55909. * Defines the location of the image to load
  55910. */
  55911. url: string);
  55912. /**
  55913. * Execute the current task
  55914. * @param scene defines the scene where you want your assets to be loaded
  55915. * @param onSuccess is a callback called when the task is successfully executed
  55916. * @param onError is a callback called if an error occurs
  55917. */
  55918. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55919. }
  55920. /**
  55921. * Defines the interface used by texture loading tasks
  55922. */
  55923. export interface ITextureAssetTask<TEX extends BaseTexture> {
  55924. /**
  55925. * Gets the loaded texture
  55926. */
  55927. texture: TEX;
  55928. }
  55929. /**
  55930. * Define a task used by AssetsManager to load 2D textures
  55931. */
  55932. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  55933. /**
  55934. * Defines the name of the task
  55935. */
  55936. name: string;
  55937. /**
  55938. * Defines the location of the file to load
  55939. */
  55940. url: string;
  55941. /**
  55942. * Defines if mipmap should not be generated (default is false)
  55943. */
  55944. noMipmap?: boolean | undefined;
  55945. /**
  55946. * Defines if texture must be inverted on Y axis (default is false)
  55947. */
  55948. invertY?: boolean | undefined;
  55949. /**
  55950. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  55951. */
  55952. samplingMode: number;
  55953. /**
  55954. * Gets the loaded texture
  55955. */
  55956. texture: Texture;
  55957. /**
  55958. * Callback called when the task is successful
  55959. */
  55960. onSuccess: (task: TextureAssetTask) => void;
  55961. /**
  55962. * Callback called when the task is successful
  55963. */
  55964. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  55965. /**
  55966. * Creates a new TextureAssetTask object
  55967. * @param name defines the name of the task
  55968. * @param url defines the location of the file to load
  55969. * @param noMipmap defines if mipmap should not be generated (default is false)
  55970. * @param invertY defines if texture must be inverted on Y axis (default is false)
  55971. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  55972. */
  55973. constructor(
  55974. /**
  55975. * Defines the name of the task
  55976. */
  55977. name: string,
  55978. /**
  55979. * Defines the location of the file to load
  55980. */
  55981. url: string,
  55982. /**
  55983. * Defines if mipmap should not be generated (default is false)
  55984. */
  55985. noMipmap?: boolean | undefined,
  55986. /**
  55987. * Defines if texture must be inverted on Y axis (default is false)
  55988. */
  55989. invertY?: boolean | undefined,
  55990. /**
  55991. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  55992. */
  55993. samplingMode?: number);
  55994. /**
  55995. * Execute the current task
  55996. * @param scene defines the scene where you want your assets to be loaded
  55997. * @param onSuccess is a callback called when the task is successfully executed
  55998. * @param onError is a callback called if an error occurs
  55999. */
  56000. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  56001. }
  56002. /**
  56003. * Define a task used by AssetsManager to load cube textures
  56004. */
  56005. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  56006. /**
  56007. * Defines the name of the task
  56008. */
  56009. name: string;
  56010. /**
  56011. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  56012. */
  56013. url: string;
  56014. /**
  56015. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  56016. */
  56017. extensions?: string[] | undefined;
  56018. /**
  56019. * Defines if mipmaps should not be generated (default is false)
  56020. */
  56021. noMipmap?: boolean | undefined;
  56022. /**
  56023. * Defines the explicit list of files (undefined by default)
  56024. */
  56025. files?: string[] | undefined;
  56026. /**
  56027. * Gets the loaded texture
  56028. */
  56029. texture: CubeTexture;
  56030. /**
  56031. * Callback called when the task is successful
  56032. */
  56033. onSuccess: (task: CubeTextureAssetTask) => void;
  56034. /**
  56035. * Callback called when the task is successful
  56036. */
  56037. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  56038. /**
  56039. * Creates a new CubeTextureAssetTask
  56040. * @param name defines the name of the task
  56041. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  56042. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  56043. * @param noMipmap defines if mipmaps should not be generated (default is false)
  56044. * @param files defines the explicit list of files (undefined by default)
  56045. */
  56046. constructor(
  56047. /**
  56048. * Defines the name of the task
  56049. */
  56050. name: string,
  56051. /**
  56052. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  56053. */
  56054. url: string,
  56055. /**
  56056. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  56057. */
  56058. extensions?: string[] | undefined,
  56059. /**
  56060. * Defines if mipmaps should not be generated (default is false)
  56061. */
  56062. noMipmap?: boolean | undefined,
  56063. /**
  56064. * Defines the explicit list of files (undefined by default)
  56065. */
  56066. files?: string[] | undefined);
  56067. /**
  56068. * Execute the current task
  56069. * @param scene defines the scene where you want your assets to be loaded
  56070. * @param onSuccess is a callback called when the task is successfully executed
  56071. * @param onError is a callback called if an error occurs
  56072. */
  56073. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  56074. }
  56075. /**
  56076. * Define a task used by AssetsManager to load HDR cube textures
  56077. */
  56078. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  56079. /**
  56080. * Defines the name of the task
  56081. */
  56082. name: string;
  56083. /**
  56084. * Defines the location of the file to load
  56085. */
  56086. url: string;
  56087. /**
  56088. * Defines the desired size (the more it increases the longer the generation will be)
  56089. */
  56090. size: number;
  56091. /**
  56092. * Defines if mipmaps should not be generated (default is false)
  56093. */
  56094. noMipmap: boolean;
  56095. /**
  56096. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  56097. */
  56098. generateHarmonics: boolean;
  56099. /**
  56100. * 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)
  56101. */
  56102. gammaSpace: boolean;
  56103. /**
  56104. * Internal Use Only
  56105. */
  56106. reserved: boolean;
  56107. /**
  56108. * Gets the loaded texture
  56109. */
  56110. texture: HDRCubeTexture;
  56111. /**
  56112. * Callback called when the task is successful
  56113. */
  56114. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  56115. /**
  56116. * Callback called when the task is successful
  56117. */
  56118. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  56119. /**
  56120. * Creates a new HDRCubeTextureAssetTask object
  56121. * @param name defines the name of the task
  56122. * @param url defines the location of the file to load
  56123. * @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.
  56124. * @param noMipmap defines if mipmaps should not be generated (default is false)
  56125. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  56126. * @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)
  56127. * @param reserved Internal use only
  56128. */
  56129. constructor(
  56130. /**
  56131. * Defines the name of the task
  56132. */
  56133. name: string,
  56134. /**
  56135. * Defines the location of the file to load
  56136. */
  56137. url: string,
  56138. /**
  56139. * Defines the desired size (the more it increases the longer the generation will be)
  56140. */
  56141. size: number,
  56142. /**
  56143. * Defines if mipmaps should not be generated (default is false)
  56144. */
  56145. noMipmap?: boolean,
  56146. /**
  56147. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  56148. */
  56149. generateHarmonics?: boolean,
  56150. /**
  56151. * 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)
  56152. */
  56153. gammaSpace?: boolean,
  56154. /**
  56155. * Internal Use Only
  56156. */
  56157. reserved?: boolean);
  56158. /**
  56159. * Execute the current task
  56160. * @param scene defines the scene where you want your assets to be loaded
  56161. * @param onSuccess is a callback called when the task is successfully executed
  56162. * @param onError is a callback called if an error occurs
  56163. */
  56164. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  56165. }
  56166. /**
  56167. * This class can be used to easily import assets into a scene
  56168. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  56169. */
  56170. export class AssetsManager {
  56171. private _scene;
  56172. private _isLoading;
  56173. protected _tasks: AbstractAssetTask[];
  56174. protected _waitingTasksCount: number;
  56175. protected _totalTasksCount: number;
  56176. /**
  56177. * Callback called when all tasks are processed
  56178. */
  56179. onFinish: (tasks: AbstractAssetTask[]) => void;
  56180. /**
  56181. * Callback called when a task is successful
  56182. */
  56183. onTaskSuccess: (task: AbstractAssetTask) => void;
  56184. /**
  56185. * Callback called when a task had an error
  56186. */
  56187. onTaskError: (task: AbstractAssetTask) => void;
  56188. /**
  56189. * Callback called when a task is done (whatever the result is)
  56190. */
  56191. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  56192. /**
  56193. * Observable called when all tasks are processed
  56194. */
  56195. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  56196. /**
  56197. * Observable called when a task had an error
  56198. */
  56199. onTaskErrorObservable: Observable<AbstractAssetTask>;
  56200. /**
  56201. * Observable called when all tasks were executed
  56202. */
  56203. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  56204. /**
  56205. * Observable called when a task is done (whatever the result is)
  56206. */
  56207. onProgressObservable: Observable<IAssetsProgressEvent>;
  56208. /**
  56209. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  56210. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  56211. */
  56212. useDefaultLoadingScreen: boolean;
  56213. /**
  56214. * Creates a new AssetsManager
  56215. * @param scene defines the scene to work on
  56216. */
  56217. constructor(scene: Scene);
  56218. /**
  56219. * Add a MeshAssetTask to the list of active tasks
  56220. * @param taskName defines the name of the new task
  56221. * @param meshesNames defines the name of meshes to load
  56222. * @param rootUrl defines the root url to use to locate files
  56223. * @param sceneFilename defines the filename of the scene file
  56224. * @returns a new MeshAssetTask object
  56225. */
  56226. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  56227. /**
  56228. * Add a TextFileAssetTask to the list of active tasks
  56229. * @param taskName defines the name of the new task
  56230. * @param url defines the url of the file to load
  56231. * @returns a new TextFileAssetTask object
  56232. */
  56233. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  56234. /**
  56235. * Add a BinaryFileAssetTask to the list of active tasks
  56236. * @param taskName defines the name of the new task
  56237. * @param url defines the url of the file to load
  56238. * @returns a new BinaryFileAssetTask object
  56239. */
  56240. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  56241. /**
  56242. * Add a ImageAssetTask to the list of active tasks
  56243. * @param taskName defines the name of the new task
  56244. * @param url defines the url of the file to load
  56245. * @returns a new ImageAssetTask object
  56246. */
  56247. addImageTask(taskName: string, url: string): ImageAssetTask;
  56248. /**
  56249. * Add a TextureAssetTask to the list of active tasks
  56250. * @param taskName defines the name of the new task
  56251. * @param url defines the url of the file to load
  56252. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  56253. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  56254. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  56255. * @returns a new TextureAssetTask object
  56256. */
  56257. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  56258. /**
  56259. * Add a CubeTextureAssetTask to the list of active tasks
  56260. * @param taskName defines the name of the new task
  56261. * @param url defines the url of the file to load
  56262. * @param extensions defines the extension to use to load the cube map (can be null)
  56263. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  56264. * @param files defines the list of files to load (can be null)
  56265. * @returns a new CubeTextureAssetTask object
  56266. */
  56267. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  56268. /**
  56269. *
  56270. * Add a HDRCubeTextureAssetTask to the list of active tasks
  56271. * @param taskName defines the name of the new task
  56272. * @param url defines the url of the file to load
  56273. * @param size defines the size you want for the cubemap (can be null)
  56274. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  56275. * @param generateHarmonics defines if you want to automatically generate (true by default)
  56276. * @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)
  56277. * @param reserved Internal use only
  56278. * @returns a new HDRCubeTextureAssetTask object
  56279. */
  56280. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  56281. /**
  56282. * Remove a task from the assets manager.
  56283. * @param task the task to remove
  56284. */
  56285. removeTask(task: AbstractAssetTask): void;
  56286. private _decreaseWaitingTasksCount;
  56287. private _runTask;
  56288. /**
  56289. * Reset the AssetsManager and remove all tasks
  56290. * @return the current instance of the AssetsManager
  56291. */
  56292. reset(): AssetsManager;
  56293. /**
  56294. * Start the loading process
  56295. * @return the current instance of the AssetsManager
  56296. */
  56297. load(): AssetsManager;
  56298. /**
  56299. * Start the loading process as an async operation
  56300. * @return a promise returning the list of failed tasks
  56301. */
  56302. loadAsync(): Promise<void>;
  56303. }
  56304. }
  56305. declare module "babylonjs/Misc/deferred" {
  56306. /**
  56307. * Wrapper class for promise with external resolve and reject.
  56308. */
  56309. export class Deferred<T> {
  56310. /**
  56311. * The promise associated with this deferred object.
  56312. */
  56313. readonly promise: Promise<T>;
  56314. private _resolve;
  56315. private _reject;
  56316. /**
  56317. * The resolve method of the promise associated with this deferred object.
  56318. */
  56319. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  56320. /**
  56321. * The reject method of the promise associated with this deferred object.
  56322. */
  56323. readonly reject: (reason?: any) => void;
  56324. /**
  56325. * Constructor for this deferred object.
  56326. */
  56327. constructor();
  56328. }
  56329. }
  56330. declare module "babylonjs/Misc/filesInput" {
  56331. import { Engine } from "babylonjs/Engines/engine";
  56332. import { Scene } from "babylonjs/scene";
  56333. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  56334. /**
  56335. * Class used to help managing file picking and drag'n'drop
  56336. */
  56337. export class FilesInput {
  56338. /**
  56339. * List of files ready to be loaded
  56340. */
  56341. static readonly FilesToLoad: {
  56342. [key: string]: File;
  56343. };
  56344. /**
  56345. * Callback called when a file is processed
  56346. */
  56347. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  56348. private _engine;
  56349. private _currentScene;
  56350. private _sceneLoadedCallback;
  56351. private _progressCallback;
  56352. private _additionalRenderLoopLogicCallback;
  56353. private _textureLoadingCallback;
  56354. private _startingProcessingFilesCallback;
  56355. private _onReloadCallback;
  56356. private _errorCallback;
  56357. private _elementToMonitor;
  56358. private _sceneFileToLoad;
  56359. private _filesToLoad;
  56360. /**
  56361. * Creates a new FilesInput
  56362. * @param engine defines the rendering engine
  56363. * @param scene defines the hosting scene
  56364. * @param sceneLoadedCallback callback called when scene is loaded
  56365. * @param progressCallback callback called to track progress
  56366. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  56367. * @param textureLoadingCallback callback called when a texture is loading
  56368. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  56369. * @param onReloadCallback callback called when a reload is requested
  56370. * @param errorCallback callback call if an error occurs
  56371. */
  56372. 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);
  56373. private _dragEnterHandler;
  56374. private _dragOverHandler;
  56375. private _dropHandler;
  56376. /**
  56377. * Calls this function to listen to drag'n'drop events on a specific DOM element
  56378. * @param elementToMonitor defines the DOM element to track
  56379. */
  56380. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  56381. /**
  56382. * Release all associated resources
  56383. */
  56384. dispose(): void;
  56385. private renderFunction;
  56386. private drag;
  56387. private drop;
  56388. private _traverseFolder;
  56389. private _processFiles;
  56390. /**
  56391. * Load files from a drop event
  56392. * @param event defines the drop event to use as source
  56393. */
  56394. loadFiles(event: any): void;
  56395. private _processReload;
  56396. /**
  56397. * Reload the current scene from the loaded files
  56398. */
  56399. reload(): void;
  56400. }
  56401. }
  56402. declare module "babylonjs/Misc/HighDynamicRange/index" {
  56403. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  56404. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  56405. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  56406. }
  56407. declare module "babylonjs/Misc/sceneOptimizer" {
  56408. import { Scene, IDisposable } from "babylonjs/scene";
  56409. import { Observable } from "babylonjs/Misc/observable";
  56410. /**
  56411. * Defines the root class used to create scene optimization to use with SceneOptimizer
  56412. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56413. */
  56414. export class SceneOptimization {
  56415. /**
  56416. * Defines the priority of this optimization (0 by default which means first in the list)
  56417. */
  56418. priority: number;
  56419. /**
  56420. * Gets a string describing the action executed by the current optimization
  56421. * @returns description string
  56422. */
  56423. getDescription(): string;
  56424. /**
  56425. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56426. * @param scene defines the current scene where to apply this optimization
  56427. * @param optimizer defines the current optimizer
  56428. * @returns true if everything that can be done was applied
  56429. */
  56430. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56431. /**
  56432. * Creates the SceneOptimization object
  56433. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  56434. * @param desc defines the description associated with the optimization
  56435. */
  56436. constructor(
  56437. /**
  56438. * Defines the priority of this optimization (0 by default which means first in the list)
  56439. */
  56440. priority?: number);
  56441. }
  56442. /**
  56443. * Defines an optimization used to reduce the size of render target textures
  56444. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56445. */
  56446. export class TextureOptimization extends SceneOptimization {
  56447. /**
  56448. * Defines the priority of this optimization (0 by default which means first in the list)
  56449. */
  56450. priority: number;
  56451. /**
  56452. * 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
  56453. */
  56454. maximumSize: number;
  56455. /**
  56456. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  56457. */
  56458. step: number;
  56459. /**
  56460. * Gets a string describing the action executed by the current optimization
  56461. * @returns description string
  56462. */
  56463. getDescription(): string;
  56464. /**
  56465. * Creates the TextureOptimization object
  56466. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  56467. * @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
  56468. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  56469. */
  56470. constructor(
  56471. /**
  56472. * Defines the priority of this optimization (0 by default which means first in the list)
  56473. */
  56474. priority?: number,
  56475. /**
  56476. * 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
  56477. */
  56478. maximumSize?: number,
  56479. /**
  56480. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  56481. */
  56482. step?: number);
  56483. /**
  56484. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56485. * @param scene defines the current scene where to apply this optimization
  56486. * @param optimizer defines the current optimizer
  56487. * @returns true if everything that can be done was applied
  56488. */
  56489. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56490. }
  56491. /**
  56492. * Defines an optimization used to increase or decrease the rendering resolution
  56493. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56494. */
  56495. export class HardwareScalingOptimization extends SceneOptimization {
  56496. /**
  56497. * Defines the priority of this optimization (0 by default which means first in the list)
  56498. */
  56499. priority: number;
  56500. /**
  56501. * Defines the maximum scale to use (2 by default)
  56502. */
  56503. maximumScale: number;
  56504. /**
  56505. * Defines the step to use between two passes (0.5 by default)
  56506. */
  56507. step: number;
  56508. private _currentScale;
  56509. private _directionOffset;
  56510. /**
  56511. * Gets a string describing the action executed by the current optimization
  56512. * @return description string
  56513. */
  56514. getDescription(): string;
  56515. /**
  56516. * Creates the HardwareScalingOptimization object
  56517. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  56518. * @param maximumScale defines the maximum scale to use (2 by default)
  56519. * @param step defines the step to use between two passes (0.5 by default)
  56520. */
  56521. constructor(
  56522. /**
  56523. * Defines the priority of this optimization (0 by default which means first in the list)
  56524. */
  56525. priority?: number,
  56526. /**
  56527. * Defines the maximum scale to use (2 by default)
  56528. */
  56529. maximumScale?: number,
  56530. /**
  56531. * Defines the step to use between two passes (0.5 by default)
  56532. */
  56533. step?: number);
  56534. /**
  56535. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56536. * @param scene defines the current scene where to apply this optimization
  56537. * @param optimizer defines the current optimizer
  56538. * @returns true if everything that can be done was applied
  56539. */
  56540. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56541. }
  56542. /**
  56543. * Defines an optimization used to remove shadows
  56544. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56545. */
  56546. export class ShadowsOptimization extends SceneOptimization {
  56547. /**
  56548. * Gets a string describing the action executed by the current optimization
  56549. * @return description string
  56550. */
  56551. getDescription(): string;
  56552. /**
  56553. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56554. * @param scene defines the current scene where to apply this optimization
  56555. * @param optimizer defines the current optimizer
  56556. * @returns true if everything that can be done was applied
  56557. */
  56558. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56559. }
  56560. /**
  56561. * Defines an optimization used to turn post-processes off
  56562. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56563. */
  56564. export class PostProcessesOptimization extends SceneOptimization {
  56565. /**
  56566. * Gets a string describing the action executed by the current optimization
  56567. * @return description string
  56568. */
  56569. getDescription(): string;
  56570. /**
  56571. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56572. * @param scene defines the current scene where to apply this optimization
  56573. * @param optimizer defines the current optimizer
  56574. * @returns true if everything that can be done was applied
  56575. */
  56576. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56577. }
  56578. /**
  56579. * Defines an optimization used to turn lens flares off
  56580. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56581. */
  56582. export class LensFlaresOptimization extends SceneOptimization {
  56583. /**
  56584. * Gets a string describing the action executed by the current optimization
  56585. * @return description string
  56586. */
  56587. getDescription(): string;
  56588. /**
  56589. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56590. * @param scene defines the current scene where to apply this optimization
  56591. * @param optimizer defines the current optimizer
  56592. * @returns true if everything that can be done was applied
  56593. */
  56594. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56595. }
  56596. /**
  56597. * Defines an optimization based on user defined callback.
  56598. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56599. */
  56600. export class CustomOptimization extends SceneOptimization {
  56601. /**
  56602. * Callback called to apply the custom optimization.
  56603. */
  56604. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  56605. /**
  56606. * Callback called to get custom description
  56607. */
  56608. onGetDescription: () => string;
  56609. /**
  56610. * Gets a string describing the action executed by the current optimization
  56611. * @returns description string
  56612. */
  56613. getDescription(): string;
  56614. /**
  56615. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56616. * @param scene defines the current scene where to apply this optimization
  56617. * @param optimizer defines the current optimizer
  56618. * @returns true if everything that can be done was applied
  56619. */
  56620. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56621. }
  56622. /**
  56623. * Defines an optimization used to turn particles off
  56624. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56625. */
  56626. export class ParticlesOptimization extends SceneOptimization {
  56627. /**
  56628. * Gets a string describing the action executed by the current optimization
  56629. * @return description string
  56630. */
  56631. getDescription(): string;
  56632. /**
  56633. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56634. * @param scene defines the current scene where to apply this optimization
  56635. * @param optimizer defines the current optimizer
  56636. * @returns true if everything that can be done was applied
  56637. */
  56638. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56639. }
  56640. /**
  56641. * Defines an optimization used to turn render targets off
  56642. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56643. */
  56644. export class RenderTargetsOptimization extends SceneOptimization {
  56645. /**
  56646. * Gets a string describing the action executed by the current optimization
  56647. * @return description string
  56648. */
  56649. getDescription(): string;
  56650. /**
  56651. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56652. * @param scene defines the current scene where to apply this optimization
  56653. * @param optimizer defines the current optimizer
  56654. * @returns true if everything that can be done was applied
  56655. */
  56656. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56657. }
  56658. /**
  56659. * Defines an optimization used to merge meshes with compatible materials
  56660. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56661. */
  56662. export class MergeMeshesOptimization extends SceneOptimization {
  56663. private static _UpdateSelectionTree;
  56664. /**
  56665. * Gets or sets a boolean which defines if optimization octree has to be updated
  56666. */
  56667. /**
  56668. * Gets or sets a boolean which defines if optimization octree has to be updated
  56669. */
  56670. static UpdateSelectionTree: boolean;
  56671. /**
  56672. * Gets a string describing the action executed by the current optimization
  56673. * @return description string
  56674. */
  56675. getDescription(): string;
  56676. private _canBeMerged;
  56677. /**
  56678. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56679. * @param scene defines the current scene where to apply this optimization
  56680. * @param optimizer defines the current optimizer
  56681. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  56682. * @returns true if everything that can be done was applied
  56683. */
  56684. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  56685. }
  56686. /**
  56687. * Defines a list of options used by SceneOptimizer
  56688. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56689. */
  56690. export class SceneOptimizerOptions {
  56691. /**
  56692. * Defines the target frame rate to reach (60 by default)
  56693. */
  56694. targetFrameRate: number;
  56695. /**
  56696. * Defines the interval between two checkes (2000ms by default)
  56697. */
  56698. trackerDuration: number;
  56699. /**
  56700. * Gets the list of optimizations to apply
  56701. */
  56702. optimizations: SceneOptimization[];
  56703. /**
  56704. * Creates a new list of options used by SceneOptimizer
  56705. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  56706. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  56707. */
  56708. constructor(
  56709. /**
  56710. * Defines the target frame rate to reach (60 by default)
  56711. */
  56712. targetFrameRate?: number,
  56713. /**
  56714. * Defines the interval between two checkes (2000ms by default)
  56715. */
  56716. trackerDuration?: number);
  56717. /**
  56718. * Add a new optimization
  56719. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  56720. * @returns the current SceneOptimizerOptions
  56721. */
  56722. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  56723. /**
  56724. * Add a new custom optimization
  56725. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  56726. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  56727. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  56728. * @returns the current SceneOptimizerOptions
  56729. */
  56730. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  56731. /**
  56732. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  56733. * @param targetFrameRate defines the target frame rate (60 by default)
  56734. * @returns a SceneOptimizerOptions object
  56735. */
  56736. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  56737. /**
  56738. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  56739. * @param targetFrameRate defines the target frame rate (60 by default)
  56740. * @returns a SceneOptimizerOptions object
  56741. */
  56742. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  56743. /**
  56744. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  56745. * @param targetFrameRate defines the target frame rate (60 by default)
  56746. * @returns a SceneOptimizerOptions object
  56747. */
  56748. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  56749. }
  56750. /**
  56751. * Class used to run optimizations in order to reach a target frame rate
  56752. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56753. */
  56754. export class SceneOptimizer implements IDisposable {
  56755. private _isRunning;
  56756. private _options;
  56757. private _scene;
  56758. private _currentPriorityLevel;
  56759. private _targetFrameRate;
  56760. private _trackerDuration;
  56761. private _currentFrameRate;
  56762. private _sceneDisposeObserver;
  56763. private _improvementMode;
  56764. /**
  56765. * Defines an observable called when the optimizer reaches the target frame rate
  56766. */
  56767. onSuccessObservable: Observable<SceneOptimizer>;
  56768. /**
  56769. * Defines an observable called when the optimizer enables an optimization
  56770. */
  56771. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  56772. /**
  56773. * Defines an observable called when the optimizer is not able to reach the target frame rate
  56774. */
  56775. onFailureObservable: Observable<SceneOptimizer>;
  56776. /**
  56777. * Gets a boolean indicating if the optimizer is in improvement mode
  56778. */
  56779. readonly isInImprovementMode: boolean;
  56780. /**
  56781. * Gets the current priority level (0 at start)
  56782. */
  56783. readonly currentPriorityLevel: number;
  56784. /**
  56785. * Gets the current frame rate checked by the SceneOptimizer
  56786. */
  56787. readonly currentFrameRate: number;
  56788. /**
  56789. * Gets or sets the current target frame rate (60 by default)
  56790. */
  56791. /**
  56792. * Gets or sets the current target frame rate (60 by default)
  56793. */
  56794. targetFrameRate: number;
  56795. /**
  56796. * Gets or sets the current interval between two checks (every 2000ms by default)
  56797. */
  56798. /**
  56799. * Gets or sets the current interval between two checks (every 2000ms by default)
  56800. */
  56801. trackerDuration: number;
  56802. /**
  56803. * Gets the list of active optimizations
  56804. */
  56805. readonly optimizations: SceneOptimization[];
  56806. /**
  56807. * Creates a new SceneOptimizer
  56808. * @param scene defines the scene to work on
  56809. * @param options defines the options to use with the SceneOptimizer
  56810. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  56811. * @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)
  56812. */
  56813. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  56814. /**
  56815. * Stops the current optimizer
  56816. */
  56817. stop(): void;
  56818. /**
  56819. * Reset the optimizer to initial step (current priority level = 0)
  56820. */
  56821. reset(): void;
  56822. /**
  56823. * Start the optimizer. By default it will try to reach a specific framerate
  56824. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  56825. */
  56826. start(): void;
  56827. private _checkCurrentState;
  56828. /**
  56829. * Release all resources
  56830. */
  56831. dispose(): void;
  56832. /**
  56833. * Helper function to create a SceneOptimizer with one single line of code
  56834. * @param scene defines the scene to work on
  56835. * @param options defines the options to use with the SceneOptimizer
  56836. * @param onSuccess defines a callback to call on success
  56837. * @param onFailure defines a callback to call on failure
  56838. * @returns the new SceneOptimizer object
  56839. */
  56840. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  56841. }
  56842. }
  56843. declare module "babylonjs/Misc/sceneSerializer" {
  56844. import { Scene } from "babylonjs/scene";
  56845. /**
  56846. * Class used to serialize a scene into a string
  56847. */
  56848. export class SceneSerializer {
  56849. /**
  56850. * Clear cache used by a previous serialization
  56851. */
  56852. static ClearCache(): void;
  56853. /**
  56854. * Serialize a scene into a JSON compatible object
  56855. * @param scene defines the scene to serialize
  56856. * @returns a JSON compatible object
  56857. */
  56858. static Serialize(scene: Scene): any;
  56859. /**
  56860. * Serialize a mesh into a JSON compatible object
  56861. * @param toSerialize defines the mesh to serialize
  56862. * @param withParents defines if parents must be serialized as well
  56863. * @param withChildren defines if children must be serialized as well
  56864. * @returns a JSON compatible object
  56865. */
  56866. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  56867. }
  56868. }
  56869. declare module "babylonjs/Misc/videoRecorder" {
  56870. import { Nullable } from "babylonjs/types";
  56871. import { Engine } from "babylonjs/Engines/engine";
  56872. /**
  56873. * This represents the different options avilable for the video capture.
  56874. */
  56875. export interface VideoRecorderOptions {
  56876. /** Defines the mime type of the video */
  56877. mimeType: string;
  56878. /** Defines the video the video should be recorded at */
  56879. fps: number;
  56880. /** Defines the chunk size for the recording data */
  56881. recordChunckSize: number;
  56882. /** The audio tracks to attach to the record */
  56883. audioTracks?: MediaStreamTrack[];
  56884. }
  56885. /**
  56886. * This can helps recording videos from BabylonJS.
  56887. * This is based on the available WebRTC functionalities of the browser.
  56888. *
  56889. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  56890. */
  56891. export class VideoRecorder {
  56892. private static readonly _defaultOptions;
  56893. /**
  56894. * Returns wehther or not the VideoRecorder is available in your browser.
  56895. * @param engine Defines the Babylon Engine to check the support for
  56896. * @returns true if supported otherwise false
  56897. */
  56898. static IsSupported(engine: Engine): boolean;
  56899. private readonly _options;
  56900. private _canvas;
  56901. private _mediaRecorder;
  56902. private _recordedChunks;
  56903. private _fileName;
  56904. private _resolve;
  56905. private _reject;
  56906. /**
  56907. * True wether a recording is already in progress.
  56908. */
  56909. readonly isRecording: boolean;
  56910. /**
  56911. * Create a new VideoCapture object which can help converting what you see in Babylon to
  56912. * a video file.
  56913. * @param engine Defines the BabylonJS Engine you wish to record
  56914. * @param options Defines options that can be used to customized the capture
  56915. */
  56916. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  56917. /**
  56918. * Stops the current recording before the default capture timeout passed in the startRecording
  56919. * functions.
  56920. */
  56921. stopRecording(): void;
  56922. /**
  56923. * Starts recording the canvas for a max duration specified in parameters.
  56924. * @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.
  56925. * @param maxDuration Defines the maximum recording time in seconds.
  56926. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  56927. * @return a promise callback at the end of the recording with the video data in Blob.
  56928. */
  56929. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  56930. /**
  56931. * Releases internal resources used during the recording.
  56932. */
  56933. dispose(): void;
  56934. private _handleDataAvailable;
  56935. private _handleError;
  56936. private _handleStop;
  56937. }
  56938. }
  56939. declare module "babylonjs/Misc/workerPool" {
  56940. import { IDisposable } from "babylonjs/scene";
  56941. /**
  56942. * Helper class to push actions to a pool of workers.
  56943. */
  56944. export class WorkerPool implements IDisposable {
  56945. private _workerInfos;
  56946. private _pendingActions;
  56947. /**
  56948. * Constructor
  56949. * @param workers Array of workers to use for actions
  56950. */
  56951. constructor(workers: Array<Worker>);
  56952. /**
  56953. * Terminates all workers and clears any pending actions.
  56954. */
  56955. dispose(): void;
  56956. /**
  56957. * Pushes an action to the worker pool. If all the workers are active, the action will be
  56958. * pended until a worker has completed its action.
  56959. * @param action The action to perform. Call onComplete when the action is complete.
  56960. */
  56961. push(action: (worker: Worker, onComplete: () => void) => void): void;
  56962. private _execute;
  56963. }
  56964. }
  56965. declare module "babylonjs/Misc/screenshotTools" {
  56966. import { Camera } from "babylonjs/Cameras/camera";
  56967. import { Engine } from "babylonjs/Engines/engine";
  56968. /**
  56969. * Class containing a set of static utilities functions for screenshots
  56970. */
  56971. export class ScreenshotTools {
  56972. /**
  56973. * Captures a screenshot of the current rendering
  56974. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  56975. * @param engine defines the rendering engine
  56976. * @param camera defines the source camera
  56977. * @param size This parameter can be set to a single number or to an object with the
  56978. * following (optional) properties: precision, width, height. If a single number is passed,
  56979. * it will be used for both width and height. If an object is passed, the screenshot size
  56980. * will be derived from the parameters. The precision property is a multiplier allowing
  56981. * rendering at a higher or lower resolution
  56982. * @param successCallback defines the callback receives a single parameter which contains the
  56983. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  56984. * src parameter of an <img> to display it
  56985. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  56986. * Check your browser for supported MIME types
  56987. */
  56988. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  56989. /**
  56990. * Generates an image screenshot from the specified camera.
  56991. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  56992. * @param engine The engine to use for rendering
  56993. * @param camera The camera to use for rendering
  56994. * @param size This parameter can be set to a single number or to an object with the
  56995. * following (optional) properties: precision, width, height. If a single number is passed,
  56996. * it will be used for both width and height. If an object is passed, the screenshot size
  56997. * will be derived from the parameters. The precision property is a multiplier allowing
  56998. * rendering at a higher or lower resolution
  56999. * @param successCallback The callback receives a single parameter which contains the
  57000. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  57001. * src parameter of an <img> to display it
  57002. * @param mimeType The MIME type of the screenshot image (default: image/png).
  57003. * Check your browser for supported MIME types
  57004. * @param samples Texture samples (default: 1)
  57005. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  57006. * @param fileName A name for for the downloaded file.
  57007. */
  57008. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  57009. }
  57010. }
  57011. declare module "babylonjs/Misc/index" {
  57012. export * from "babylonjs/Misc/andOrNotEvaluator";
  57013. export * from "babylonjs/Misc/assetsManager";
  57014. export * from "babylonjs/Misc/dds";
  57015. export * from "babylonjs/Misc/decorators";
  57016. export * from "babylonjs/Misc/deferred";
  57017. export * from "babylonjs/Misc/environmentTextureTools";
  57018. export * from "babylonjs/Misc/filesInput";
  57019. export * from "babylonjs/Misc/HighDynamicRange/index";
  57020. export * from "babylonjs/Misc/khronosTextureContainer";
  57021. export * from "babylonjs/Misc/observable";
  57022. export * from "babylonjs/Misc/performanceMonitor";
  57023. export * from "babylonjs/Misc/promise";
  57024. export * from "babylonjs/Misc/sceneOptimizer";
  57025. export * from "babylonjs/Misc/sceneSerializer";
  57026. export * from "babylonjs/Misc/smartArray";
  57027. export * from "babylonjs/Misc/stringDictionary";
  57028. export * from "babylonjs/Misc/tags";
  57029. export * from "babylonjs/Misc/textureTools";
  57030. export * from "babylonjs/Misc/tga";
  57031. export * from "babylonjs/Misc/tools";
  57032. export * from "babylonjs/Misc/videoRecorder";
  57033. export * from "babylonjs/Misc/virtualJoystick";
  57034. export * from "babylonjs/Misc/workerPool";
  57035. export * from "babylonjs/Misc/logger";
  57036. export * from "babylonjs/Misc/typeStore";
  57037. export * from "babylonjs/Misc/filesInputStore";
  57038. export * from "babylonjs/Misc/deepCopier";
  57039. export * from "babylonjs/Misc/pivotTools";
  57040. export * from "babylonjs/Misc/precisionDate";
  57041. export * from "babylonjs/Misc/screenshotTools";
  57042. export * from "babylonjs/Misc/typeStore";
  57043. }
  57044. declare module "babylonjs/index" {
  57045. export * from "babylonjs/abstractScene";
  57046. export * from "babylonjs/Actions/index";
  57047. export * from "babylonjs/Animations/index";
  57048. export * from "babylonjs/assetContainer";
  57049. export * from "babylonjs/Audio/index";
  57050. export * from "babylonjs/Behaviors/index";
  57051. export * from "babylonjs/Bones/index";
  57052. export * from "babylonjs/Cameras/index";
  57053. export * from "babylonjs/Collisions/index";
  57054. export * from "babylonjs/Culling/index";
  57055. export * from "babylonjs/Debug/index";
  57056. export * from "babylonjs/Engines/index";
  57057. export * from "babylonjs/Events/index";
  57058. export * from "babylonjs/Gamepads/index";
  57059. export * from "babylonjs/Gizmos/index";
  57060. export * from "babylonjs/Helpers/index";
  57061. export * from "babylonjs/Instrumentation/index";
  57062. export * from "babylonjs/Layers/index";
  57063. export * from "babylonjs/LensFlares/index";
  57064. export * from "babylonjs/Lights/index";
  57065. export * from "babylonjs/Loading/index";
  57066. export * from "babylonjs/Materials/index";
  57067. export * from "babylonjs/Maths/index";
  57068. export * from "babylonjs/Meshes/index";
  57069. export * from "babylonjs/Morph/index";
  57070. export * from "babylonjs/node";
  57071. export * from "babylonjs/Offline/index";
  57072. export * from "babylonjs/Particles/index";
  57073. export * from "babylonjs/Physics/index";
  57074. export * from "babylonjs/PostProcesses/index";
  57075. export * from "babylonjs/Probes/index";
  57076. export * from "babylonjs/Rendering/index";
  57077. export * from "babylonjs/scene";
  57078. export * from "babylonjs/sceneComponent";
  57079. export * from "babylonjs/Sprites/index";
  57080. export * from "babylonjs/States/index";
  57081. export * from "babylonjs/Misc/index";
  57082. export * from "babylonjs/types";
  57083. }
  57084. declare module "babylonjs/Animations/pathCursor" {
  57085. import { Path2, Vector3 } from "babylonjs/Maths/math";
  57086. /**
  57087. * A cursor which tracks a point on a path
  57088. */
  57089. export class PathCursor {
  57090. private path;
  57091. /**
  57092. * Stores path cursor callbacks for when an onchange event is triggered
  57093. */
  57094. private _onchange;
  57095. /**
  57096. * The value of the path cursor
  57097. */
  57098. value: number;
  57099. /**
  57100. * The animation array of the path cursor
  57101. */
  57102. animations: Animation[];
  57103. /**
  57104. * Initializes the path cursor
  57105. * @param path The path to track
  57106. */
  57107. constructor(path: Path2);
  57108. /**
  57109. * Gets the cursor point on the path
  57110. * @returns A point on the path cursor at the cursor location
  57111. */
  57112. getPoint(): Vector3;
  57113. /**
  57114. * Moves the cursor ahead by the step amount
  57115. * @param step The amount to move the cursor forward
  57116. * @returns This path cursor
  57117. */
  57118. moveAhead(step?: number): PathCursor;
  57119. /**
  57120. * Moves the cursor behind by the step amount
  57121. * @param step The amount to move the cursor back
  57122. * @returns This path cursor
  57123. */
  57124. moveBack(step?: number): PathCursor;
  57125. /**
  57126. * Moves the cursor by the step amount
  57127. * If the step amount is greater than one, an exception is thrown
  57128. * @param step The amount to move the cursor
  57129. * @returns This path cursor
  57130. */
  57131. move(step: number): PathCursor;
  57132. /**
  57133. * Ensures that the value is limited between zero and one
  57134. * @returns This path cursor
  57135. */
  57136. private ensureLimits;
  57137. /**
  57138. * Runs onchange callbacks on change (used by the animation engine)
  57139. * @returns This path cursor
  57140. */
  57141. private raiseOnChange;
  57142. /**
  57143. * Executes a function on change
  57144. * @param f A path cursor onchange callback
  57145. * @returns This path cursor
  57146. */
  57147. onchange(f: (cursor: PathCursor) => void): PathCursor;
  57148. }
  57149. }
  57150. declare module "babylonjs/Legacy/legacy" {
  57151. import * as Babylon from "babylonjs/index";
  57152. export * from "babylonjs/index";
  57153. }
  57154. declare module "babylonjs/Shaders/blur.fragment" {
  57155. /** @hidden */
  57156. export var blurPixelShader: {
  57157. name: string;
  57158. shader: string;
  57159. };
  57160. }
  57161. declare module "babylonjs/Shaders/ShadersInclude/bones300Declaration" {
  57162. /** @hidden */
  57163. export var bones300Declaration: {
  57164. name: string;
  57165. shader: string;
  57166. };
  57167. }
  57168. declare module "babylonjs/Shaders/ShadersInclude/instances300Declaration" {
  57169. /** @hidden */
  57170. export var instances300Declaration: {
  57171. name: string;
  57172. shader: string;
  57173. };
  57174. }
  57175. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  57176. /** @hidden */
  57177. export var pointCloudVertexDeclaration: {
  57178. name: string;
  57179. shader: string;
  57180. };
  57181. }
  57182. // Mixins
  57183. interface Window {
  57184. mozIndexedDB: IDBFactory;
  57185. webkitIndexedDB: IDBFactory;
  57186. msIndexedDB: IDBFactory;
  57187. webkitURL: typeof URL;
  57188. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  57189. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  57190. WebGLRenderingContext: WebGLRenderingContext;
  57191. MSGesture: MSGesture;
  57192. CANNON: any;
  57193. AudioContext: AudioContext;
  57194. webkitAudioContext: AudioContext;
  57195. PointerEvent: any;
  57196. Math: Math;
  57197. Uint8Array: Uint8ArrayConstructor;
  57198. Float32Array: Float32ArrayConstructor;
  57199. mozURL: typeof URL;
  57200. msURL: typeof URL;
  57201. VRFrameData: any; // WebVR, from specs 1.1
  57202. DracoDecoderModule: any;
  57203. setImmediate(handler: (...args: any[]) => void): number;
  57204. }
  57205. interface HTMLCanvasElement {
  57206. requestPointerLock(): void;
  57207. msRequestPointerLock?(): void;
  57208. mozRequestPointerLock?(): void;
  57209. webkitRequestPointerLock?(): void;
  57210. /** Track wether a record is in progress */
  57211. isRecording: boolean;
  57212. /** Capture Stream method defined by some browsers */
  57213. captureStream(fps?: number): MediaStream;
  57214. }
  57215. interface CanvasRenderingContext2D {
  57216. msImageSmoothingEnabled: boolean;
  57217. }
  57218. interface MouseEvent {
  57219. mozMovementX: number;
  57220. mozMovementY: number;
  57221. webkitMovementX: number;
  57222. webkitMovementY: number;
  57223. msMovementX: number;
  57224. msMovementY: number;
  57225. }
  57226. interface Navigator {
  57227. mozGetVRDevices: (any: any) => any;
  57228. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  57229. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  57230. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  57231. webkitGetGamepads(): Gamepad[];
  57232. msGetGamepads(): Gamepad[];
  57233. webkitGamepads(): Gamepad[];
  57234. }
  57235. interface HTMLVideoElement {
  57236. mozSrcObject: any;
  57237. }
  57238. interface Math {
  57239. fround(x: number): number;
  57240. imul(a: number, b: number): number;
  57241. }
  57242. interface WebGLProgram {
  57243. context?: WebGLRenderingContext;
  57244. vertexShader?: WebGLShader;
  57245. fragmentShader?: WebGLShader;
  57246. isParallelCompiled: boolean;
  57247. onCompiled?: () => void;
  57248. }
  57249. interface WebGLRenderingContext {
  57250. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  57251. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  57252. vertexAttribDivisor(index: number, divisor: number): void;
  57253. createVertexArray(): any;
  57254. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  57255. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  57256. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  57257. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  57258. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  57259. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  57260. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  57261. // Queries
  57262. createQuery(): WebGLQuery;
  57263. deleteQuery(query: WebGLQuery): void;
  57264. beginQuery(target: number, query: WebGLQuery): void;
  57265. endQuery(target: number): void;
  57266. getQueryParameter(query: WebGLQuery, pname: number): any;
  57267. getQuery(target: number, pname: number): any;
  57268. MAX_SAMPLES: number;
  57269. RGBA8: number;
  57270. READ_FRAMEBUFFER: number;
  57271. DRAW_FRAMEBUFFER: number;
  57272. UNIFORM_BUFFER: number;
  57273. HALF_FLOAT_OES: number;
  57274. RGBA16F: number;
  57275. RGBA32F: number;
  57276. R32F: number;
  57277. RG32F: number;
  57278. RGB32F: number;
  57279. R16F: number;
  57280. RG16F: number;
  57281. RGB16F: number;
  57282. RED: number;
  57283. RG: number;
  57284. R8: number;
  57285. RG8: number;
  57286. UNSIGNED_INT_24_8: number;
  57287. DEPTH24_STENCIL8: number;
  57288. /* Multiple Render Targets */
  57289. drawBuffers(buffers: number[]): void;
  57290. readBuffer(src: number): void;
  57291. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  57292. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  57293. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  57294. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  57295. // Occlusion Query
  57296. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  57297. ANY_SAMPLES_PASSED: number;
  57298. QUERY_RESULT_AVAILABLE: number;
  57299. QUERY_RESULT: number;
  57300. }
  57301. interface WebGLBuffer {
  57302. references: number;
  57303. capacity: number;
  57304. is32Bits: boolean;
  57305. }
  57306. interface WebGLProgram {
  57307. transformFeedback?: WebGLTransformFeedback | null;
  57308. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  57309. }
  57310. interface EXT_disjoint_timer_query {
  57311. QUERY_COUNTER_BITS_EXT: number;
  57312. TIME_ELAPSED_EXT: number;
  57313. TIMESTAMP_EXT: number;
  57314. GPU_DISJOINT_EXT: number;
  57315. QUERY_RESULT_EXT: number;
  57316. QUERY_RESULT_AVAILABLE_EXT: number;
  57317. queryCounterEXT(query: WebGLQuery, target: number): void;
  57318. createQueryEXT(): WebGLQuery;
  57319. beginQueryEXT(target: number, query: WebGLQuery): void;
  57320. endQueryEXT(target: number): void;
  57321. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  57322. deleteQueryEXT(query: WebGLQuery): void;
  57323. }
  57324. interface WebGLUniformLocation {
  57325. _currentState: any;
  57326. }
  57327. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  57328. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  57329. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  57330. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  57331. interface WebGLRenderingContext {
  57332. readonly RASTERIZER_DISCARD: number;
  57333. readonly DEPTH_COMPONENT24: number;
  57334. readonly TEXTURE_3D: number;
  57335. readonly TEXTURE_2D_ARRAY: number;
  57336. readonly TEXTURE_COMPARE_FUNC: number;
  57337. readonly TEXTURE_COMPARE_MODE: number;
  57338. readonly COMPARE_REF_TO_TEXTURE: number;
  57339. readonly TEXTURE_WRAP_R: number;
  57340. readonly HALF_FLOAT: number;
  57341. readonly RGB8: number;
  57342. readonly RED_INTEGER: number;
  57343. readonly RG_INTEGER: number;
  57344. readonly RGB_INTEGER: number;
  57345. readonly RGBA_INTEGER: number;
  57346. readonly R8_SNORM: number;
  57347. readonly RG8_SNORM: number;
  57348. readonly RGB8_SNORM: number;
  57349. readonly RGBA8_SNORM: number;
  57350. readonly R8I: number;
  57351. readonly RG8I: number;
  57352. readonly RGB8I: number;
  57353. readonly RGBA8I: number;
  57354. readonly R8UI: number;
  57355. readonly RG8UI: number;
  57356. readonly RGB8UI: number;
  57357. readonly RGBA8UI: number;
  57358. readonly R16I: number;
  57359. readonly RG16I: number;
  57360. readonly RGB16I: number;
  57361. readonly RGBA16I: number;
  57362. readonly R16UI: number;
  57363. readonly RG16UI: number;
  57364. readonly RGB16UI: number;
  57365. readonly RGBA16UI: number;
  57366. readonly R32I: number;
  57367. readonly RG32I: number;
  57368. readonly RGB32I: number;
  57369. readonly RGBA32I: number;
  57370. readonly R32UI: number;
  57371. readonly RG32UI: number;
  57372. readonly RGB32UI: number;
  57373. readonly RGBA32UI: number;
  57374. readonly RGB10_A2UI: number;
  57375. readonly R11F_G11F_B10F: number;
  57376. readonly RGB9_E5: number;
  57377. readonly RGB10_A2: number;
  57378. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  57379. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  57380. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  57381. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  57382. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  57383. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  57384. 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;
  57385. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  57386. readonly TRANSFORM_FEEDBACK: number;
  57387. readonly INTERLEAVED_ATTRIBS: number;
  57388. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  57389. createTransformFeedback(): WebGLTransformFeedback;
  57390. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  57391. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  57392. beginTransformFeedback(primitiveMode: number): void;
  57393. endTransformFeedback(): void;
  57394. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  57395. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  57396. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  57397. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  57398. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  57399. }
  57400. interface ImageBitmap {
  57401. readonly width: number;
  57402. readonly height: number;
  57403. close(): void;
  57404. }
  57405. interface WebGLQuery extends WebGLObject {
  57406. }
  57407. declare var WebGLQuery: {
  57408. prototype: WebGLQuery;
  57409. new(): WebGLQuery;
  57410. };
  57411. interface WebGLSampler extends WebGLObject {
  57412. }
  57413. declare var WebGLSampler: {
  57414. prototype: WebGLSampler;
  57415. new(): WebGLSampler;
  57416. };
  57417. interface WebGLSync extends WebGLObject {
  57418. }
  57419. declare var WebGLSync: {
  57420. prototype: WebGLSync;
  57421. new(): WebGLSync;
  57422. };
  57423. interface WebGLTransformFeedback extends WebGLObject {
  57424. }
  57425. declare var WebGLTransformFeedback: {
  57426. prototype: WebGLTransformFeedback;
  57427. new(): WebGLTransformFeedback;
  57428. };
  57429. interface WebGLVertexArrayObject extends WebGLObject {
  57430. }
  57431. declare var WebGLVertexArrayObject: {
  57432. prototype: WebGLVertexArrayObject;
  57433. new(): WebGLVertexArrayObject;
  57434. };
  57435. // Type definitions for WebVR API
  57436. // Project: https://w3c.github.io/webvr/
  57437. // Definitions by: six a <https://github.com/lostfictions>
  57438. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  57439. interface VRDisplay extends EventTarget {
  57440. /**
  57441. * Dictionary of capabilities describing the VRDisplay.
  57442. */
  57443. readonly capabilities: VRDisplayCapabilities;
  57444. /**
  57445. * z-depth defining the far plane of the eye view frustum
  57446. * enables mapping of values in the render target depth
  57447. * attachment to scene coordinates. Initially set to 10000.0.
  57448. */
  57449. depthFar: number;
  57450. /**
  57451. * z-depth defining the near plane of the eye view frustum
  57452. * enables mapping of values in the render target depth
  57453. * attachment to scene coordinates. Initially set to 0.01.
  57454. */
  57455. depthNear: number;
  57456. /**
  57457. * An identifier for this distinct VRDisplay. Used as an
  57458. * association point in the Gamepad API.
  57459. */
  57460. readonly displayId: number;
  57461. /**
  57462. * A display name, a user-readable name identifying it.
  57463. */
  57464. readonly displayName: string;
  57465. readonly isConnected: boolean;
  57466. readonly isPresenting: boolean;
  57467. /**
  57468. * If this VRDisplay supports room-scale experiences, the optional
  57469. * stage attribute contains details on the room-scale parameters.
  57470. */
  57471. readonly stageParameters: VRStageParameters | null;
  57472. /**
  57473. * Passing the value returned by `requestAnimationFrame` to
  57474. * `cancelAnimationFrame` will unregister the callback.
  57475. * @param handle Define the hanle of the request to cancel
  57476. */
  57477. cancelAnimationFrame(handle: number): void;
  57478. /**
  57479. * Stops presenting to the VRDisplay.
  57480. * @returns a promise to know when it stopped
  57481. */
  57482. exitPresent(): Promise<void>;
  57483. /**
  57484. * Return the current VREyeParameters for the given eye.
  57485. * @param whichEye Define the eye we want the parameter for
  57486. * @returns the eye parameters
  57487. */
  57488. getEyeParameters(whichEye: string): VREyeParameters;
  57489. /**
  57490. * Populates the passed VRFrameData with the information required to render
  57491. * the current frame.
  57492. * @param frameData Define the data structure to populate
  57493. * @returns true if ok otherwise false
  57494. */
  57495. getFrameData(frameData: VRFrameData): boolean;
  57496. /**
  57497. * Get the layers currently being presented.
  57498. * @returns the list of VR layers
  57499. */
  57500. getLayers(): VRLayer[];
  57501. /**
  57502. * Return a VRPose containing the future predicted pose of the VRDisplay
  57503. * when the current frame will be presented. The value returned will not
  57504. * change until JavaScript has returned control to the browser.
  57505. *
  57506. * The VRPose will contain the position, orientation, velocity,
  57507. * and acceleration of each of these properties.
  57508. * @returns the pose object
  57509. */
  57510. getPose(): VRPose;
  57511. /**
  57512. * Return the current instantaneous pose of the VRDisplay, with no
  57513. * prediction applied.
  57514. * @returns the current instantaneous pose
  57515. */
  57516. getImmediatePose(): VRPose;
  57517. /**
  57518. * The callback passed to `requestAnimationFrame` will be called
  57519. * any time a new frame should be rendered. When the VRDisplay is
  57520. * presenting the callback will be called at the native refresh
  57521. * rate of the HMD. When not presenting this function acts
  57522. * identically to how window.requestAnimationFrame acts. Content should
  57523. * make no assumptions of frame rate or vsync behavior as the HMD runs
  57524. * asynchronously from other displays and at differing refresh rates.
  57525. * @param callback Define the eaction to run next frame
  57526. * @returns the request handle it
  57527. */
  57528. requestAnimationFrame(callback: FrameRequestCallback): number;
  57529. /**
  57530. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  57531. * Repeat calls while already presenting will update the VRLayers being displayed.
  57532. * @param layers Define the list of layer to present
  57533. * @returns a promise to know when the request has been fulfilled
  57534. */
  57535. requestPresent(layers: VRLayer[]): Promise<void>;
  57536. /**
  57537. * Reset the pose for this display, treating its current position and
  57538. * orientation as the "origin/zero" values. VRPose.position,
  57539. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  57540. * updated when calling resetPose(). This should be called in only
  57541. * sitting-space experiences.
  57542. */
  57543. resetPose(): void;
  57544. /**
  57545. * The VRLayer provided to the VRDisplay will be captured and presented
  57546. * in the HMD. Calling this function has the same effect on the source
  57547. * canvas as any other operation that uses its source image, and canvases
  57548. * created without preserveDrawingBuffer set to true will be cleared.
  57549. * @param pose Define the pose to submit
  57550. */
  57551. submitFrame(pose?: VRPose): void;
  57552. }
  57553. declare var VRDisplay: {
  57554. prototype: VRDisplay;
  57555. new(): VRDisplay;
  57556. };
  57557. interface VRLayer {
  57558. leftBounds?: number[] | Float32Array | null;
  57559. rightBounds?: number[] | Float32Array | null;
  57560. source?: HTMLCanvasElement | null;
  57561. }
  57562. interface VRDisplayCapabilities {
  57563. readonly canPresent: boolean;
  57564. readonly hasExternalDisplay: boolean;
  57565. readonly hasOrientation: boolean;
  57566. readonly hasPosition: boolean;
  57567. readonly maxLayers: number;
  57568. }
  57569. interface VREyeParameters {
  57570. /** @deprecated */
  57571. readonly fieldOfView: VRFieldOfView;
  57572. readonly offset: Float32Array;
  57573. readonly renderHeight: number;
  57574. readonly renderWidth: number;
  57575. }
  57576. interface VRFieldOfView {
  57577. readonly downDegrees: number;
  57578. readonly leftDegrees: number;
  57579. readonly rightDegrees: number;
  57580. readonly upDegrees: number;
  57581. }
  57582. interface VRFrameData {
  57583. readonly leftProjectionMatrix: Float32Array;
  57584. readonly leftViewMatrix: Float32Array;
  57585. readonly pose: VRPose;
  57586. readonly rightProjectionMatrix: Float32Array;
  57587. readonly rightViewMatrix: Float32Array;
  57588. readonly timestamp: number;
  57589. }
  57590. interface VRPose {
  57591. readonly angularAcceleration: Float32Array | null;
  57592. readonly angularVelocity: Float32Array | null;
  57593. readonly linearAcceleration: Float32Array | null;
  57594. readonly linearVelocity: Float32Array | null;
  57595. readonly orientation: Float32Array | null;
  57596. readonly position: Float32Array | null;
  57597. readonly timestamp: number;
  57598. }
  57599. interface VRStageParameters {
  57600. sittingToStandingTransform?: Float32Array;
  57601. sizeX?: number;
  57602. sizeY?: number;
  57603. }
  57604. interface Navigator {
  57605. getVRDisplays(): Promise<VRDisplay[]>;
  57606. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  57607. }
  57608. interface Window {
  57609. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  57610. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  57611. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  57612. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  57613. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  57614. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  57615. }
  57616. interface Gamepad {
  57617. readonly displayId: number;
  57618. }
  57619. interface XRDevice {
  57620. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  57621. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  57622. }
  57623. interface XRSession {
  57624. getInputSources(): Array<any>;
  57625. baseLayer: XRWebGLLayer;
  57626. requestFrameOfReference(type: string): Promise<void>;
  57627. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  57628. end(): Promise<void>;
  57629. requestAnimationFrame: Function;
  57630. addEventListener: Function;
  57631. }
  57632. interface XRSessionCreationOptions {
  57633. outputContext?: WebGLRenderingContext | null;
  57634. immersive?: boolean;
  57635. environmentIntegration?: boolean;
  57636. }
  57637. interface XRLayer {
  57638. getViewport: Function;
  57639. framebufferWidth: number;
  57640. framebufferHeight: number;
  57641. }
  57642. interface XRView {
  57643. projectionMatrix: Float32Array;
  57644. }
  57645. interface XRFrame {
  57646. getDevicePose: Function;
  57647. getInputPose: Function;
  57648. views: Array<XRView>;
  57649. baseLayer: XRLayer;
  57650. }
  57651. interface XRFrameOfReference {
  57652. }
  57653. interface XRWebGLLayer extends XRLayer {
  57654. framebuffer: WebGLFramebuffer;
  57655. }
  57656. declare var XRWebGLLayer: {
  57657. prototype: XRWebGLLayer;
  57658. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  57659. };
  57660. declare module "babylonjs" {
  57661. export * from "babylonjs/Legacy/legacy";
  57662. }
  57663. declare module BABYLON {
  57664. /** Alias type for value that can be null */
  57665. export type Nullable<T> = T | null;
  57666. /**
  57667. * Alias type for number that are floats
  57668. * @ignorenaming
  57669. */
  57670. export type float = number;
  57671. /**
  57672. * Alias type for number that are doubles.
  57673. * @ignorenaming
  57674. */
  57675. export type double = number;
  57676. /**
  57677. * Alias type for number that are integer
  57678. * @ignorenaming
  57679. */
  57680. export type int = number;
  57681. /** Alias type for number array or Float32Array */
  57682. export type FloatArray = number[] | Float32Array;
  57683. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  57684. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  57685. /**
  57686. * Alias for types that can be used by a Buffer or VertexBuffer.
  57687. */
  57688. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  57689. /**
  57690. * Alias type for primitive types
  57691. * @ignorenaming
  57692. */
  57693. type Primitive = undefined | null | boolean | string | number | Function;
  57694. /**
  57695. * Type modifier to make all the properties of an object Readonly
  57696. */
  57697. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  57698. /**
  57699. * Type modifier to make all the properties of an object Readonly recursively
  57700. */
  57701. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  57702. /** @hidden */
  57703. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  57704. }
  57705. /** @hidden */
  57706. /** @hidden */
  57707. type DeepImmutableObject<T> = {
  57708. readonly [K in keyof T]: DeepImmutable<T[K]>;
  57709. };
  57710. }
  57711. declare module BABYLON {
  57712. /**
  57713. * Class containing a set of static utilities functions for arrays.
  57714. */
  57715. export class ArrayTools {
  57716. /**
  57717. * Returns an array of the given size filled with element built from the given constructor and the paramters
  57718. * @param size the number of element to construct and put in the array
  57719. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  57720. * @returns a new array filled with new objects
  57721. */
  57722. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  57723. }
  57724. }
  57725. declare module BABYLON {
  57726. /**
  57727. * Scalar computation library
  57728. */
  57729. export class Scalar {
  57730. /**
  57731. * Two pi constants convenient for computation.
  57732. */
  57733. static TwoPi: number;
  57734. /**
  57735. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  57736. * @param a number
  57737. * @param b number
  57738. * @param epsilon (default = 1.401298E-45)
  57739. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  57740. */
  57741. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  57742. /**
  57743. * Returns a string : the upper case translation of the number i to hexadecimal.
  57744. * @param i number
  57745. * @returns the upper case translation of the number i to hexadecimal.
  57746. */
  57747. static ToHex(i: number): string;
  57748. /**
  57749. * Returns -1 if value is negative and +1 is value is positive.
  57750. * @param value the value
  57751. * @returns the value itself if it's equal to zero.
  57752. */
  57753. static Sign(value: number): number;
  57754. /**
  57755. * Returns the value itself if it's between min and max.
  57756. * Returns min if the value is lower than min.
  57757. * Returns max if the value is greater than max.
  57758. * @param value the value to clmap
  57759. * @param min the min value to clamp to (default: 0)
  57760. * @param max the max value to clamp to (default: 1)
  57761. * @returns the clamped value
  57762. */
  57763. static Clamp(value: number, min?: number, max?: number): number;
  57764. /**
  57765. * the log2 of value.
  57766. * @param value the value to compute log2 of
  57767. * @returns the log2 of value.
  57768. */
  57769. static Log2(value: number): number;
  57770. /**
  57771. * Loops the value, so that it is never larger than length and never smaller than 0.
  57772. *
  57773. * This is similar to the modulo operator but it works with floating point numbers.
  57774. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  57775. * With t = 5 and length = 2.5, the result would be 0.0.
  57776. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  57777. * @param value the value
  57778. * @param length the length
  57779. * @returns the looped value
  57780. */
  57781. static Repeat(value: number, length: number): number;
  57782. /**
  57783. * Normalize the value between 0.0 and 1.0 using min and max values
  57784. * @param value value to normalize
  57785. * @param min max to normalize between
  57786. * @param max min to normalize between
  57787. * @returns the normalized value
  57788. */
  57789. static Normalize(value: number, min: number, max: number): number;
  57790. /**
  57791. * Denormalize the value from 0.0 and 1.0 using min and max values
  57792. * @param normalized value to denormalize
  57793. * @param min max to denormalize between
  57794. * @param max min to denormalize between
  57795. * @returns the denormalized value
  57796. */
  57797. static Denormalize(normalized: number, min: number, max: number): number;
  57798. /**
  57799. * Calculates the shortest difference between two given angles given in degrees.
  57800. * @param current current angle in degrees
  57801. * @param target target angle in degrees
  57802. * @returns the delta
  57803. */
  57804. static DeltaAngle(current: number, target: number): number;
  57805. /**
  57806. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  57807. * @param tx value
  57808. * @param length length
  57809. * @returns The returned value will move back and forth between 0 and length
  57810. */
  57811. static PingPong(tx: number, length: number): number;
  57812. /**
  57813. * Interpolates between min and max with smoothing at the limits.
  57814. *
  57815. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  57816. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  57817. * @param from from
  57818. * @param to to
  57819. * @param tx value
  57820. * @returns the smooth stepped value
  57821. */
  57822. static SmoothStep(from: number, to: number, tx: number): number;
  57823. /**
  57824. * Moves a value current towards target.
  57825. *
  57826. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  57827. * Negative values of maxDelta pushes the value away from target.
  57828. * @param current current value
  57829. * @param target target value
  57830. * @param maxDelta max distance to move
  57831. * @returns resulting value
  57832. */
  57833. static MoveTowards(current: number, target: number, maxDelta: number): number;
  57834. /**
  57835. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  57836. *
  57837. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  57838. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  57839. * @param current current value
  57840. * @param target target value
  57841. * @param maxDelta max distance to move
  57842. * @returns resulting angle
  57843. */
  57844. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  57845. /**
  57846. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  57847. * @param start start value
  57848. * @param end target value
  57849. * @param amount amount to lerp between
  57850. * @returns the lerped value
  57851. */
  57852. static Lerp(start: number, end: number, amount: number): number;
  57853. /**
  57854. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  57855. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  57856. * @param start start value
  57857. * @param end target value
  57858. * @param amount amount to lerp between
  57859. * @returns the lerped value
  57860. */
  57861. static LerpAngle(start: number, end: number, amount: number): number;
  57862. /**
  57863. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  57864. * @param a start value
  57865. * @param b target value
  57866. * @param value value between a and b
  57867. * @returns the inverseLerp value
  57868. */
  57869. static InverseLerp(a: number, b: number, value: number): number;
  57870. /**
  57871. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  57872. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  57873. * @param value1 spline value
  57874. * @param tangent1 spline value
  57875. * @param value2 spline value
  57876. * @param tangent2 spline value
  57877. * @param amount input value
  57878. * @returns hermite result
  57879. */
  57880. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  57881. /**
  57882. * Returns a random float number between and min and max values
  57883. * @param min min value of random
  57884. * @param max max value of random
  57885. * @returns random value
  57886. */
  57887. static RandomRange(min: number, max: number): number;
  57888. /**
  57889. * This function returns percentage of a number in a given range.
  57890. *
  57891. * RangeToPercent(40,20,60) will return 0.5 (50%)
  57892. * RangeToPercent(34,0,100) will return 0.34 (34%)
  57893. * @param number to convert to percentage
  57894. * @param min min range
  57895. * @param max max range
  57896. * @returns the percentage
  57897. */
  57898. static RangeToPercent(number: number, min: number, max: number): number;
  57899. /**
  57900. * This function returns number that corresponds to the percentage in a given range.
  57901. *
  57902. * PercentToRange(0.34,0,100) will return 34.
  57903. * @param percent to convert to number
  57904. * @param min min range
  57905. * @param max max range
  57906. * @returns the number
  57907. */
  57908. static PercentToRange(percent: number, min: number, max: number): number;
  57909. /**
  57910. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  57911. * @param angle The angle to normalize in radian.
  57912. * @return The converted angle.
  57913. */
  57914. static NormalizeRadians(angle: number): number;
  57915. }
  57916. }
  57917. declare module BABYLON {
  57918. /**
  57919. * Constant used to convert a value to gamma space
  57920. * @ignorenaming
  57921. */
  57922. export const ToGammaSpace: number;
  57923. /**
  57924. * Constant used to convert a value to linear space
  57925. * @ignorenaming
  57926. */
  57927. export const ToLinearSpace = 2.2;
  57928. /**
  57929. * Constant used to define the minimal number value in Babylon.js
  57930. * @ignorenaming
  57931. */
  57932. export const Epsilon = 0.001;
  57933. /**
  57934. * Class used to hold a RBG color
  57935. */
  57936. export class Color3 {
  57937. /**
  57938. * Defines the red component (between 0 and 1, default is 0)
  57939. */
  57940. r: number;
  57941. /**
  57942. * Defines the green component (between 0 and 1, default is 0)
  57943. */
  57944. g: number;
  57945. /**
  57946. * Defines the blue component (between 0 and 1, default is 0)
  57947. */
  57948. b: number;
  57949. /**
  57950. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  57951. * @param r defines the red component (between 0 and 1, default is 0)
  57952. * @param g defines the green component (between 0 and 1, default is 0)
  57953. * @param b defines the blue component (between 0 and 1, default is 0)
  57954. */
  57955. constructor(
  57956. /**
  57957. * Defines the red component (between 0 and 1, default is 0)
  57958. */
  57959. r?: number,
  57960. /**
  57961. * Defines the green component (between 0 and 1, default is 0)
  57962. */
  57963. g?: number,
  57964. /**
  57965. * Defines the blue component (between 0 and 1, default is 0)
  57966. */
  57967. b?: number);
  57968. /**
  57969. * Creates a string with the Color3 current values
  57970. * @returns the string representation of the Color3 object
  57971. */
  57972. toString(): string;
  57973. /**
  57974. * Returns the string "Color3"
  57975. * @returns "Color3"
  57976. */
  57977. getClassName(): string;
  57978. /**
  57979. * Compute the Color3 hash code
  57980. * @returns an unique number that can be used to hash Color3 objects
  57981. */
  57982. getHashCode(): number;
  57983. /**
  57984. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  57985. * @param array defines the array where to store the r,g,b components
  57986. * @param index defines an optional index in the target array to define where to start storing values
  57987. * @returns the current Color3 object
  57988. */
  57989. toArray(array: FloatArray, index?: number): Color3;
  57990. /**
  57991. * Returns a new Color4 object from the current Color3 and the given alpha
  57992. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  57993. * @returns a new Color4 object
  57994. */
  57995. toColor4(alpha?: number): Color4;
  57996. /**
  57997. * Returns a new array populated with 3 numeric elements : red, green and blue values
  57998. * @returns the new array
  57999. */
  58000. asArray(): number[];
  58001. /**
  58002. * Returns the luminance value
  58003. * @returns a float value
  58004. */
  58005. toLuminance(): number;
  58006. /**
  58007. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  58008. * @param otherColor defines the second operand
  58009. * @returns the new Color3 object
  58010. */
  58011. multiply(otherColor: DeepImmutable<Color3>): Color3;
  58012. /**
  58013. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  58014. * @param otherColor defines the second operand
  58015. * @param result defines the Color3 object where to store the result
  58016. * @returns the current Color3
  58017. */
  58018. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  58019. /**
  58020. * Determines equality between Color3 objects
  58021. * @param otherColor defines the second operand
  58022. * @returns true if the rgb values are equal to the given ones
  58023. */
  58024. equals(otherColor: DeepImmutable<Color3>): boolean;
  58025. /**
  58026. * Determines equality between the current Color3 object and a set of r,b,g values
  58027. * @param r defines the red component to check
  58028. * @param g defines the green component to check
  58029. * @param b defines the blue component to check
  58030. * @returns true if the rgb values are equal to the given ones
  58031. */
  58032. equalsFloats(r: number, g: number, b: number): boolean;
  58033. /**
  58034. * Multiplies in place each rgb value by scale
  58035. * @param scale defines the scaling factor
  58036. * @returns the updated Color3
  58037. */
  58038. scale(scale: number): Color3;
  58039. /**
  58040. * Multiplies the rgb values by scale and stores the result into "result"
  58041. * @param scale defines the scaling factor
  58042. * @param result defines the Color3 object where to store the result
  58043. * @returns the unmodified current Color3
  58044. */
  58045. scaleToRef(scale: number, result: Color3): Color3;
  58046. /**
  58047. * Scale the current Color3 values by a factor and add the result to a given Color3
  58048. * @param scale defines the scale factor
  58049. * @param result defines color to store the result into
  58050. * @returns the unmodified current Color3
  58051. */
  58052. scaleAndAddToRef(scale: number, result: Color3): Color3;
  58053. /**
  58054. * Clamps the rgb values by the min and max values and stores the result into "result"
  58055. * @param min defines minimum clamping value (default is 0)
  58056. * @param max defines maximum clamping value (default is 1)
  58057. * @param result defines color to store the result into
  58058. * @returns the original Color3
  58059. */
  58060. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  58061. /**
  58062. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  58063. * @param otherColor defines the second operand
  58064. * @returns the new Color3
  58065. */
  58066. add(otherColor: DeepImmutable<Color3>): Color3;
  58067. /**
  58068. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  58069. * @param otherColor defines the second operand
  58070. * @param result defines Color3 object to store the result into
  58071. * @returns the unmodified current Color3
  58072. */
  58073. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  58074. /**
  58075. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  58076. * @param otherColor defines the second operand
  58077. * @returns the new Color3
  58078. */
  58079. subtract(otherColor: DeepImmutable<Color3>): Color3;
  58080. /**
  58081. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  58082. * @param otherColor defines the second operand
  58083. * @param result defines Color3 object to store the result into
  58084. * @returns the unmodified current Color3
  58085. */
  58086. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  58087. /**
  58088. * Copy the current object
  58089. * @returns a new Color3 copied the current one
  58090. */
  58091. clone(): Color3;
  58092. /**
  58093. * Copies the rgb values from the source in the current Color3
  58094. * @param source defines the source Color3 object
  58095. * @returns the updated Color3 object
  58096. */
  58097. copyFrom(source: DeepImmutable<Color3>): Color3;
  58098. /**
  58099. * Updates the Color3 rgb values from the given floats
  58100. * @param r defines the red component to read from
  58101. * @param g defines the green component to read from
  58102. * @param b defines the blue component to read from
  58103. * @returns the current Color3 object
  58104. */
  58105. copyFromFloats(r: number, g: number, b: number): Color3;
  58106. /**
  58107. * Updates the Color3 rgb values from the given floats
  58108. * @param r defines the red component to read from
  58109. * @param g defines the green component to read from
  58110. * @param b defines the blue component to read from
  58111. * @returns the current Color3 object
  58112. */
  58113. set(r: number, g: number, b: number): Color3;
  58114. /**
  58115. * Compute the Color3 hexadecimal code as a string
  58116. * @returns a string containing the hexadecimal representation of the Color3 object
  58117. */
  58118. toHexString(): string;
  58119. /**
  58120. * Computes a new Color3 converted from the current one to linear space
  58121. * @returns a new Color3 object
  58122. */
  58123. toLinearSpace(): Color3;
  58124. /**
  58125. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  58126. * @param convertedColor defines the Color3 object where to store the linear space version
  58127. * @returns the unmodified Color3
  58128. */
  58129. toLinearSpaceToRef(convertedColor: Color3): Color3;
  58130. /**
  58131. * Computes a new Color3 converted from the current one to gamma space
  58132. * @returns a new Color3 object
  58133. */
  58134. toGammaSpace(): Color3;
  58135. /**
  58136. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  58137. * @param convertedColor defines the Color3 object where to store the gamma space version
  58138. * @returns the unmodified Color3
  58139. */
  58140. toGammaSpaceToRef(convertedColor: Color3): Color3;
  58141. private static _BlackReadOnly;
  58142. /**
  58143. * Creates a new Color3 from the string containing valid hexadecimal values
  58144. * @param hex defines a string containing valid hexadecimal values
  58145. * @returns a new Color3 object
  58146. */
  58147. static FromHexString(hex: string): Color3;
  58148. /**
  58149. * Creates a new Vector3 from the starting index of the given array
  58150. * @param array defines the source array
  58151. * @param offset defines an offset in the source array
  58152. * @returns a new Color3 object
  58153. */
  58154. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  58155. /**
  58156. * Creates a new Color3 from integer values (< 256)
  58157. * @param r defines the red component to read from (value between 0 and 255)
  58158. * @param g defines the green component to read from (value between 0 and 255)
  58159. * @param b defines the blue component to read from (value between 0 and 255)
  58160. * @returns a new Color3 object
  58161. */
  58162. static FromInts(r: number, g: number, b: number): Color3;
  58163. /**
  58164. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  58165. * @param start defines the start Color3 value
  58166. * @param end defines the end Color3 value
  58167. * @param amount defines the gradient value between start and end
  58168. * @returns a new Color3 object
  58169. */
  58170. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  58171. /**
  58172. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  58173. * @param left defines the start value
  58174. * @param right defines the end value
  58175. * @param amount defines the gradient factor
  58176. * @param result defines the Color3 object where to store the result
  58177. */
  58178. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  58179. /**
  58180. * Returns a Color3 value containing a red color
  58181. * @returns a new Color3 object
  58182. */
  58183. static Red(): Color3;
  58184. /**
  58185. * Returns a Color3 value containing a green color
  58186. * @returns a new Color3 object
  58187. */
  58188. static Green(): Color3;
  58189. /**
  58190. * Returns a Color3 value containing a blue color
  58191. * @returns a new Color3 object
  58192. */
  58193. static Blue(): Color3;
  58194. /**
  58195. * Returns a Color3 value containing a black color
  58196. * @returns a new Color3 object
  58197. */
  58198. static Black(): Color3;
  58199. /**
  58200. * Gets a Color3 value containing a black color that must not be updated
  58201. */
  58202. static readonly BlackReadOnly: DeepImmutable<Color3>;
  58203. /**
  58204. * Returns a Color3 value containing a white color
  58205. * @returns a new Color3 object
  58206. */
  58207. static White(): Color3;
  58208. /**
  58209. * Returns a Color3 value containing a purple color
  58210. * @returns a new Color3 object
  58211. */
  58212. static Purple(): Color3;
  58213. /**
  58214. * Returns a Color3 value containing a magenta color
  58215. * @returns a new Color3 object
  58216. */
  58217. static Magenta(): Color3;
  58218. /**
  58219. * Returns a Color3 value containing a yellow color
  58220. * @returns a new Color3 object
  58221. */
  58222. static Yellow(): Color3;
  58223. /**
  58224. * Returns a Color3 value containing a gray color
  58225. * @returns a new Color3 object
  58226. */
  58227. static Gray(): Color3;
  58228. /**
  58229. * Returns a Color3 value containing a teal color
  58230. * @returns a new Color3 object
  58231. */
  58232. static Teal(): Color3;
  58233. /**
  58234. * Returns a Color3 value containing a random color
  58235. * @returns a new Color3 object
  58236. */
  58237. static Random(): Color3;
  58238. }
  58239. /**
  58240. * Class used to hold a RBGA color
  58241. */
  58242. export class Color4 {
  58243. /**
  58244. * Defines the red component (between 0 and 1, default is 0)
  58245. */
  58246. r: number;
  58247. /**
  58248. * Defines the green component (between 0 and 1, default is 0)
  58249. */
  58250. g: number;
  58251. /**
  58252. * Defines the blue component (between 0 and 1, default is 0)
  58253. */
  58254. b: number;
  58255. /**
  58256. * Defines the alpha component (between 0 and 1, default is 1)
  58257. */
  58258. a: number;
  58259. /**
  58260. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  58261. * @param r defines the red component (between 0 and 1, default is 0)
  58262. * @param g defines the green component (between 0 and 1, default is 0)
  58263. * @param b defines the blue component (between 0 and 1, default is 0)
  58264. * @param a defines the alpha component (between 0 and 1, default is 1)
  58265. */
  58266. constructor(
  58267. /**
  58268. * Defines the red component (between 0 and 1, default is 0)
  58269. */
  58270. r?: number,
  58271. /**
  58272. * Defines the green component (between 0 and 1, default is 0)
  58273. */
  58274. g?: number,
  58275. /**
  58276. * Defines the blue component (between 0 and 1, default is 0)
  58277. */
  58278. b?: number,
  58279. /**
  58280. * Defines the alpha component (between 0 and 1, default is 1)
  58281. */
  58282. a?: number);
  58283. /**
  58284. * Adds in place the given Color4 values to the current Color4 object
  58285. * @param right defines the second operand
  58286. * @returns the current updated Color4 object
  58287. */
  58288. addInPlace(right: DeepImmutable<Color4>): Color4;
  58289. /**
  58290. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  58291. * @returns the new array
  58292. */
  58293. asArray(): number[];
  58294. /**
  58295. * Stores from the starting index in the given array the Color4 successive values
  58296. * @param array defines the array where to store the r,g,b components
  58297. * @param index defines an optional index in the target array to define where to start storing values
  58298. * @returns the current Color4 object
  58299. */
  58300. toArray(array: number[], index?: number): Color4;
  58301. /**
  58302. * Determines equality between Color4 objects
  58303. * @param otherColor defines the second operand
  58304. * @returns true if the rgba values are equal to the given ones
  58305. */
  58306. equals(otherColor: DeepImmutable<Color4>): boolean;
  58307. /**
  58308. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  58309. * @param right defines the second operand
  58310. * @returns a new Color4 object
  58311. */
  58312. add(right: DeepImmutable<Color4>): Color4;
  58313. /**
  58314. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  58315. * @param right defines the second operand
  58316. * @returns a new Color4 object
  58317. */
  58318. subtract(right: DeepImmutable<Color4>): Color4;
  58319. /**
  58320. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  58321. * @param right defines the second operand
  58322. * @param result defines the Color4 object where to store the result
  58323. * @returns the current Color4 object
  58324. */
  58325. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  58326. /**
  58327. * Creates a new Color4 with the current Color4 values multiplied by scale
  58328. * @param scale defines the scaling factor to apply
  58329. * @returns a new Color4 object
  58330. */
  58331. scale(scale: number): Color4;
  58332. /**
  58333. * Multiplies the current Color4 values by scale and stores the result in "result"
  58334. * @param scale defines the scaling factor to apply
  58335. * @param result defines the Color4 object where to store the result
  58336. * @returns the current unmodified Color4
  58337. */
  58338. scaleToRef(scale: number, result: Color4): Color4;
  58339. /**
  58340. * Scale the current Color4 values by a factor and add the result to a given Color4
  58341. * @param scale defines the scale factor
  58342. * @param result defines the Color4 object where to store the result
  58343. * @returns the unmodified current Color4
  58344. */
  58345. scaleAndAddToRef(scale: number, result: Color4): Color4;
  58346. /**
  58347. * Clamps the rgb values by the min and max values and stores the result into "result"
  58348. * @param min defines minimum clamping value (default is 0)
  58349. * @param max defines maximum clamping value (default is 1)
  58350. * @param result defines color to store the result into.
  58351. * @returns the cuurent Color4
  58352. */
  58353. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  58354. /**
  58355. * Multipy an Color4 value by another and return a new Color4 object
  58356. * @param color defines the Color4 value to multiply by
  58357. * @returns a new Color4 object
  58358. */
  58359. multiply(color: Color4): Color4;
  58360. /**
  58361. * Multipy a Color4 value by another and push the result in a reference value
  58362. * @param color defines the Color4 value to multiply by
  58363. * @param result defines the Color4 to fill the result in
  58364. * @returns the result Color4
  58365. */
  58366. multiplyToRef(color: Color4, result: Color4): Color4;
  58367. /**
  58368. * Creates a string with the Color4 current values
  58369. * @returns the string representation of the Color4 object
  58370. */
  58371. toString(): string;
  58372. /**
  58373. * Returns the string "Color4"
  58374. * @returns "Color4"
  58375. */
  58376. getClassName(): string;
  58377. /**
  58378. * Compute the Color4 hash code
  58379. * @returns an unique number that can be used to hash Color4 objects
  58380. */
  58381. getHashCode(): number;
  58382. /**
  58383. * Creates a new Color4 copied from the current one
  58384. * @returns a new Color4 object
  58385. */
  58386. clone(): Color4;
  58387. /**
  58388. * Copies the given Color4 values into the current one
  58389. * @param source defines the source Color4 object
  58390. * @returns the current updated Color4 object
  58391. */
  58392. copyFrom(source: Color4): Color4;
  58393. /**
  58394. * Copies the given float values into the current one
  58395. * @param r defines the red component to read from
  58396. * @param g defines the green component to read from
  58397. * @param b defines the blue component to read from
  58398. * @param a defines the alpha component to read from
  58399. * @returns the current updated Color4 object
  58400. */
  58401. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  58402. /**
  58403. * Copies the given float values into the current one
  58404. * @param r defines the red component to read from
  58405. * @param g defines the green component to read from
  58406. * @param b defines the blue component to read from
  58407. * @param a defines the alpha component to read from
  58408. * @returns the current updated Color4 object
  58409. */
  58410. set(r: number, g: number, b: number, a: number): Color4;
  58411. /**
  58412. * Compute the Color4 hexadecimal code as a string
  58413. * @returns a string containing the hexadecimal representation of the Color4 object
  58414. */
  58415. toHexString(): string;
  58416. /**
  58417. * Computes a new Color4 converted from the current one to linear space
  58418. * @returns a new Color4 object
  58419. */
  58420. toLinearSpace(): Color4;
  58421. /**
  58422. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  58423. * @param convertedColor defines the Color4 object where to store the linear space version
  58424. * @returns the unmodified Color4
  58425. */
  58426. toLinearSpaceToRef(convertedColor: Color4): Color4;
  58427. /**
  58428. * Computes a new Color4 converted from the current one to gamma space
  58429. * @returns a new Color4 object
  58430. */
  58431. toGammaSpace(): Color4;
  58432. /**
  58433. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  58434. * @param convertedColor defines the Color4 object where to store the gamma space version
  58435. * @returns the unmodified Color4
  58436. */
  58437. toGammaSpaceToRef(convertedColor: Color4): Color4;
  58438. /**
  58439. * Creates a new Color4 from the string containing valid hexadecimal values
  58440. * @param hex defines a string containing valid hexadecimal values
  58441. * @returns a new Color4 object
  58442. */
  58443. static FromHexString(hex: string): Color4;
  58444. /**
  58445. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  58446. * @param left defines the start value
  58447. * @param right defines the end value
  58448. * @param amount defines the gradient factor
  58449. * @returns a new Color4 object
  58450. */
  58451. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  58452. /**
  58453. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  58454. * @param left defines the start value
  58455. * @param right defines the end value
  58456. * @param amount defines the gradient factor
  58457. * @param result defines the Color4 object where to store data
  58458. */
  58459. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  58460. /**
  58461. * Creates a new Color4 from a Color3 and an alpha value
  58462. * @param color3 defines the source Color3 to read from
  58463. * @param alpha defines the alpha component (1.0 by default)
  58464. * @returns a new Color4 object
  58465. */
  58466. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  58467. /**
  58468. * Creates a new Color4 from the starting index element of the given array
  58469. * @param array defines the source array to read from
  58470. * @param offset defines the offset in the source array
  58471. * @returns a new Color4 object
  58472. */
  58473. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  58474. /**
  58475. * Creates a new Color3 from integer values (< 256)
  58476. * @param r defines the red component to read from (value between 0 and 255)
  58477. * @param g defines the green component to read from (value between 0 and 255)
  58478. * @param b defines the blue component to read from (value between 0 and 255)
  58479. * @param a defines the alpha component to read from (value between 0 and 255)
  58480. * @returns a new Color3 object
  58481. */
  58482. static FromInts(r: number, g: number, b: number, a: number): Color4;
  58483. /**
  58484. * Check the content of a given array and convert it to an array containing RGBA data
  58485. * If the original array was already containing count * 4 values then it is returned directly
  58486. * @param colors defines the array to check
  58487. * @param count defines the number of RGBA data to expect
  58488. * @returns an array containing count * 4 values (RGBA)
  58489. */
  58490. static CheckColors4(colors: number[], count: number): number[];
  58491. }
  58492. /**
  58493. * Class representing a vector containing 2 coordinates
  58494. */
  58495. export class Vector2 {
  58496. /** defines the first coordinate */
  58497. x: number;
  58498. /** defines the second coordinate */
  58499. y: number;
  58500. /**
  58501. * Creates a new Vector2 from the given x and y coordinates
  58502. * @param x defines the first coordinate
  58503. * @param y defines the second coordinate
  58504. */
  58505. constructor(
  58506. /** defines the first coordinate */
  58507. x?: number,
  58508. /** defines the second coordinate */
  58509. y?: number);
  58510. /**
  58511. * Gets a string with the Vector2 coordinates
  58512. * @returns a string with the Vector2 coordinates
  58513. */
  58514. toString(): string;
  58515. /**
  58516. * Gets class name
  58517. * @returns the string "Vector2"
  58518. */
  58519. getClassName(): string;
  58520. /**
  58521. * Gets current vector hash code
  58522. * @returns the Vector2 hash code as a number
  58523. */
  58524. getHashCode(): number;
  58525. /**
  58526. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  58527. * @param array defines the source array
  58528. * @param index defines the offset in source array
  58529. * @returns the current Vector2
  58530. */
  58531. toArray(array: FloatArray, index?: number): Vector2;
  58532. /**
  58533. * Copy the current vector to an array
  58534. * @returns a new array with 2 elements: the Vector2 coordinates.
  58535. */
  58536. asArray(): number[];
  58537. /**
  58538. * Sets the Vector2 coordinates with the given Vector2 coordinates
  58539. * @param source defines the source Vector2
  58540. * @returns the current updated Vector2
  58541. */
  58542. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  58543. /**
  58544. * Sets the Vector2 coordinates with the given floats
  58545. * @param x defines the first coordinate
  58546. * @param y defines the second coordinate
  58547. * @returns the current updated Vector2
  58548. */
  58549. copyFromFloats(x: number, y: number): Vector2;
  58550. /**
  58551. * Sets the Vector2 coordinates with the given floats
  58552. * @param x defines the first coordinate
  58553. * @param y defines the second coordinate
  58554. * @returns the current updated Vector2
  58555. */
  58556. set(x: number, y: number): Vector2;
  58557. /**
  58558. * Add another vector with the current one
  58559. * @param otherVector defines the other vector
  58560. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  58561. */
  58562. add(otherVector: DeepImmutable<Vector2>): Vector2;
  58563. /**
  58564. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  58565. * @param otherVector defines the other vector
  58566. * @param result defines the target vector
  58567. * @returns the unmodified current Vector2
  58568. */
  58569. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  58570. /**
  58571. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  58572. * @param otherVector defines the other vector
  58573. * @returns the current updated Vector2
  58574. */
  58575. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  58576. /**
  58577. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  58578. * @param otherVector defines the other vector
  58579. * @returns a new Vector2
  58580. */
  58581. addVector3(otherVector: Vector3): Vector2;
  58582. /**
  58583. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  58584. * @param otherVector defines the other vector
  58585. * @returns a new Vector2
  58586. */
  58587. subtract(otherVector: Vector2): Vector2;
  58588. /**
  58589. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  58590. * @param otherVector defines the other vector
  58591. * @param result defines the target vector
  58592. * @returns the unmodified current Vector2
  58593. */
  58594. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  58595. /**
  58596. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  58597. * @param otherVector defines the other vector
  58598. * @returns the current updated Vector2
  58599. */
  58600. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  58601. /**
  58602. * Multiplies in place the current Vector2 coordinates by the given ones
  58603. * @param otherVector defines the other vector
  58604. * @returns the current updated Vector2
  58605. */
  58606. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  58607. /**
  58608. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  58609. * @param otherVector defines the other vector
  58610. * @returns a new Vector2
  58611. */
  58612. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  58613. /**
  58614. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  58615. * @param otherVector defines the other vector
  58616. * @param result defines the target vector
  58617. * @returns the unmodified current Vector2
  58618. */
  58619. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  58620. /**
  58621. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  58622. * @param x defines the first coordinate
  58623. * @param y defines the second coordinate
  58624. * @returns a new Vector2
  58625. */
  58626. multiplyByFloats(x: number, y: number): Vector2;
  58627. /**
  58628. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  58629. * @param otherVector defines the other vector
  58630. * @returns a new Vector2
  58631. */
  58632. divide(otherVector: Vector2): Vector2;
  58633. /**
  58634. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  58635. * @param otherVector defines the other vector
  58636. * @param result defines the target vector
  58637. * @returns the unmodified current Vector2
  58638. */
  58639. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  58640. /**
  58641. * Divides the current Vector2 coordinates by the given ones
  58642. * @param otherVector defines the other vector
  58643. * @returns the current updated Vector2
  58644. */
  58645. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  58646. /**
  58647. * Gets a new Vector2 with current Vector2 negated coordinates
  58648. * @returns a new Vector2
  58649. */
  58650. negate(): Vector2;
  58651. /**
  58652. * Multiply the Vector2 coordinates by scale
  58653. * @param scale defines the scaling factor
  58654. * @returns the current updated Vector2
  58655. */
  58656. scaleInPlace(scale: number): Vector2;
  58657. /**
  58658. * Returns a new Vector2 scaled by "scale" from the current Vector2
  58659. * @param scale defines the scaling factor
  58660. * @returns a new Vector2
  58661. */
  58662. scale(scale: number): Vector2;
  58663. /**
  58664. * Scale the current Vector2 values by a factor to a given Vector2
  58665. * @param scale defines the scale factor
  58666. * @param result defines the Vector2 object where to store the result
  58667. * @returns the unmodified current Vector2
  58668. */
  58669. scaleToRef(scale: number, result: Vector2): Vector2;
  58670. /**
  58671. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  58672. * @param scale defines the scale factor
  58673. * @param result defines the Vector2 object where to store the result
  58674. * @returns the unmodified current Vector2
  58675. */
  58676. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  58677. /**
  58678. * Gets a boolean if two vectors are equals
  58679. * @param otherVector defines the other vector
  58680. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  58681. */
  58682. equals(otherVector: DeepImmutable<Vector2>): boolean;
  58683. /**
  58684. * Gets a boolean if two vectors are equals (using an epsilon value)
  58685. * @param otherVector defines the other vector
  58686. * @param epsilon defines the minimal distance to consider equality
  58687. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  58688. */
  58689. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  58690. /**
  58691. * Gets a new Vector2 from current Vector2 floored values
  58692. * @returns a new Vector2
  58693. */
  58694. floor(): Vector2;
  58695. /**
  58696. * Gets a new Vector2 from current Vector2 floored values
  58697. * @returns a new Vector2
  58698. */
  58699. fract(): Vector2;
  58700. /**
  58701. * Gets the length of the vector
  58702. * @returns the vector length (float)
  58703. */
  58704. length(): number;
  58705. /**
  58706. * Gets the vector squared length
  58707. * @returns the vector squared length (float)
  58708. */
  58709. lengthSquared(): number;
  58710. /**
  58711. * Normalize the vector
  58712. * @returns the current updated Vector2
  58713. */
  58714. normalize(): Vector2;
  58715. /**
  58716. * Gets a new Vector2 copied from the Vector2
  58717. * @returns a new Vector2
  58718. */
  58719. clone(): Vector2;
  58720. /**
  58721. * Gets a new Vector2(0, 0)
  58722. * @returns a new Vector2
  58723. */
  58724. static Zero(): Vector2;
  58725. /**
  58726. * Gets a new Vector2(1, 1)
  58727. * @returns a new Vector2
  58728. */
  58729. static One(): Vector2;
  58730. /**
  58731. * Gets a new Vector2 set from the given index element of the given array
  58732. * @param array defines the data source
  58733. * @param offset defines the offset in the data source
  58734. * @returns a new Vector2
  58735. */
  58736. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  58737. /**
  58738. * Sets "result" from the given index element of the given array
  58739. * @param array defines the data source
  58740. * @param offset defines the offset in the data source
  58741. * @param result defines the target vector
  58742. */
  58743. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  58744. /**
  58745. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  58746. * @param value1 defines 1st point of control
  58747. * @param value2 defines 2nd point of control
  58748. * @param value3 defines 3rd point of control
  58749. * @param value4 defines 4th point of control
  58750. * @param amount defines the interpolation factor
  58751. * @returns a new Vector2
  58752. */
  58753. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  58754. /**
  58755. * 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".
  58756. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  58757. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  58758. * @param value defines the value to clamp
  58759. * @param min defines the lower limit
  58760. * @param max defines the upper limit
  58761. * @returns a new Vector2
  58762. */
  58763. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  58764. /**
  58765. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  58766. * @param value1 defines the 1st control point
  58767. * @param tangent1 defines the outgoing tangent
  58768. * @param value2 defines the 2nd control point
  58769. * @param tangent2 defines the incoming tangent
  58770. * @param amount defines the interpolation factor
  58771. * @returns a new Vector2
  58772. */
  58773. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  58774. /**
  58775. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  58776. * @param start defines the start vector
  58777. * @param end defines the end vector
  58778. * @param amount defines the interpolation factor
  58779. * @returns a new Vector2
  58780. */
  58781. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  58782. /**
  58783. * Gets the dot product of the vector "left" and the vector "right"
  58784. * @param left defines first vector
  58785. * @param right defines second vector
  58786. * @returns the dot product (float)
  58787. */
  58788. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  58789. /**
  58790. * Returns a new Vector2 equal to the normalized given vector
  58791. * @param vector defines the vector to normalize
  58792. * @returns a new Vector2
  58793. */
  58794. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  58795. /**
  58796. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  58797. * @param left defines 1st vector
  58798. * @param right defines 2nd vector
  58799. * @returns a new Vector2
  58800. */
  58801. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  58802. /**
  58803. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  58804. * @param left defines 1st vector
  58805. * @param right defines 2nd vector
  58806. * @returns a new Vector2
  58807. */
  58808. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  58809. /**
  58810. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  58811. * @param vector defines the vector to transform
  58812. * @param transformation defines the matrix to apply
  58813. * @returns a new Vector2
  58814. */
  58815. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  58816. /**
  58817. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  58818. * @param vector defines the vector to transform
  58819. * @param transformation defines the matrix to apply
  58820. * @param result defines the target vector
  58821. */
  58822. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  58823. /**
  58824. * Determines if a given vector is included in a triangle
  58825. * @param p defines the vector to test
  58826. * @param p0 defines 1st triangle point
  58827. * @param p1 defines 2nd triangle point
  58828. * @param p2 defines 3rd triangle point
  58829. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  58830. */
  58831. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  58832. /**
  58833. * Gets the distance between the vectors "value1" and "value2"
  58834. * @param value1 defines first vector
  58835. * @param value2 defines second vector
  58836. * @returns the distance between vectors
  58837. */
  58838. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  58839. /**
  58840. * Returns the squared distance between the vectors "value1" and "value2"
  58841. * @param value1 defines first vector
  58842. * @param value2 defines second vector
  58843. * @returns the squared distance between vectors
  58844. */
  58845. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  58846. /**
  58847. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  58848. * @param value1 defines first vector
  58849. * @param value2 defines second vector
  58850. * @returns a new Vector2
  58851. */
  58852. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  58853. /**
  58854. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  58855. * @param p defines the middle point
  58856. * @param segA defines one point of the segment
  58857. * @param segB defines the other point of the segment
  58858. * @returns the shortest distance
  58859. */
  58860. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  58861. }
  58862. /**
  58863. * Classed used to store (x,y,z) vector representation
  58864. * A Vector3 is the main object used in 3D geometry
  58865. * It can represent etiher the coordinates of a point the space, either a direction
  58866. * Reminder: js uses a left handed forward facing system
  58867. */
  58868. export class Vector3 {
  58869. /**
  58870. * Defines the first coordinates (on X axis)
  58871. */
  58872. x: number;
  58873. /**
  58874. * Defines the second coordinates (on Y axis)
  58875. */
  58876. y: number;
  58877. /**
  58878. * Defines the third coordinates (on Z axis)
  58879. */
  58880. z: number;
  58881. private static _UpReadOnly;
  58882. /**
  58883. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  58884. * @param x defines the first coordinates (on X axis)
  58885. * @param y defines the second coordinates (on Y axis)
  58886. * @param z defines the third coordinates (on Z axis)
  58887. */
  58888. constructor(
  58889. /**
  58890. * Defines the first coordinates (on X axis)
  58891. */
  58892. x?: number,
  58893. /**
  58894. * Defines the second coordinates (on Y axis)
  58895. */
  58896. y?: number,
  58897. /**
  58898. * Defines the third coordinates (on Z axis)
  58899. */
  58900. z?: number);
  58901. /**
  58902. * Creates a string representation of the Vector3
  58903. * @returns a string with the Vector3 coordinates.
  58904. */
  58905. toString(): string;
  58906. /**
  58907. * Gets the class name
  58908. * @returns the string "Vector3"
  58909. */
  58910. getClassName(): string;
  58911. /**
  58912. * Creates the Vector3 hash code
  58913. * @returns a number which tends to be unique between Vector3 instances
  58914. */
  58915. getHashCode(): number;
  58916. /**
  58917. * Creates an array containing three elements : the coordinates of the Vector3
  58918. * @returns a new array of numbers
  58919. */
  58920. asArray(): number[];
  58921. /**
  58922. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  58923. * @param array defines the destination array
  58924. * @param index defines the offset in the destination array
  58925. * @returns the current Vector3
  58926. */
  58927. toArray(array: FloatArray, index?: number): Vector3;
  58928. /**
  58929. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  58930. * @returns a new Quaternion object, computed from the Vector3 coordinates
  58931. */
  58932. toQuaternion(): Quaternion;
  58933. /**
  58934. * Adds the given vector to the current Vector3
  58935. * @param otherVector defines the second operand
  58936. * @returns the current updated Vector3
  58937. */
  58938. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  58939. /**
  58940. * Adds the given coordinates to the current Vector3
  58941. * @param x defines the x coordinate of the operand
  58942. * @param y defines the y coordinate of the operand
  58943. * @param z defines the z coordinate of the operand
  58944. * @returns the current updated Vector3
  58945. */
  58946. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  58947. /**
  58948. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  58949. * @param otherVector defines the second operand
  58950. * @returns the resulting Vector3
  58951. */
  58952. add(otherVector: DeepImmutable<Vector3>): Vector3;
  58953. /**
  58954. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  58955. * @param otherVector defines the second operand
  58956. * @param result defines the Vector3 object where to store the result
  58957. * @returns the current Vector3
  58958. */
  58959. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  58960. /**
  58961. * Subtract the given vector from the current Vector3
  58962. * @param otherVector defines the second operand
  58963. * @returns the current updated Vector3
  58964. */
  58965. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  58966. /**
  58967. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  58968. * @param otherVector defines the second operand
  58969. * @returns the resulting Vector3
  58970. */
  58971. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  58972. /**
  58973. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  58974. * @param otherVector defines the second operand
  58975. * @param result defines the Vector3 object where to store the result
  58976. * @returns the current Vector3
  58977. */
  58978. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  58979. /**
  58980. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  58981. * @param x defines the x coordinate of the operand
  58982. * @param y defines the y coordinate of the operand
  58983. * @param z defines the z coordinate of the operand
  58984. * @returns the resulting Vector3
  58985. */
  58986. subtractFromFloats(x: number, y: number, z: number): Vector3;
  58987. /**
  58988. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  58989. * @param x defines the x coordinate of the operand
  58990. * @param y defines the y coordinate of the operand
  58991. * @param z defines the z coordinate of the operand
  58992. * @param result defines the Vector3 object where to store the result
  58993. * @returns the current Vector3
  58994. */
  58995. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  58996. /**
  58997. * Gets a new Vector3 set with the current Vector3 negated coordinates
  58998. * @returns a new Vector3
  58999. */
  59000. negate(): Vector3;
  59001. /**
  59002. * Multiplies the Vector3 coordinates by the float "scale"
  59003. * @param scale defines the multiplier factor
  59004. * @returns the current updated Vector3
  59005. */
  59006. scaleInPlace(scale: number): Vector3;
  59007. /**
  59008. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  59009. * @param scale defines the multiplier factor
  59010. * @returns a new Vector3
  59011. */
  59012. scale(scale: number): Vector3;
  59013. /**
  59014. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  59015. * @param scale defines the multiplier factor
  59016. * @param result defines the Vector3 object where to store the result
  59017. * @returns the current Vector3
  59018. */
  59019. scaleToRef(scale: number, result: Vector3): Vector3;
  59020. /**
  59021. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  59022. * @param scale defines the scale factor
  59023. * @param result defines the Vector3 object where to store the result
  59024. * @returns the unmodified current Vector3
  59025. */
  59026. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  59027. /**
  59028. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  59029. * @param otherVector defines the second operand
  59030. * @returns true if both vectors are equals
  59031. */
  59032. equals(otherVector: DeepImmutable<Vector3>): boolean;
  59033. /**
  59034. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  59035. * @param otherVector defines the second operand
  59036. * @param epsilon defines the minimal distance to define values as equals
  59037. * @returns true if both vectors are distant less than epsilon
  59038. */
  59039. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  59040. /**
  59041. * Returns true if the current Vector3 coordinates equals the given floats
  59042. * @param x defines the x coordinate of the operand
  59043. * @param y defines the y coordinate of the operand
  59044. * @param z defines the z coordinate of the operand
  59045. * @returns true if both vectors are equals
  59046. */
  59047. equalsToFloats(x: number, y: number, z: number): boolean;
  59048. /**
  59049. * Multiplies the current Vector3 coordinates by the given ones
  59050. * @param otherVector defines the second operand
  59051. * @returns the current updated Vector3
  59052. */
  59053. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  59054. /**
  59055. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  59056. * @param otherVector defines the second operand
  59057. * @returns the new Vector3
  59058. */
  59059. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  59060. /**
  59061. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  59062. * @param otherVector defines the second operand
  59063. * @param result defines the Vector3 object where to store the result
  59064. * @returns the current Vector3
  59065. */
  59066. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  59067. /**
  59068. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  59069. * @param x defines the x coordinate of the operand
  59070. * @param y defines the y coordinate of the operand
  59071. * @param z defines the z coordinate of the operand
  59072. * @returns the new Vector3
  59073. */
  59074. multiplyByFloats(x: number, y: number, z: number): Vector3;
  59075. /**
  59076. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  59077. * @param otherVector defines the second operand
  59078. * @returns the new Vector3
  59079. */
  59080. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  59081. /**
  59082. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  59083. * @param otherVector defines the second operand
  59084. * @param result defines the Vector3 object where to store the result
  59085. * @returns the current Vector3
  59086. */
  59087. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  59088. /**
  59089. * Divides the current Vector3 coordinates by the given ones.
  59090. * @param otherVector defines the second operand
  59091. * @returns the current updated Vector3
  59092. */
  59093. divideInPlace(otherVector: Vector3): Vector3;
  59094. /**
  59095. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  59096. * @param other defines the second operand
  59097. * @returns the current updated Vector3
  59098. */
  59099. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  59100. /**
  59101. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  59102. * @param other defines the second operand
  59103. * @returns the current updated Vector3
  59104. */
  59105. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  59106. /**
  59107. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  59108. * @param x defines the x coordinate of the operand
  59109. * @param y defines the y coordinate of the operand
  59110. * @param z defines the z coordinate of the operand
  59111. * @returns the current updated Vector3
  59112. */
  59113. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  59114. /**
  59115. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  59116. * @param x defines the x coordinate of the operand
  59117. * @param y defines the y coordinate of the operand
  59118. * @param z defines the z coordinate of the operand
  59119. * @returns the current updated Vector3
  59120. */
  59121. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  59122. /**
  59123. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  59124. * Check if is non uniform within a certain amount of decimal places to account for this
  59125. * @param epsilon the amount the values can differ
  59126. * @returns if the the vector is non uniform to a certain number of decimal places
  59127. */
  59128. isNonUniformWithinEpsilon(epsilon: number): boolean;
  59129. /**
  59130. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  59131. */
  59132. readonly isNonUniform: boolean;
  59133. /**
  59134. * Gets a new Vector3 from current Vector3 floored values
  59135. * @returns a new Vector3
  59136. */
  59137. floor(): Vector3;
  59138. /**
  59139. * Gets a new Vector3 from current Vector3 floored values
  59140. * @returns a new Vector3
  59141. */
  59142. fract(): Vector3;
  59143. /**
  59144. * Gets the length of the Vector3
  59145. * @returns the length of the Vecto3
  59146. */
  59147. length(): number;
  59148. /**
  59149. * Gets the squared length of the Vector3
  59150. * @returns squared length of the Vector3
  59151. */
  59152. lengthSquared(): number;
  59153. /**
  59154. * Normalize the current Vector3.
  59155. * Please note that this is an in place operation.
  59156. * @returns the current updated Vector3
  59157. */
  59158. normalize(): Vector3;
  59159. /**
  59160. * Reorders the x y z properties of the vector in place
  59161. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  59162. * @returns the current updated vector
  59163. */
  59164. reorderInPlace(order: string): this;
  59165. /**
  59166. * Rotates the vector around 0,0,0 by a quaternion
  59167. * @param quaternion the rotation quaternion
  59168. * @param result vector to store the result
  59169. * @returns the resulting vector
  59170. */
  59171. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  59172. /**
  59173. * Rotates a vector around a given point
  59174. * @param quaternion the rotation quaternion
  59175. * @param point the point to rotate around
  59176. * @param result vector to store the result
  59177. * @returns the resulting vector
  59178. */
  59179. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  59180. /**
  59181. * Normalize the current Vector3 with the given input length.
  59182. * Please note that this is an in place operation.
  59183. * @param len the length of the vector
  59184. * @returns the current updated Vector3
  59185. */
  59186. normalizeFromLength(len: number): Vector3;
  59187. /**
  59188. * Normalize the current Vector3 to a new vector
  59189. * @returns the new Vector3
  59190. */
  59191. normalizeToNew(): Vector3;
  59192. /**
  59193. * Normalize the current Vector3 to the reference
  59194. * @param reference define the Vector3 to update
  59195. * @returns the updated Vector3
  59196. */
  59197. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  59198. /**
  59199. * Creates a new Vector3 copied from the current Vector3
  59200. * @returns the new Vector3
  59201. */
  59202. clone(): Vector3;
  59203. /**
  59204. * Copies the given vector coordinates to the current Vector3 ones
  59205. * @param source defines the source Vector3
  59206. * @returns the current updated Vector3
  59207. */
  59208. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  59209. /**
  59210. * Copies the given floats to the current Vector3 coordinates
  59211. * @param x defines the x coordinate of the operand
  59212. * @param y defines the y coordinate of the operand
  59213. * @param z defines the z coordinate of the operand
  59214. * @returns the current updated Vector3
  59215. */
  59216. copyFromFloats(x: number, y: number, z: number): Vector3;
  59217. /**
  59218. * Copies the given floats to the current Vector3 coordinates
  59219. * @param x defines the x coordinate of the operand
  59220. * @param y defines the y coordinate of the operand
  59221. * @param z defines the z coordinate of the operand
  59222. * @returns the current updated Vector3
  59223. */
  59224. set(x: number, y: number, z: number): Vector3;
  59225. /**
  59226. * Copies the given float to the current Vector3 coordinates
  59227. * @param v defines the x, y and z coordinates of the operand
  59228. * @returns the current updated Vector3
  59229. */
  59230. setAll(v: number): Vector3;
  59231. /**
  59232. * Get the clip factor between two vectors
  59233. * @param vector0 defines the first operand
  59234. * @param vector1 defines the second operand
  59235. * @param axis defines the axis to use
  59236. * @param size defines the size along the axis
  59237. * @returns the clip factor
  59238. */
  59239. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  59240. /**
  59241. * Get angle between two vectors
  59242. * @param vector0 angle between vector0 and vector1
  59243. * @param vector1 angle between vector0 and vector1
  59244. * @param normal direction of the normal
  59245. * @return the angle between vector0 and vector1
  59246. */
  59247. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  59248. /**
  59249. * Returns a new Vector3 set from the index "offset" of the given array
  59250. * @param array defines the source array
  59251. * @param offset defines the offset in the source array
  59252. * @returns the new Vector3
  59253. */
  59254. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  59255. /**
  59256. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  59257. * This function is deprecated. Use FromArray instead
  59258. * @param array defines the source array
  59259. * @param offset defines the offset in the source array
  59260. * @returns the new Vector3
  59261. */
  59262. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  59263. /**
  59264. * Sets the given vector "result" with the element values from the index "offset" of the given array
  59265. * @param array defines the source array
  59266. * @param offset defines the offset in the source array
  59267. * @param result defines the Vector3 where to store the result
  59268. */
  59269. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  59270. /**
  59271. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  59272. * This function is deprecated. Use FromArrayToRef instead.
  59273. * @param array defines the source array
  59274. * @param offset defines the offset in the source array
  59275. * @param result defines the Vector3 where to store the result
  59276. */
  59277. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  59278. /**
  59279. * Sets the given vector "result" with the given floats.
  59280. * @param x defines the x coordinate of the source
  59281. * @param y defines the y coordinate of the source
  59282. * @param z defines the z coordinate of the source
  59283. * @param result defines the Vector3 where to store the result
  59284. */
  59285. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  59286. /**
  59287. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  59288. * @returns a new empty Vector3
  59289. */
  59290. static Zero(): Vector3;
  59291. /**
  59292. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  59293. * @returns a new unit Vector3
  59294. */
  59295. static One(): Vector3;
  59296. /**
  59297. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  59298. * @returns a new up Vector3
  59299. */
  59300. static Up(): Vector3;
  59301. /**
  59302. * Gets a up Vector3 that must not be updated
  59303. */
  59304. static readonly UpReadOnly: DeepImmutable<Vector3>;
  59305. /**
  59306. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  59307. * @returns a new down Vector3
  59308. */
  59309. static Down(): Vector3;
  59310. /**
  59311. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  59312. * @returns a new forward Vector3
  59313. */
  59314. static Forward(): Vector3;
  59315. /**
  59316. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  59317. * @returns a new forward Vector3
  59318. */
  59319. static Backward(): Vector3;
  59320. /**
  59321. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  59322. * @returns a new right Vector3
  59323. */
  59324. static Right(): Vector3;
  59325. /**
  59326. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  59327. * @returns a new left Vector3
  59328. */
  59329. static Left(): Vector3;
  59330. /**
  59331. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  59332. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  59333. * @param vector defines the Vector3 to transform
  59334. * @param transformation defines the transformation matrix
  59335. * @returns the transformed Vector3
  59336. */
  59337. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  59338. /**
  59339. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  59340. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  59341. * @param vector defines the Vector3 to transform
  59342. * @param transformation defines the transformation matrix
  59343. * @param result defines the Vector3 where to store the result
  59344. */
  59345. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  59346. /**
  59347. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  59348. * This method computes tranformed coordinates only, not transformed direction vectors
  59349. * @param x define the x coordinate of the source vector
  59350. * @param y define the y coordinate of the source vector
  59351. * @param z define the z coordinate of the source vector
  59352. * @param transformation defines the transformation matrix
  59353. * @param result defines the Vector3 where to store the result
  59354. */
  59355. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  59356. /**
  59357. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  59358. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  59359. * @param vector defines the Vector3 to transform
  59360. * @param transformation defines the transformation matrix
  59361. * @returns the new Vector3
  59362. */
  59363. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  59364. /**
  59365. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  59366. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  59367. * @param vector defines the Vector3 to transform
  59368. * @param transformation defines the transformation matrix
  59369. * @param result defines the Vector3 where to store the result
  59370. */
  59371. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  59372. /**
  59373. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  59374. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  59375. * @param x define the x coordinate of the source vector
  59376. * @param y define the y coordinate of the source vector
  59377. * @param z define the z coordinate of the source vector
  59378. * @param transformation defines the transformation matrix
  59379. * @param result defines the Vector3 where to store the result
  59380. */
  59381. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  59382. /**
  59383. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  59384. * @param value1 defines the first control point
  59385. * @param value2 defines the second control point
  59386. * @param value3 defines the third control point
  59387. * @param value4 defines the fourth control point
  59388. * @param amount defines the amount on the spline to use
  59389. * @returns the new Vector3
  59390. */
  59391. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  59392. /**
  59393. * 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"
  59394. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  59395. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  59396. * @param value defines the current value
  59397. * @param min defines the lower range value
  59398. * @param max defines the upper range value
  59399. * @returns the new Vector3
  59400. */
  59401. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  59402. /**
  59403. * 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"
  59404. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  59405. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  59406. * @param value defines the current value
  59407. * @param min defines the lower range value
  59408. * @param max defines the upper range value
  59409. * @param result defines the Vector3 where to store the result
  59410. */
  59411. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  59412. /**
  59413. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  59414. * @param value1 defines the first control point
  59415. * @param tangent1 defines the first tangent vector
  59416. * @param value2 defines the second control point
  59417. * @param tangent2 defines the second tangent vector
  59418. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  59419. * @returns the new Vector3
  59420. */
  59421. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  59422. /**
  59423. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  59424. * @param start defines the start value
  59425. * @param end defines the end value
  59426. * @param amount max defines amount between both (between 0 and 1)
  59427. * @returns the new Vector3
  59428. */
  59429. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  59430. /**
  59431. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  59432. * @param start defines the start value
  59433. * @param end defines the end value
  59434. * @param amount max defines amount between both (between 0 and 1)
  59435. * @param result defines the Vector3 where to store the result
  59436. */
  59437. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  59438. /**
  59439. * Returns the dot product (float) between the vectors "left" and "right"
  59440. * @param left defines the left operand
  59441. * @param right defines the right operand
  59442. * @returns the dot product
  59443. */
  59444. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  59445. /**
  59446. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  59447. * The cross product is then orthogonal to both "left" and "right"
  59448. * @param left defines the left operand
  59449. * @param right defines the right operand
  59450. * @returns the cross product
  59451. */
  59452. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  59453. /**
  59454. * Sets the given vector "result" with the cross product of "left" and "right"
  59455. * The cross product is then orthogonal to both "left" and "right"
  59456. * @param left defines the left operand
  59457. * @param right defines the right operand
  59458. * @param result defines the Vector3 where to store the result
  59459. */
  59460. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  59461. /**
  59462. * Returns a new Vector3 as the normalization of the given vector
  59463. * @param vector defines the Vector3 to normalize
  59464. * @returns the new Vector3
  59465. */
  59466. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  59467. /**
  59468. * Sets the given vector "result" with the normalization of the given first vector
  59469. * @param vector defines the Vector3 to normalize
  59470. * @param result defines the Vector3 where to store the result
  59471. */
  59472. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  59473. /**
  59474. * Project a Vector3 onto screen space
  59475. * @param vector defines the Vector3 to project
  59476. * @param world defines the world matrix to use
  59477. * @param transform defines the transform (view x projection) matrix to use
  59478. * @param viewport defines the screen viewport to use
  59479. * @returns the new Vector3
  59480. */
  59481. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  59482. /** @hidden */
  59483. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  59484. /**
  59485. * Unproject from screen space to object space
  59486. * @param source defines the screen space Vector3 to use
  59487. * @param viewportWidth defines the current width of the viewport
  59488. * @param viewportHeight defines the current height of the viewport
  59489. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  59490. * @param transform defines the transform (view x projection) matrix to use
  59491. * @returns the new Vector3
  59492. */
  59493. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  59494. /**
  59495. * Unproject from screen space to object space
  59496. * @param source defines the screen space Vector3 to use
  59497. * @param viewportWidth defines the current width of the viewport
  59498. * @param viewportHeight defines the current height of the viewport
  59499. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  59500. * @param view defines the view matrix to use
  59501. * @param projection defines the projection matrix to use
  59502. * @returns the new Vector3
  59503. */
  59504. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  59505. /**
  59506. * Unproject from screen space to object space
  59507. * @param source defines the screen space Vector3 to use
  59508. * @param viewportWidth defines the current width of the viewport
  59509. * @param viewportHeight defines the current height of the viewport
  59510. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  59511. * @param view defines the view matrix to use
  59512. * @param projection defines the projection matrix to use
  59513. * @param result defines the Vector3 where to store the result
  59514. */
  59515. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  59516. /**
  59517. * Unproject from screen space to object space
  59518. * @param sourceX defines the screen space x coordinate to use
  59519. * @param sourceY defines the screen space y coordinate to use
  59520. * @param sourceZ defines the screen space z coordinate to use
  59521. * @param viewportWidth defines the current width of the viewport
  59522. * @param viewportHeight defines the current height of the viewport
  59523. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  59524. * @param view defines the view matrix to use
  59525. * @param projection defines the projection matrix to use
  59526. * @param result defines the Vector3 where to store the result
  59527. */
  59528. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  59529. /**
  59530. * Gets the minimal coordinate values between two Vector3
  59531. * @param left defines the first operand
  59532. * @param right defines the second operand
  59533. * @returns the new Vector3
  59534. */
  59535. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  59536. /**
  59537. * Gets the maximal coordinate values between two Vector3
  59538. * @param left defines the first operand
  59539. * @param right defines the second operand
  59540. * @returns the new Vector3
  59541. */
  59542. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  59543. /**
  59544. * Returns the distance between the vectors "value1" and "value2"
  59545. * @param value1 defines the first operand
  59546. * @param value2 defines the second operand
  59547. * @returns the distance
  59548. */
  59549. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  59550. /**
  59551. * Returns the squared distance between the vectors "value1" and "value2"
  59552. * @param value1 defines the first operand
  59553. * @param value2 defines the second operand
  59554. * @returns the squared distance
  59555. */
  59556. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  59557. /**
  59558. * Returns a new Vector3 located at the center between "value1" and "value2"
  59559. * @param value1 defines the first operand
  59560. * @param value2 defines the second operand
  59561. * @returns the new Vector3
  59562. */
  59563. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  59564. /**
  59565. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  59566. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  59567. * to something in order to rotate it from its local system to the given target system
  59568. * Note: axis1, axis2 and axis3 are normalized during this operation
  59569. * @param axis1 defines the first axis
  59570. * @param axis2 defines the second axis
  59571. * @param axis3 defines the third axis
  59572. * @returns a new Vector3
  59573. */
  59574. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  59575. /**
  59576. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  59577. * @param axis1 defines the first axis
  59578. * @param axis2 defines the second axis
  59579. * @param axis3 defines the third axis
  59580. * @param ref defines the Vector3 where to store the result
  59581. */
  59582. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  59583. }
  59584. /**
  59585. * Vector4 class created for EulerAngle class conversion to Quaternion
  59586. */
  59587. export class Vector4 {
  59588. /** x value of the vector */
  59589. x: number;
  59590. /** y value of the vector */
  59591. y: number;
  59592. /** z value of the vector */
  59593. z: number;
  59594. /** w value of the vector */
  59595. w: number;
  59596. /**
  59597. * Creates a Vector4 object from the given floats.
  59598. * @param x x value of the vector
  59599. * @param y y value of the vector
  59600. * @param z z value of the vector
  59601. * @param w w value of the vector
  59602. */
  59603. constructor(
  59604. /** x value of the vector */
  59605. x: number,
  59606. /** y value of the vector */
  59607. y: number,
  59608. /** z value of the vector */
  59609. z: number,
  59610. /** w value of the vector */
  59611. w: number);
  59612. /**
  59613. * Returns the string with the Vector4 coordinates.
  59614. * @returns a string containing all the vector values
  59615. */
  59616. toString(): string;
  59617. /**
  59618. * Returns the string "Vector4".
  59619. * @returns "Vector4"
  59620. */
  59621. getClassName(): string;
  59622. /**
  59623. * Returns the Vector4 hash code.
  59624. * @returns a unique hash code
  59625. */
  59626. getHashCode(): number;
  59627. /**
  59628. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  59629. * @returns the resulting array
  59630. */
  59631. asArray(): number[];
  59632. /**
  59633. * Populates the given array from the given index with the Vector4 coordinates.
  59634. * @param array array to populate
  59635. * @param index index of the array to start at (default: 0)
  59636. * @returns the Vector4.
  59637. */
  59638. toArray(array: FloatArray, index?: number): Vector4;
  59639. /**
  59640. * Adds the given vector to the current Vector4.
  59641. * @param otherVector the vector to add
  59642. * @returns the updated Vector4.
  59643. */
  59644. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  59645. /**
  59646. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  59647. * @param otherVector the vector to add
  59648. * @returns the resulting vector
  59649. */
  59650. add(otherVector: DeepImmutable<Vector4>): Vector4;
  59651. /**
  59652. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  59653. * @param otherVector the vector to add
  59654. * @param result the vector to store the result
  59655. * @returns the current Vector4.
  59656. */
  59657. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  59658. /**
  59659. * Subtract in place the given vector from the current Vector4.
  59660. * @param otherVector the vector to subtract
  59661. * @returns the updated Vector4.
  59662. */
  59663. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  59664. /**
  59665. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  59666. * @param otherVector the vector to add
  59667. * @returns the new vector with the result
  59668. */
  59669. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  59670. /**
  59671. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  59672. * @param otherVector the vector to subtract
  59673. * @param result the vector to store the result
  59674. * @returns the current Vector4.
  59675. */
  59676. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  59677. /**
  59678. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  59679. */
  59680. /**
  59681. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  59682. * @param x value to subtract
  59683. * @param y value to subtract
  59684. * @param z value to subtract
  59685. * @param w value to subtract
  59686. * @returns new vector containing the result
  59687. */
  59688. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  59689. /**
  59690. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  59691. * @param x value to subtract
  59692. * @param y value to subtract
  59693. * @param z value to subtract
  59694. * @param w value to subtract
  59695. * @param result the vector to store the result in
  59696. * @returns the current Vector4.
  59697. */
  59698. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  59699. /**
  59700. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  59701. * @returns a new vector with the negated values
  59702. */
  59703. negate(): Vector4;
  59704. /**
  59705. * Multiplies the current Vector4 coordinates by scale (float).
  59706. * @param scale the number to scale with
  59707. * @returns the updated Vector4.
  59708. */
  59709. scaleInPlace(scale: number): Vector4;
  59710. /**
  59711. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  59712. * @param scale the number to scale with
  59713. * @returns a new vector with the result
  59714. */
  59715. scale(scale: number): Vector4;
  59716. /**
  59717. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  59718. * @param scale the number to scale with
  59719. * @param result a vector to store the result in
  59720. * @returns the current Vector4.
  59721. */
  59722. scaleToRef(scale: number, result: Vector4): Vector4;
  59723. /**
  59724. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  59725. * @param scale defines the scale factor
  59726. * @param result defines the Vector4 object where to store the result
  59727. * @returns the unmodified current Vector4
  59728. */
  59729. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  59730. /**
  59731. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  59732. * @param otherVector the vector to compare against
  59733. * @returns true if they are equal
  59734. */
  59735. equals(otherVector: DeepImmutable<Vector4>): boolean;
  59736. /**
  59737. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  59738. * @param otherVector vector to compare against
  59739. * @param epsilon (Default: very small number)
  59740. * @returns true if they are equal
  59741. */
  59742. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  59743. /**
  59744. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  59745. * @param x x value to compare against
  59746. * @param y y value to compare against
  59747. * @param z z value to compare against
  59748. * @param w w value to compare against
  59749. * @returns true if equal
  59750. */
  59751. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  59752. /**
  59753. * Multiplies in place the current Vector4 by the given one.
  59754. * @param otherVector vector to multiple with
  59755. * @returns the updated Vector4.
  59756. */
  59757. multiplyInPlace(otherVector: Vector4): Vector4;
  59758. /**
  59759. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  59760. * @param otherVector vector to multiple with
  59761. * @returns resulting new vector
  59762. */
  59763. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  59764. /**
  59765. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  59766. * @param otherVector vector to multiple with
  59767. * @param result vector to store the result
  59768. * @returns the current Vector4.
  59769. */
  59770. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  59771. /**
  59772. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  59773. * @param x x value multiply with
  59774. * @param y y value multiply with
  59775. * @param z z value multiply with
  59776. * @param w w value multiply with
  59777. * @returns resulting new vector
  59778. */
  59779. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  59780. /**
  59781. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  59782. * @param otherVector vector to devide with
  59783. * @returns resulting new vector
  59784. */
  59785. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  59786. /**
  59787. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  59788. * @param otherVector vector to devide with
  59789. * @param result vector to store the result
  59790. * @returns the current Vector4.
  59791. */
  59792. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  59793. /**
  59794. * Divides the current Vector3 coordinates by the given ones.
  59795. * @param otherVector vector to devide with
  59796. * @returns the updated Vector3.
  59797. */
  59798. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  59799. /**
  59800. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  59801. * @param other defines the second operand
  59802. * @returns the current updated Vector4
  59803. */
  59804. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  59805. /**
  59806. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  59807. * @param other defines the second operand
  59808. * @returns the current updated Vector4
  59809. */
  59810. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  59811. /**
  59812. * Gets a new Vector4 from current Vector4 floored values
  59813. * @returns a new Vector4
  59814. */
  59815. floor(): Vector4;
  59816. /**
  59817. * Gets a new Vector4 from current Vector3 floored values
  59818. * @returns a new Vector4
  59819. */
  59820. fract(): Vector4;
  59821. /**
  59822. * Returns the Vector4 length (float).
  59823. * @returns the length
  59824. */
  59825. length(): number;
  59826. /**
  59827. * Returns the Vector4 squared length (float).
  59828. * @returns the length squared
  59829. */
  59830. lengthSquared(): number;
  59831. /**
  59832. * Normalizes in place the Vector4.
  59833. * @returns the updated Vector4.
  59834. */
  59835. normalize(): Vector4;
  59836. /**
  59837. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  59838. * @returns this converted to a new vector3
  59839. */
  59840. toVector3(): Vector3;
  59841. /**
  59842. * Returns a new Vector4 copied from the current one.
  59843. * @returns the new cloned vector
  59844. */
  59845. clone(): Vector4;
  59846. /**
  59847. * Updates the current Vector4 with the given one coordinates.
  59848. * @param source the source vector to copy from
  59849. * @returns the updated Vector4.
  59850. */
  59851. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  59852. /**
  59853. * Updates the current Vector4 coordinates with the given floats.
  59854. * @param x float to copy from
  59855. * @param y float to copy from
  59856. * @param z float to copy from
  59857. * @param w float to copy from
  59858. * @returns the updated Vector4.
  59859. */
  59860. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  59861. /**
  59862. * Updates the current Vector4 coordinates with the given floats.
  59863. * @param x float to set from
  59864. * @param y float to set from
  59865. * @param z float to set from
  59866. * @param w float to set from
  59867. * @returns the updated Vector4.
  59868. */
  59869. set(x: number, y: number, z: number, w: number): Vector4;
  59870. /**
  59871. * Copies the given float to the current Vector3 coordinates
  59872. * @param v defines the x, y, z and w coordinates of the operand
  59873. * @returns the current updated Vector3
  59874. */
  59875. setAll(v: number): Vector4;
  59876. /**
  59877. * Returns a new Vector4 set from the starting index of the given array.
  59878. * @param array the array to pull values from
  59879. * @param offset the offset into the array to start at
  59880. * @returns the new vector
  59881. */
  59882. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  59883. /**
  59884. * Updates the given vector "result" from the starting index of the given array.
  59885. * @param array the array to pull values from
  59886. * @param offset the offset into the array to start at
  59887. * @param result the vector to store the result in
  59888. */
  59889. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  59890. /**
  59891. * Updates the given vector "result" from the starting index of the given Float32Array.
  59892. * @param array the array to pull values from
  59893. * @param offset the offset into the array to start at
  59894. * @param result the vector to store the result in
  59895. */
  59896. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  59897. /**
  59898. * Updates the given vector "result" coordinates from the given floats.
  59899. * @param x float to set from
  59900. * @param y float to set from
  59901. * @param z float to set from
  59902. * @param w float to set from
  59903. * @param result the vector to the floats in
  59904. */
  59905. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  59906. /**
  59907. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  59908. * @returns the new vector
  59909. */
  59910. static Zero(): Vector4;
  59911. /**
  59912. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  59913. * @returns the new vector
  59914. */
  59915. static One(): Vector4;
  59916. /**
  59917. * Returns a new normalized Vector4 from the given one.
  59918. * @param vector the vector to normalize
  59919. * @returns the vector
  59920. */
  59921. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  59922. /**
  59923. * Updates the given vector "result" from the normalization of the given one.
  59924. * @param vector the vector to normalize
  59925. * @param result the vector to store the result in
  59926. */
  59927. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  59928. /**
  59929. * Returns a vector with the minimum values from the left and right vectors
  59930. * @param left left vector to minimize
  59931. * @param right right vector to minimize
  59932. * @returns a new vector with the minimum of the left and right vector values
  59933. */
  59934. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  59935. /**
  59936. * Returns a vector with the maximum values from the left and right vectors
  59937. * @param left left vector to maximize
  59938. * @param right right vector to maximize
  59939. * @returns a new vector with the maximum of the left and right vector values
  59940. */
  59941. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  59942. /**
  59943. * Returns the distance (float) between the vectors "value1" and "value2".
  59944. * @param value1 value to calulate the distance between
  59945. * @param value2 value to calulate the distance between
  59946. * @return the distance between the two vectors
  59947. */
  59948. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  59949. /**
  59950. * Returns the squared distance (float) between the vectors "value1" and "value2".
  59951. * @param value1 value to calulate the distance between
  59952. * @param value2 value to calulate the distance between
  59953. * @return the distance between the two vectors squared
  59954. */
  59955. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  59956. /**
  59957. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  59958. * @param value1 value to calulate the center between
  59959. * @param value2 value to calulate the center between
  59960. * @return the center between the two vectors
  59961. */
  59962. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  59963. /**
  59964. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  59965. * This methods computes transformed normalized direction vectors only.
  59966. * @param vector the vector to transform
  59967. * @param transformation the transformation matrix to apply
  59968. * @returns the new vector
  59969. */
  59970. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  59971. /**
  59972. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  59973. * This methods computes transformed normalized direction vectors only.
  59974. * @param vector the vector to transform
  59975. * @param transformation the transformation matrix to apply
  59976. * @param result the vector to store the result in
  59977. */
  59978. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  59979. /**
  59980. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  59981. * This methods computes transformed normalized direction vectors only.
  59982. * @param x value to transform
  59983. * @param y value to transform
  59984. * @param z value to transform
  59985. * @param w value to transform
  59986. * @param transformation the transformation matrix to apply
  59987. * @param result the vector to store the results in
  59988. */
  59989. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  59990. /**
  59991. * Creates a new Vector4 from a Vector3
  59992. * @param source defines the source data
  59993. * @param w defines the 4th component (default is 0)
  59994. * @returns a new Vector4
  59995. */
  59996. static FromVector3(source: Vector3, w?: number): Vector4;
  59997. }
  59998. /**
  59999. * Interface for the size containing width and height
  60000. */
  60001. export interface ISize {
  60002. /**
  60003. * Width
  60004. */
  60005. width: number;
  60006. /**
  60007. * Heighht
  60008. */
  60009. height: number;
  60010. }
  60011. /**
  60012. * Size containing widht and height
  60013. */
  60014. export class Size implements ISize {
  60015. /**
  60016. * Width
  60017. */
  60018. width: number;
  60019. /**
  60020. * Height
  60021. */
  60022. height: number;
  60023. /**
  60024. * Creates a Size object from the given width and height (floats).
  60025. * @param width width of the new size
  60026. * @param height height of the new size
  60027. */
  60028. constructor(width: number, height: number);
  60029. /**
  60030. * Returns a string with the Size width and height
  60031. * @returns a string with the Size width and height
  60032. */
  60033. toString(): string;
  60034. /**
  60035. * "Size"
  60036. * @returns the string "Size"
  60037. */
  60038. getClassName(): string;
  60039. /**
  60040. * Returns the Size hash code.
  60041. * @returns a hash code for a unique width and height
  60042. */
  60043. getHashCode(): number;
  60044. /**
  60045. * Updates the current size from the given one.
  60046. * @param src the given size
  60047. */
  60048. copyFrom(src: Size): void;
  60049. /**
  60050. * Updates in place the current Size from the given floats.
  60051. * @param width width of the new size
  60052. * @param height height of the new size
  60053. * @returns the updated Size.
  60054. */
  60055. copyFromFloats(width: number, height: number): Size;
  60056. /**
  60057. * Updates in place the current Size from the given floats.
  60058. * @param width width to set
  60059. * @param height height to set
  60060. * @returns the updated Size.
  60061. */
  60062. set(width: number, height: number): Size;
  60063. /**
  60064. * Multiplies the width and height by numbers
  60065. * @param w factor to multiple the width by
  60066. * @param h factor to multiple the height by
  60067. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  60068. */
  60069. multiplyByFloats(w: number, h: number): Size;
  60070. /**
  60071. * Clones the size
  60072. * @returns a new Size copied from the given one.
  60073. */
  60074. clone(): Size;
  60075. /**
  60076. * True if the current Size and the given one width and height are strictly equal.
  60077. * @param other the other size to compare against
  60078. * @returns True if the current Size and the given one width and height are strictly equal.
  60079. */
  60080. equals(other: Size): boolean;
  60081. /**
  60082. * The surface of the Size : width * height (float).
  60083. */
  60084. readonly surface: number;
  60085. /**
  60086. * Create a new size of zero
  60087. * @returns a new Size set to (0.0, 0.0)
  60088. */
  60089. static Zero(): Size;
  60090. /**
  60091. * Sums the width and height of two sizes
  60092. * @param otherSize size to add to this size
  60093. * @returns a new Size set as the addition result of the current Size and the given one.
  60094. */
  60095. add(otherSize: Size): Size;
  60096. /**
  60097. * Subtracts the width and height of two
  60098. * @param otherSize size to subtract to this size
  60099. * @returns a new Size set as the subtraction result of the given one from the current Size.
  60100. */
  60101. subtract(otherSize: Size): Size;
  60102. /**
  60103. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  60104. * @param start starting size to lerp between
  60105. * @param end end size to lerp between
  60106. * @param amount amount to lerp between the start and end values
  60107. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  60108. */
  60109. static Lerp(start: Size, end: Size, amount: number): Size;
  60110. }
  60111. /**
  60112. * Class used to store quaternion data
  60113. * @see https://en.wikipedia.org/wiki/Quaternion
  60114. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  60115. */
  60116. export class Quaternion {
  60117. /** defines the first component (0 by default) */
  60118. x: number;
  60119. /** defines the second component (0 by default) */
  60120. y: number;
  60121. /** defines the third component (0 by default) */
  60122. z: number;
  60123. /** defines the fourth component (1.0 by default) */
  60124. w: number;
  60125. /**
  60126. * Creates a new Quaternion from the given floats
  60127. * @param x defines the first component (0 by default)
  60128. * @param y defines the second component (0 by default)
  60129. * @param z defines the third component (0 by default)
  60130. * @param w defines the fourth component (1.0 by default)
  60131. */
  60132. constructor(
  60133. /** defines the first component (0 by default) */
  60134. x?: number,
  60135. /** defines the second component (0 by default) */
  60136. y?: number,
  60137. /** defines the third component (0 by default) */
  60138. z?: number,
  60139. /** defines the fourth component (1.0 by default) */
  60140. w?: number);
  60141. /**
  60142. * Gets a string representation for the current quaternion
  60143. * @returns a string with the Quaternion coordinates
  60144. */
  60145. toString(): string;
  60146. /**
  60147. * Gets the class name of the quaternion
  60148. * @returns the string "Quaternion"
  60149. */
  60150. getClassName(): string;
  60151. /**
  60152. * Gets a hash code for this quaternion
  60153. * @returns the quaternion hash code
  60154. */
  60155. getHashCode(): number;
  60156. /**
  60157. * Copy the quaternion to an array
  60158. * @returns a new array populated with 4 elements from the quaternion coordinates
  60159. */
  60160. asArray(): number[];
  60161. /**
  60162. * Check if two quaternions are equals
  60163. * @param otherQuaternion defines the second operand
  60164. * @return true if the current quaternion and the given one coordinates are strictly equals
  60165. */
  60166. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  60167. /**
  60168. * Clone the current quaternion
  60169. * @returns a new quaternion copied from the current one
  60170. */
  60171. clone(): Quaternion;
  60172. /**
  60173. * Copy a quaternion to the current one
  60174. * @param other defines the other quaternion
  60175. * @returns the updated current quaternion
  60176. */
  60177. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  60178. /**
  60179. * Updates the current quaternion with the given float coordinates
  60180. * @param x defines the x coordinate
  60181. * @param y defines the y coordinate
  60182. * @param z defines the z coordinate
  60183. * @param w defines the w coordinate
  60184. * @returns the updated current quaternion
  60185. */
  60186. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  60187. /**
  60188. * Updates the current quaternion from the given float coordinates
  60189. * @param x defines the x coordinate
  60190. * @param y defines the y coordinate
  60191. * @param z defines the z coordinate
  60192. * @param w defines the w coordinate
  60193. * @returns the updated current quaternion
  60194. */
  60195. set(x: number, y: number, z: number, w: number): Quaternion;
  60196. /**
  60197. * Adds two quaternions
  60198. * @param other defines the second operand
  60199. * @returns a new quaternion as the addition result of the given one and the current quaternion
  60200. */
  60201. add(other: DeepImmutable<Quaternion>): Quaternion;
  60202. /**
  60203. * Add a quaternion to the current one
  60204. * @param other defines the quaternion to add
  60205. * @returns the current quaternion
  60206. */
  60207. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  60208. /**
  60209. * Subtract two quaternions
  60210. * @param other defines the second operand
  60211. * @returns a new quaternion as the subtraction result of the given one from the current one
  60212. */
  60213. subtract(other: Quaternion): Quaternion;
  60214. /**
  60215. * Multiplies the current quaternion by a scale factor
  60216. * @param value defines the scale factor
  60217. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  60218. */
  60219. scale(value: number): Quaternion;
  60220. /**
  60221. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  60222. * @param scale defines the scale factor
  60223. * @param result defines the Quaternion object where to store the result
  60224. * @returns the unmodified current quaternion
  60225. */
  60226. scaleToRef(scale: number, result: Quaternion): Quaternion;
  60227. /**
  60228. * Multiplies in place the current quaternion by a scale factor
  60229. * @param value defines the scale factor
  60230. * @returns the current modified quaternion
  60231. */
  60232. scaleInPlace(value: number): Quaternion;
  60233. /**
  60234. * Scale the current quaternion values by a factor and add the result to a given quaternion
  60235. * @param scale defines the scale factor
  60236. * @param result defines the Quaternion object where to store the result
  60237. * @returns the unmodified current quaternion
  60238. */
  60239. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  60240. /**
  60241. * Multiplies two quaternions
  60242. * @param q1 defines the second operand
  60243. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  60244. */
  60245. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  60246. /**
  60247. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  60248. * @param q1 defines the second operand
  60249. * @param result defines the target quaternion
  60250. * @returns the current quaternion
  60251. */
  60252. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  60253. /**
  60254. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  60255. * @param q1 defines the second operand
  60256. * @returns the currentupdated quaternion
  60257. */
  60258. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  60259. /**
  60260. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  60261. * @param ref defines the target quaternion
  60262. * @returns the current quaternion
  60263. */
  60264. conjugateToRef(ref: Quaternion): Quaternion;
  60265. /**
  60266. * Conjugates in place (1-q) the current quaternion
  60267. * @returns the current updated quaternion
  60268. */
  60269. conjugateInPlace(): Quaternion;
  60270. /**
  60271. * Conjugates in place (1-q) the current quaternion
  60272. * @returns a new quaternion
  60273. */
  60274. conjugate(): Quaternion;
  60275. /**
  60276. * Gets length of current quaternion
  60277. * @returns the quaternion length (float)
  60278. */
  60279. length(): number;
  60280. /**
  60281. * Normalize in place the current quaternion
  60282. * @returns the current updated quaternion
  60283. */
  60284. normalize(): Quaternion;
  60285. /**
  60286. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  60287. * @param order is a reserved parameter and is ignore for now
  60288. * @returns a new Vector3 containing the Euler angles
  60289. */
  60290. toEulerAngles(order?: string): Vector3;
  60291. /**
  60292. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  60293. * @param result defines the vector which will be filled with the Euler angles
  60294. * @param order is a reserved parameter and is ignore for now
  60295. * @returns the current unchanged quaternion
  60296. */
  60297. toEulerAnglesToRef(result: Vector3): Quaternion;
  60298. /**
  60299. * Updates the given rotation matrix with the current quaternion values
  60300. * @param result defines the target matrix
  60301. * @returns the current unchanged quaternion
  60302. */
  60303. toRotationMatrix(result: Matrix): Quaternion;
  60304. /**
  60305. * Updates the current quaternion from the given rotation matrix values
  60306. * @param matrix defines the source matrix
  60307. * @returns the current updated quaternion
  60308. */
  60309. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  60310. /**
  60311. * Creates a new quaternion from a rotation matrix
  60312. * @param matrix defines the source matrix
  60313. * @returns a new quaternion created from the given rotation matrix values
  60314. */
  60315. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  60316. /**
  60317. * Updates the given quaternion with the given rotation matrix values
  60318. * @param matrix defines the source matrix
  60319. * @param result defines the target quaternion
  60320. */
  60321. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  60322. /**
  60323. * Returns the dot product (float) between the quaternions "left" and "right"
  60324. * @param left defines the left operand
  60325. * @param right defines the right operand
  60326. * @returns the dot product
  60327. */
  60328. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  60329. /**
  60330. * Checks if the two quaternions are close to each other
  60331. * @param quat0 defines the first quaternion to check
  60332. * @param quat1 defines the second quaternion to check
  60333. * @returns true if the two quaternions are close to each other
  60334. */
  60335. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  60336. /**
  60337. * Creates an empty quaternion
  60338. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  60339. */
  60340. static Zero(): Quaternion;
  60341. /**
  60342. * Inverse a given quaternion
  60343. * @param q defines the source quaternion
  60344. * @returns a new quaternion as the inverted current quaternion
  60345. */
  60346. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  60347. /**
  60348. * Inverse a given quaternion
  60349. * @param q defines the source quaternion
  60350. * @param result the quaternion the result will be stored in
  60351. * @returns the result quaternion
  60352. */
  60353. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  60354. /**
  60355. * Creates an identity quaternion
  60356. * @returns the identity quaternion
  60357. */
  60358. static Identity(): Quaternion;
  60359. /**
  60360. * Gets a boolean indicating if the given quaternion is identity
  60361. * @param quaternion defines the quaternion to check
  60362. * @returns true if the quaternion is identity
  60363. */
  60364. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  60365. /**
  60366. * Creates a quaternion from a rotation around an axis
  60367. * @param axis defines the axis to use
  60368. * @param angle defines the angle to use
  60369. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  60370. */
  60371. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  60372. /**
  60373. * Creates a rotation around an axis and stores it into the given quaternion
  60374. * @param axis defines the axis to use
  60375. * @param angle defines the angle to use
  60376. * @param result defines the target quaternion
  60377. * @returns the target quaternion
  60378. */
  60379. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  60380. /**
  60381. * Creates a new quaternion from data stored into an array
  60382. * @param array defines the data source
  60383. * @param offset defines the offset in the source array where the data starts
  60384. * @returns a new quaternion
  60385. */
  60386. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  60387. /**
  60388. * Create a quaternion from Euler rotation angles
  60389. * @param x Pitch
  60390. * @param y Yaw
  60391. * @param z Roll
  60392. * @returns the new Quaternion
  60393. */
  60394. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  60395. /**
  60396. * Updates a quaternion from Euler rotation angles
  60397. * @param x Pitch
  60398. * @param y Yaw
  60399. * @param z Roll
  60400. * @param result the quaternion to store the result
  60401. * @returns the updated quaternion
  60402. */
  60403. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  60404. /**
  60405. * Create a quaternion from Euler rotation vector
  60406. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  60407. * @returns the new Quaternion
  60408. */
  60409. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  60410. /**
  60411. * Updates a quaternion from Euler rotation vector
  60412. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  60413. * @param result the quaternion to store the result
  60414. * @returns the updated quaternion
  60415. */
  60416. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  60417. /**
  60418. * Creates a new quaternion from the given Euler float angles (y, x, z)
  60419. * @param yaw defines the rotation around Y axis
  60420. * @param pitch defines the rotation around X axis
  60421. * @param roll defines the rotation around Z axis
  60422. * @returns the new quaternion
  60423. */
  60424. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  60425. /**
  60426. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  60427. * @param yaw defines the rotation around Y axis
  60428. * @param pitch defines the rotation around X axis
  60429. * @param roll defines the rotation around Z axis
  60430. * @param result defines the target quaternion
  60431. */
  60432. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  60433. /**
  60434. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  60435. * @param alpha defines the rotation around first axis
  60436. * @param beta defines the rotation around second axis
  60437. * @param gamma defines the rotation around third axis
  60438. * @returns the new quaternion
  60439. */
  60440. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  60441. /**
  60442. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  60443. * @param alpha defines the rotation around first axis
  60444. * @param beta defines the rotation around second axis
  60445. * @param gamma defines the rotation around third axis
  60446. * @param result defines the target quaternion
  60447. */
  60448. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  60449. /**
  60450. * 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)
  60451. * @param axis1 defines the first axis
  60452. * @param axis2 defines the second axis
  60453. * @param axis3 defines the third axis
  60454. * @returns the new quaternion
  60455. */
  60456. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  60457. /**
  60458. * 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
  60459. * @param axis1 defines the first axis
  60460. * @param axis2 defines the second axis
  60461. * @param axis3 defines the third axis
  60462. * @param ref defines the target quaternion
  60463. */
  60464. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  60465. /**
  60466. * Interpolates between two quaternions
  60467. * @param left defines first quaternion
  60468. * @param right defines second quaternion
  60469. * @param amount defines the gradient to use
  60470. * @returns the new interpolated quaternion
  60471. */
  60472. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  60473. /**
  60474. * Interpolates between two quaternions and stores it into a target quaternion
  60475. * @param left defines first quaternion
  60476. * @param right defines second quaternion
  60477. * @param amount defines the gradient to use
  60478. * @param result defines the target quaternion
  60479. */
  60480. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  60481. /**
  60482. * Interpolate between two quaternions using Hermite interpolation
  60483. * @param value1 defines first quaternion
  60484. * @param tangent1 defines the incoming tangent
  60485. * @param value2 defines second quaternion
  60486. * @param tangent2 defines the outgoing tangent
  60487. * @param amount defines the target quaternion
  60488. * @returns the new interpolated quaternion
  60489. */
  60490. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  60491. }
  60492. /**
  60493. * Class used to store matrix data (4x4)
  60494. */
  60495. export class Matrix {
  60496. private static _updateFlagSeed;
  60497. private static _identityReadOnly;
  60498. private _isIdentity;
  60499. private _isIdentityDirty;
  60500. private _isIdentity3x2;
  60501. private _isIdentity3x2Dirty;
  60502. /**
  60503. * Gets the update flag of the matrix which is an unique number for the matrix.
  60504. * It will be incremented every time the matrix data change.
  60505. * You can use it to speed the comparison between two versions of the same matrix.
  60506. */
  60507. updateFlag: number;
  60508. private readonly _m;
  60509. /**
  60510. * Gets the internal data of the matrix
  60511. */
  60512. readonly m: DeepImmutable<Float32Array>;
  60513. /** @hidden */
  60514. _markAsUpdated(): void;
  60515. /** @hidden */
  60516. private _updateIdentityStatus;
  60517. /**
  60518. * Creates an empty matrix (filled with zeros)
  60519. */
  60520. constructor();
  60521. /**
  60522. * Check if the current matrix is identity
  60523. * @returns true is the matrix is the identity matrix
  60524. */
  60525. isIdentity(): boolean;
  60526. /**
  60527. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  60528. * @returns true is the matrix is the identity matrix
  60529. */
  60530. isIdentityAs3x2(): boolean;
  60531. /**
  60532. * Gets the determinant of the matrix
  60533. * @returns the matrix determinant
  60534. */
  60535. determinant(): number;
  60536. /**
  60537. * Returns the matrix as a Float32Array
  60538. * @returns the matrix underlying array
  60539. */
  60540. toArray(): DeepImmutable<Float32Array>;
  60541. /**
  60542. * Returns the matrix as a Float32Array
  60543. * @returns the matrix underlying array.
  60544. */
  60545. asArray(): DeepImmutable<Float32Array>;
  60546. /**
  60547. * Inverts the current matrix in place
  60548. * @returns the current inverted matrix
  60549. */
  60550. invert(): Matrix;
  60551. /**
  60552. * Sets all the matrix elements to zero
  60553. * @returns the current matrix
  60554. */
  60555. reset(): Matrix;
  60556. /**
  60557. * Adds the current matrix with a second one
  60558. * @param other defines the matrix to add
  60559. * @returns a new matrix as the addition of the current matrix and the given one
  60560. */
  60561. add(other: DeepImmutable<Matrix>): Matrix;
  60562. /**
  60563. * Sets the given matrix "result" to the addition of the current matrix and the given one
  60564. * @param other defines the matrix to add
  60565. * @param result defines the target matrix
  60566. * @returns the current matrix
  60567. */
  60568. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  60569. /**
  60570. * Adds in place the given matrix to the current matrix
  60571. * @param other defines the second operand
  60572. * @returns the current updated matrix
  60573. */
  60574. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  60575. /**
  60576. * Sets the given matrix to the current inverted Matrix
  60577. * @param other defines the target matrix
  60578. * @returns the unmodified current matrix
  60579. */
  60580. invertToRef(other: Matrix): Matrix;
  60581. /**
  60582. * add a value at the specified position in the current Matrix
  60583. * @param index the index of the value within the matrix. between 0 and 15.
  60584. * @param value the value to be added
  60585. * @returns the current updated matrix
  60586. */
  60587. addAtIndex(index: number, value: number): Matrix;
  60588. /**
  60589. * mutiply the specified position in the current Matrix by a value
  60590. * @param index the index of the value within the matrix. between 0 and 15.
  60591. * @param value the value to be added
  60592. * @returns the current updated matrix
  60593. */
  60594. multiplyAtIndex(index: number, value: number): Matrix;
  60595. /**
  60596. * Inserts the translation vector (using 3 floats) in the current matrix
  60597. * @param x defines the 1st component of the translation
  60598. * @param y defines the 2nd component of the translation
  60599. * @param z defines the 3rd component of the translation
  60600. * @returns the current updated matrix
  60601. */
  60602. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  60603. /**
  60604. * Inserts the translation vector in the current matrix
  60605. * @param vector3 defines the translation to insert
  60606. * @returns the current updated matrix
  60607. */
  60608. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  60609. /**
  60610. * Gets the translation value of the current matrix
  60611. * @returns a new Vector3 as the extracted translation from the matrix
  60612. */
  60613. getTranslation(): Vector3;
  60614. /**
  60615. * Fill a Vector3 with the extracted translation from the matrix
  60616. * @param result defines the Vector3 where to store the translation
  60617. * @returns the current matrix
  60618. */
  60619. getTranslationToRef(result: Vector3): Matrix;
  60620. /**
  60621. * Remove rotation and scaling part from the matrix
  60622. * @returns the updated matrix
  60623. */
  60624. removeRotationAndScaling(): Matrix;
  60625. /**
  60626. * Multiply two matrices
  60627. * @param other defines the second operand
  60628. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  60629. */
  60630. multiply(other: DeepImmutable<Matrix>): Matrix;
  60631. /**
  60632. * Copy the current matrix from the given one
  60633. * @param other defines the source matrix
  60634. * @returns the current updated matrix
  60635. */
  60636. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  60637. /**
  60638. * Populates the given array from the starting index with the current matrix values
  60639. * @param array defines the target array
  60640. * @param offset defines the offset in the target array where to start storing values
  60641. * @returns the current matrix
  60642. */
  60643. copyToArray(array: Float32Array, offset?: number): Matrix;
  60644. /**
  60645. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  60646. * @param other defines the second operand
  60647. * @param result defines the matrix where to store the multiplication
  60648. * @returns the current matrix
  60649. */
  60650. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  60651. /**
  60652. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  60653. * @param other defines the second operand
  60654. * @param result defines the array where to store the multiplication
  60655. * @param offset defines the offset in the target array where to start storing values
  60656. * @returns the current matrix
  60657. */
  60658. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  60659. /**
  60660. * Check equality between this matrix and a second one
  60661. * @param value defines the second matrix to compare
  60662. * @returns true is the current matrix and the given one values are strictly equal
  60663. */
  60664. equals(value: DeepImmutable<Matrix>): boolean;
  60665. /**
  60666. * Clone the current matrix
  60667. * @returns a new matrix from the current matrix
  60668. */
  60669. clone(): Matrix;
  60670. /**
  60671. * Returns the name of the current matrix class
  60672. * @returns the string "Matrix"
  60673. */
  60674. getClassName(): string;
  60675. /**
  60676. * Gets the hash code of the current matrix
  60677. * @returns the hash code
  60678. */
  60679. getHashCode(): number;
  60680. /**
  60681. * Decomposes the current Matrix into a translation, rotation and scaling components
  60682. * @param scale defines the scale vector3 given as a reference to update
  60683. * @param rotation defines the rotation quaternion given as a reference to update
  60684. * @param translation defines the translation vector3 given as a reference to update
  60685. * @returns true if operation was successful
  60686. */
  60687. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  60688. /**
  60689. * Gets specific row of the matrix
  60690. * @param index defines the number of the row to get
  60691. * @returns the index-th row of the current matrix as a new Vector4
  60692. */
  60693. getRow(index: number): Nullable<Vector4>;
  60694. /**
  60695. * Sets the index-th row of the current matrix to the vector4 values
  60696. * @param index defines the number of the row to set
  60697. * @param row defines the target vector4
  60698. * @returns the updated current matrix
  60699. */
  60700. setRow(index: number, row: Vector4): Matrix;
  60701. /**
  60702. * Compute the transpose of the matrix
  60703. * @returns the new transposed matrix
  60704. */
  60705. transpose(): Matrix;
  60706. /**
  60707. * Compute the transpose of the matrix and store it in a given matrix
  60708. * @param result defines the target matrix
  60709. * @returns the current matrix
  60710. */
  60711. transposeToRef(result: Matrix): Matrix;
  60712. /**
  60713. * Sets the index-th row of the current matrix with the given 4 x float values
  60714. * @param index defines the row index
  60715. * @param x defines the x component to set
  60716. * @param y defines the y component to set
  60717. * @param z defines the z component to set
  60718. * @param w defines the w component to set
  60719. * @returns the updated current matrix
  60720. */
  60721. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  60722. /**
  60723. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  60724. * @param scale defines the scale factor
  60725. * @returns a new matrix
  60726. */
  60727. scale(scale: number): Matrix;
  60728. /**
  60729. * Scale the current matrix values by a factor to a given result matrix
  60730. * @param scale defines the scale factor
  60731. * @param result defines the matrix to store the result
  60732. * @returns the current matrix
  60733. */
  60734. scaleToRef(scale: number, result: Matrix): Matrix;
  60735. /**
  60736. * Scale the current matrix values by a factor and add the result to a given matrix
  60737. * @param scale defines the scale factor
  60738. * @param result defines the Matrix to store the result
  60739. * @returns the current matrix
  60740. */
  60741. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  60742. /**
  60743. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  60744. * @param ref matrix to store the result
  60745. */
  60746. toNormalMatrix(ref: Matrix): void;
  60747. /**
  60748. * Gets only rotation part of the current matrix
  60749. * @returns a new matrix sets to the extracted rotation matrix from the current one
  60750. */
  60751. getRotationMatrix(): Matrix;
  60752. /**
  60753. * Extracts the rotation matrix from the current one and sets it as the given "result"
  60754. * @param result defines the target matrix to store data to
  60755. * @returns the current matrix
  60756. */
  60757. getRotationMatrixToRef(result: Matrix): Matrix;
  60758. /**
  60759. * Toggles model matrix from being right handed to left handed in place and vice versa
  60760. */
  60761. toggleModelMatrixHandInPlace(): void;
  60762. /**
  60763. * Toggles projection matrix from being right handed to left handed in place and vice versa
  60764. */
  60765. toggleProjectionMatrixHandInPlace(): void;
  60766. /**
  60767. * Creates a matrix from an array
  60768. * @param array defines the source array
  60769. * @param offset defines an offset in the source array
  60770. * @returns a new Matrix set from the starting index of the given array
  60771. */
  60772. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  60773. /**
  60774. * Copy the content of an array into a given matrix
  60775. * @param array defines the source array
  60776. * @param offset defines an offset in the source array
  60777. * @param result defines the target matrix
  60778. */
  60779. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  60780. /**
  60781. * Stores an array into a matrix after having multiplied each component by a given factor
  60782. * @param array defines the source array
  60783. * @param offset defines the offset in the source array
  60784. * @param scale defines the scaling factor
  60785. * @param result defines the target matrix
  60786. */
  60787. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  60788. /**
  60789. * Gets an identity matrix that must not be updated
  60790. */
  60791. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  60792. /**
  60793. * Stores a list of values (16) inside a given matrix
  60794. * @param initialM11 defines 1st value of 1st row
  60795. * @param initialM12 defines 2nd value of 1st row
  60796. * @param initialM13 defines 3rd value of 1st row
  60797. * @param initialM14 defines 4th value of 1st row
  60798. * @param initialM21 defines 1st value of 2nd row
  60799. * @param initialM22 defines 2nd value of 2nd row
  60800. * @param initialM23 defines 3rd value of 2nd row
  60801. * @param initialM24 defines 4th value of 2nd row
  60802. * @param initialM31 defines 1st value of 3rd row
  60803. * @param initialM32 defines 2nd value of 3rd row
  60804. * @param initialM33 defines 3rd value of 3rd row
  60805. * @param initialM34 defines 4th value of 3rd row
  60806. * @param initialM41 defines 1st value of 4th row
  60807. * @param initialM42 defines 2nd value of 4th row
  60808. * @param initialM43 defines 3rd value of 4th row
  60809. * @param initialM44 defines 4th value of 4th row
  60810. * @param result defines the target matrix
  60811. */
  60812. 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;
  60813. /**
  60814. * Creates new matrix from a list of values (16)
  60815. * @param initialM11 defines 1st value of 1st row
  60816. * @param initialM12 defines 2nd value of 1st row
  60817. * @param initialM13 defines 3rd value of 1st row
  60818. * @param initialM14 defines 4th value of 1st row
  60819. * @param initialM21 defines 1st value of 2nd row
  60820. * @param initialM22 defines 2nd value of 2nd row
  60821. * @param initialM23 defines 3rd value of 2nd row
  60822. * @param initialM24 defines 4th value of 2nd row
  60823. * @param initialM31 defines 1st value of 3rd row
  60824. * @param initialM32 defines 2nd value of 3rd row
  60825. * @param initialM33 defines 3rd value of 3rd row
  60826. * @param initialM34 defines 4th value of 3rd row
  60827. * @param initialM41 defines 1st value of 4th row
  60828. * @param initialM42 defines 2nd value of 4th row
  60829. * @param initialM43 defines 3rd value of 4th row
  60830. * @param initialM44 defines 4th value of 4th row
  60831. * @returns the new matrix
  60832. */
  60833. 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;
  60834. /**
  60835. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  60836. * @param scale defines the scale vector3
  60837. * @param rotation defines the rotation quaternion
  60838. * @param translation defines the translation vector3
  60839. * @returns a new matrix
  60840. */
  60841. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  60842. /**
  60843. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  60844. * @param scale defines the scale vector3
  60845. * @param rotation defines the rotation quaternion
  60846. * @param translation defines the translation vector3
  60847. * @param result defines the target matrix
  60848. */
  60849. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  60850. /**
  60851. * Creates a new identity matrix
  60852. * @returns a new identity matrix
  60853. */
  60854. static Identity(): Matrix;
  60855. /**
  60856. * Creates a new identity matrix and stores the result in a given matrix
  60857. * @param result defines the target matrix
  60858. */
  60859. static IdentityToRef(result: Matrix): void;
  60860. /**
  60861. * Creates a new zero matrix
  60862. * @returns a new zero matrix
  60863. */
  60864. static Zero(): Matrix;
  60865. /**
  60866. * Creates a new rotation matrix for "angle" radians around the X axis
  60867. * @param angle defines the angle (in radians) to use
  60868. * @return the new matrix
  60869. */
  60870. static RotationX(angle: number): Matrix;
  60871. /**
  60872. * Creates a new matrix as the invert of a given matrix
  60873. * @param source defines the source matrix
  60874. * @returns the new matrix
  60875. */
  60876. static Invert(source: DeepImmutable<Matrix>): Matrix;
  60877. /**
  60878. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  60879. * @param angle defines the angle (in radians) to use
  60880. * @param result defines the target matrix
  60881. */
  60882. static RotationXToRef(angle: number, result: Matrix): void;
  60883. /**
  60884. * Creates a new rotation matrix for "angle" radians around the Y axis
  60885. * @param angle defines the angle (in radians) to use
  60886. * @return the new matrix
  60887. */
  60888. static RotationY(angle: number): Matrix;
  60889. /**
  60890. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  60891. * @param angle defines the angle (in radians) to use
  60892. * @param result defines the target matrix
  60893. */
  60894. static RotationYToRef(angle: number, result: Matrix): void;
  60895. /**
  60896. * Creates a new rotation matrix for "angle" radians around the Z axis
  60897. * @param angle defines the angle (in radians) to use
  60898. * @return the new matrix
  60899. */
  60900. static RotationZ(angle: number): Matrix;
  60901. /**
  60902. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  60903. * @param angle defines the angle (in radians) to use
  60904. * @param result defines the target matrix
  60905. */
  60906. static RotationZToRef(angle: number, result: Matrix): void;
  60907. /**
  60908. * Creates a new rotation matrix for "angle" radians around the given axis
  60909. * @param axis defines the axis to use
  60910. * @param angle defines the angle (in radians) to use
  60911. * @return the new matrix
  60912. */
  60913. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  60914. /**
  60915. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  60916. * @param axis defines the axis to use
  60917. * @param angle defines the angle (in radians) to use
  60918. * @param result defines the target matrix
  60919. */
  60920. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  60921. /**
  60922. * Creates a rotation matrix
  60923. * @param yaw defines the yaw angle in radians (Y axis)
  60924. * @param pitch defines the pitch angle in radians (X axis)
  60925. * @param roll defines the roll angle in radians (X axis)
  60926. * @returns the new rotation matrix
  60927. */
  60928. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  60929. /**
  60930. * Creates a rotation matrix and stores it in a given matrix
  60931. * @param yaw defines the yaw angle in radians (Y axis)
  60932. * @param pitch defines the pitch angle in radians (X axis)
  60933. * @param roll defines the roll angle in radians (X axis)
  60934. * @param result defines the target matrix
  60935. */
  60936. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  60937. /**
  60938. * Creates a scaling matrix
  60939. * @param x defines the scale factor on X axis
  60940. * @param y defines the scale factor on Y axis
  60941. * @param z defines the scale factor on Z axis
  60942. * @returns the new matrix
  60943. */
  60944. static Scaling(x: number, y: number, z: number): Matrix;
  60945. /**
  60946. * Creates a scaling matrix and stores it in a given matrix
  60947. * @param x defines the scale factor on X axis
  60948. * @param y defines the scale factor on Y axis
  60949. * @param z defines the scale factor on Z axis
  60950. * @param result defines the target matrix
  60951. */
  60952. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  60953. /**
  60954. * Creates a translation matrix
  60955. * @param x defines the translation on X axis
  60956. * @param y defines the translation on Y axis
  60957. * @param z defines the translationon Z axis
  60958. * @returns the new matrix
  60959. */
  60960. static Translation(x: number, y: number, z: number): Matrix;
  60961. /**
  60962. * Creates a translation matrix and stores it in a given matrix
  60963. * @param x defines the translation on X axis
  60964. * @param y defines the translation on Y axis
  60965. * @param z defines the translationon Z axis
  60966. * @param result defines the target matrix
  60967. */
  60968. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  60969. /**
  60970. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  60971. * @param startValue defines the start value
  60972. * @param endValue defines the end value
  60973. * @param gradient defines the gradient factor
  60974. * @returns the new matrix
  60975. */
  60976. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  60977. /**
  60978. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  60979. * @param startValue defines the start value
  60980. * @param endValue defines the end value
  60981. * @param gradient defines the gradient factor
  60982. * @param result defines the Matrix object where to store data
  60983. */
  60984. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  60985. /**
  60986. * Builds a new matrix whose values are computed by:
  60987. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  60988. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  60989. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  60990. * @param startValue defines the first matrix
  60991. * @param endValue defines the second matrix
  60992. * @param gradient defines the gradient between the two matrices
  60993. * @returns the new matrix
  60994. */
  60995. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  60996. /**
  60997. * Update a matrix to values which are computed by:
  60998. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  60999. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  61000. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  61001. * @param startValue defines the first matrix
  61002. * @param endValue defines the second matrix
  61003. * @param gradient defines the gradient between the two matrices
  61004. * @param result defines the target matrix
  61005. */
  61006. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  61007. /**
  61008. * 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"
  61009. * This function works in left handed mode
  61010. * @param eye defines the final position of the entity
  61011. * @param target defines where the entity should look at
  61012. * @param up defines the up vector for the entity
  61013. * @returns the new matrix
  61014. */
  61015. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  61016. /**
  61017. * 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".
  61018. * This function works in left handed mode
  61019. * @param eye defines the final position of the entity
  61020. * @param target defines where the entity should look at
  61021. * @param up defines the up vector for the entity
  61022. * @param result defines the target matrix
  61023. */
  61024. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  61025. /**
  61026. * 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"
  61027. * This function works in right handed mode
  61028. * @param eye defines the final position of the entity
  61029. * @param target defines where the entity should look at
  61030. * @param up defines the up vector for the entity
  61031. * @returns the new matrix
  61032. */
  61033. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  61034. /**
  61035. * 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".
  61036. * This function works in right handed mode
  61037. * @param eye defines the final position of the entity
  61038. * @param target defines where the entity should look at
  61039. * @param up defines the up vector for the entity
  61040. * @param result defines the target matrix
  61041. */
  61042. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  61043. /**
  61044. * Create a left-handed orthographic projection matrix
  61045. * @param width defines the viewport width
  61046. * @param height defines the viewport height
  61047. * @param znear defines the near clip plane
  61048. * @param zfar defines the far clip plane
  61049. * @returns a new matrix as a left-handed orthographic projection matrix
  61050. */
  61051. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  61052. /**
  61053. * Store a left-handed orthographic projection to a given matrix
  61054. * @param width defines the viewport width
  61055. * @param height defines the viewport height
  61056. * @param znear defines the near clip plane
  61057. * @param zfar defines the far clip plane
  61058. * @param result defines the target matrix
  61059. */
  61060. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  61061. /**
  61062. * Create a left-handed orthographic projection matrix
  61063. * @param left defines the viewport left coordinate
  61064. * @param right defines the viewport right coordinate
  61065. * @param bottom defines the viewport bottom coordinate
  61066. * @param top defines the viewport top coordinate
  61067. * @param znear defines the near clip plane
  61068. * @param zfar defines the far clip plane
  61069. * @returns a new matrix as a left-handed orthographic projection matrix
  61070. */
  61071. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  61072. /**
  61073. * Stores a left-handed orthographic projection into a given matrix
  61074. * @param left defines the viewport left coordinate
  61075. * @param right defines the viewport right coordinate
  61076. * @param bottom defines the viewport bottom coordinate
  61077. * @param top defines the viewport top coordinate
  61078. * @param znear defines the near clip plane
  61079. * @param zfar defines the far clip plane
  61080. * @param result defines the target matrix
  61081. */
  61082. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  61083. /**
  61084. * Creates a right-handed orthographic projection matrix
  61085. * @param left defines the viewport left coordinate
  61086. * @param right defines the viewport right coordinate
  61087. * @param bottom defines the viewport bottom coordinate
  61088. * @param top defines the viewport top coordinate
  61089. * @param znear defines the near clip plane
  61090. * @param zfar defines the far clip plane
  61091. * @returns a new matrix as a right-handed orthographic projection matrix
  61092. */
  61093. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  61094. /**
  61095. * Stores a right-handed orthographic projection into a given matrix
  61096. * @param left defines the viewport left coordinate
  61097. * @param right defines the viewport right coordinate
  61098. * @param bottom defines the viewport bottom coordinate
  61099. * @param top defines the viewport top coordinate
  61100. * @param znear defines the near clip plane
  61101. * @param zfar defines the far clip plane
  61102. * @param result defines the target matrix
  61103. */
  61104. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  61105. /**
  61106. * Creates a left-handed perspective projection matrix
  61107. * @param width defines the viewport width
  61108. * @param height defines the viewport height
  61109. * @param znear defines the near clip plane
  61110. * @param zfar defines the far clip plane
  61111. * @returns a new matrix as a left-handed perspective projection matrix
  61112. */
  61113. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  61114. /**
  61115. * Creates a left-handed perspective projection matrix
  61116. * @param fov defines the horizontal field of view
  61117. * @param aspect defines the aspect ratio
  61118. * @param znear defines the near clip plane
  61119. * @param zfar defines the far clip plane
  61120. * @returns a new matrix as a left-handed perspective projection matrix
  61121. */
  61122. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  61123. /**
  61124. * Stores a left-handed perspective projection into a given matrix
  61125. * @param fov defines the horizontal field of view
  61126. * @param aspect defines the aspect ratio
  61127. * @param znear defines the near clip plane
  61128. * @param zfar defines the far clip plane
  61129. * @param result defines the target matrix
  61130. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  61131. */
  61132. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  61133. /**
  61134. * Creates a right-handed perspective projection matrix
  61135. * @param fov defines the horizontal field of view
  61136. * @param aspect defines the aspect ratio
  61137. * @param znear defines the near clip plane
  61138. * @param zfar defines the far clip plane
  61139. * @returns a new matrix as a right-handed perspective projection matrix
  61140. */
  61141. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  61142. /**
  61143. * Stores a right-handed perspective projection into a given matrix
  61144. * @param fov defines the horizontal field of view
  61145. * @param aspect defines the aspect ratio
  61146. * @param znear defines the near clip plane
  61147. * @param zfar defines the far clip plane
  61148. * @param result defines the target matrix
  61149. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  61150. */
  61151. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  61152. /**
  61153. * Stores a perspective projection for WebVR info a given matrix
  61154. * @param fov defines the field of view
  61155. * @param znear defines the near clip plane
  61156. * @param zfar defines the far clip plane
  61157. * @param result defines the target matrix
  61158. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  61159. */
  61160. static PerspectiveFovWebVRToRef(fov: {
  61161. upDegrees: number;
  61162. downDegrees: number;
  61163. leftDegrees: number;
  61164. rightDegrees: number;
  61165. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  61166. /**
  61167. * Computes a complete transformation matrix
  61168. * @param viewport defines the viewport to use
  61169. * @param world defines the world matrix
  61170. * @param view defines the view matrix
  61171. * @param projection defines the projection matrix
  61172. * @param zmin defines the near clip plane
  61173. * @param zmax defines the far clip plane
  61174. * @returns the transformation matrix
  61175. */
  61176. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  61177. /**
  61178. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  61179. * @param matrix defines the matrix to use
  61180. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  61181. */
  61182. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  61183. /**
  61184. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  61185. * @param matrix defines the matrix to use
  61186. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  61187. */
  61188. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  61189. /**
  61190. * Compute the transpose of a given matrix
  61191. * @param matrix defines the matrix to transpose
  61192. * @returns the new matrix
  61193. */
  61194. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  61195. /**
  61196. * Compute the transpose of a matrix and store it in a target matrix
  61197. * @param matrix defines the matrix to transpose
  61198. * @param result defines the target matrix
  61199. */
  61200. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  61201. /**
  61202. * Computes a reflection matrix from a plane
  61203. * @param plane defines the reflection plane
  61204. * @returns a new matrix
  61205. */
  61206. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  61207. /**
  61208. * Computes a reflection matrix from a plane
  61209. * @param plane defines the reflection plane
  61210. * @param result defines the target matrix
  61211. */
  61212. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  61213. /**
  61214. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  61215. * @param xaxis defines the value of the 1st axis
  61216. * @param yaxis defines the value of the 2nd axis
  61217. * @param zaxis defines the value of the 3rd axis
  61218. * @param result defines the target matrix
  61219. */
  61220. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  61221. /**
  61222. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  61223. * @param quat defines the quaternion to use
  61224. * @param result defines the target matrix
  61225. */
  61226. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  61227. }
  61228. /**
  61229. * Represens a plane by the equation ax + by + cz + d = 0
  61230. */
  61231. export class Plane {
  61232. /**
  61233. * Normal of the plane (a,b,c)
  61234. */
  61235. normal: Vector3;
  61236. /**
  61237. * d component of the plane
  61238. */
  61239. d: number;
  61240. /**
  61241. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  61242. * @param a a component of the plane
  61243. * @param b b component of the plane
  61244. * @param c c component of the plane
  61245. * @param d d component of the plane
  61246. */
  61247. constructor(a: number, b: number, c: number, d: number);
  61248. /**
  61249. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  61250. */
  61251. asArray(): number[];
  61252. /**
  61253. * @returns a new plane copied from the current Plane.
  61254. */
  61255. clone(): Plane;
  61256. /**
  61257. * @returns the string "Plane".
  61258. */
  61259. getClassName(): string;
  61260. /**
  61261. * @returns the Plane hash code.
  61262. */
  61263. getHashCode(): number;
  61264. /**
  61265. * Normalize the current Plane in place.
  61266. * @returns the updated Plane.
  61267. */
  61268. normalize(): Plane;
  61269. /**
  61270. * Applies a transformation the plane and returns the result
  61271. * @param transformation the transformation matrix to be applied to the plane
  61272. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  61273. */
  61274. transform(transformation: DeepImmutable<Matrix>): Plane;
  61275. /**
  61276. * Calcualtte the dot product between the point and the plane normal
  61277. * @param point point to calculate the dot product with
  61278. * @returns the dot product (float) of the point coordinates and the plane normal.
  61279. */
  61280. dotCoordinate(point: DeepImmutable<Vector3>): number;
  61281. /**
  61282. * Updates the current Plane from the plane defined by the three given points.
  61283. * @param point1 one of the points used to contruct the plane
  61284. * @param point2 one of the points used to contruct the plane
  61285. * @param point3 one of the points used to contruct the plane
  61286. * @returns the updated Plane.
  61287. */
  61288. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  61289. /**
  61290. * Checks if the plane is facing a given direction
  61291. * @param direction the direction to check if the plane is facing
  61292. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  61293. * @returns True is the vector "direction" is the same side than the plane normal.
  61294. */
  61295. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  61296. /**
  61297. * Calculates the distance to a point
  61298. * @param point point to calculate distance to
  61299. * @returns the signed distance (float) from the given point to the Plane.
  61300. */
  61301. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  61302. /**
  61303. * Creates a plane from an array
  61304. * @param array the array to create a plane from
  61305. * @returns a new Plane from the given array.
  61306. */
  61307. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  61308. /**
  61309. * Creates a plane from three points
  61310. * @param point1 point used to create the plane
  61311. * @param point2 point used to create the plane
  61312. * @param point3 point used to create the plane
  61313. * @returns a new Plane defined by the three given points.
  61314. */
  61315. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  61316. /**
  61317. * Creates a plane from an origin point and a normal
  61318. * @param origin origin of the plane to be constructed
  61319. * @param normal normal of the plane to be constructed
  61320. * @returns a new Plane the normal vector to this plane at the given origin point.
  61321. * Note : the vector "normal" is updated because normalized.
  61322. */
  61323. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  61324. /**
  61325. * Calculates the distance from a plane and a point
  61326. * @param origin origin of the plane to be constructed
  61327. * @param normal normal of the plane to be constructed
  61328. * @param point point to calculate distance to
  61329. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  61330. */
  61331. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  61332. }
  61333. /**
  61334. * Class used to represent a viewport on screen
  61335. */
  61336. export class Viewport {
  61337. /** viewport left coordinate */
  61338. x: number;
  61339. /** viewport top coordinate */
  61340. y: number;
  61341. /**viewport width */
  61342. width: number;
  61343. /** viewport height */
  61344. height: number;
  61345. /**
  61346. * Creates a Viewport object located at (x, y) and sized (width, height)
  61347. * @param x defines viewport left coordinate
  61348. * @param y defines viewport top coordinate
  61349. * @param width defines the viewport width
  61350. * @param height defines the viewport height
  61351. */
  61352. constructor(
  61353. /** viewport left coordinate */
  61354. x: number,
  61355. /** viewport top coordinate */
  61356. y: number,
  61357. /**viewport width */
  61358. width: number,
  61359. /** viewport height */
  61360. height: number);
  61361. /**
  61362. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  61363. * @param renderWidth defines the rendering width
  61364. * @param renderHeight defines the rendering height
  61365. * @returns a new Viewport
  61366. */
  61367. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  61368. /**
  61369. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  61370. * @param renderWidth defines the rendering width
  61371. * @param renderHeight defines the rendering height
  61372. * @param ref defines the target viewport
  61373. * @returns the current viewport
  61374. */
  61375. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  61376. /**
  61377. * Returns a new Viewport copied from the current one
  61378. * @returns a new Viewport
  61379. */
  61380. clone(): Viewport;
  61381. }
  61382. /**
  61383. * Reprasents a camera frustum
  61384. */
  61385. export class Frustum {
  61386. /**
  61387. * Gets the planes representing the frustum
  61388. * @param transform matrix to be applied to the returned planes
  61389. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  61390. */
  61391. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  61392. /**
  61393. * Gets the near frustum plane transformed by the transform matrix
  61394. * @param transform transformation matrix to be applied to the resulting frustum plane
  61395. * @param frustumPlane the resuling frustum plane
  61396. */
  61397. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  61398. /**
  61399. * Gets the far frustum plane transformed by the transform matrix
  61400. * @param transform transformation matrix to be applied to the resulting frustum plane
  61401. * @param frustumPlane the resuling frustum plane
  61402. */
  61403. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  61404. /**
  61405. * Gets the left frustum plane transformed by the transform matrix
  61406. * @param transform transformation matrix to be applied to the resulting frustum plane
  61407. * @param frustumPlane the resuling frustum plane
  61408. */
  61409. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  61410. /**
  61411. * Gets the right frustum plane transformed by the transform matrix
  61412. * @param transform transformation matrix to be applied to the resulting frustum plane
  61413. * @param frustumPlane the resuling frustum plane
  61414. */
  61415. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  61416. /**
  61417. * Gets the top frustum plane transformed by the transform matrix
  61418. * @param transform transformation matrix to be applied to the resulting frustum plane
  61419. * @param frustumPlane the resuling frustum plane
  61420. */
  61421. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  61422. /**
  61423. * Gets the bottom frustum plane transformed by the transform matrix
  61424. * @param transform transformation matrix to be applied to the resulting frustum plane
  61425. * @param frustumPlane the resuling frustum plane
  61426. */
  61427. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  61428. /**
  61429. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  61430. * @param transform transformation matrix to be applied to the resulting frustum planes
  61431. * @param frustumPlanes the resuling frustum planes
  61432. */
  61433. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  61434. }
  61435. /** Defines supported spaces */
  61436. export enum Space {
  61437. /** Local (object) space */
  61438. LOCAL = 0,
  61439. /** World space */
  61440. WORLD = 1,
  61441. /** Bone space */
  61442. BONE = 2
  61443. }
  61444. /** Defines the 3 main axes */
  61445. export class Axis {
  61446. /** X axis */
  61447. static X: Vector3;
  61448. /** Y axis */
  61449. static Y: Vector3;
  61450. /** Z axis */
  61451. static Z: Vector3;
  61452. }
  61453. /** Class used to represent a Bezier curve */
  61454. export class BezierCurve {
  61455. /**
  61456. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  61457. * @param t defines the time
  61458. * @param x1 defines the left coordinate on X axis
  61459. * @param y1 defines the left coordinate on Y axis
  61460. * @param x2 defines the right coordinate on X axis
  61461. * @param y2 defines the right coordinate on Y axis
  61462. * @returns the interpolated value
  61463. */
  61464. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  61465. }
  61466. /**
  61467. * Defines potential orientation for back face culling
  61468. */
  61469. export enum Orientation {
  61470. /**
  61471. * Clockwise
  61472. */
  61473. CW = 0,
  61474. /** Counter clockwise */
  61475. CCW = 1
  61476. }
  61477. /**
  61478. * Defines angle representation
  61479. */
  61480. export class Angle {
  61481. private _radians;
  61482. /**
  61483. * Creates an Angle object of "radians" radians (float).
  61484. * @param radians the angle in radians
  61485. */
  61486. constructor(radians: number);
  61487. /**
  61488. * Get value in degrees
  61489. * @returns the Angle value in degrees (float)
  61490. */
  61491. degrees(): number;
  61492. /**
  61493. * Get value in radians
  61494. * @returns the Angle value in radians (float)
  61495. */
  61496. radians(): number;
  61497. /**
  61498. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  61499. * @param a defines first vector
  61500. * @param b defines second vector
  61501. * @returns a new Angle
  61502. */
  61503. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  61504. /**
  61505. * Gets a new Angle object from the given float in radians
  61506. * @param radians defines the angle value in radians
  61507. * @returns a new Angle
  61508. */
  61509. static FromRadians(radians: number): Angle;
  61510. /**
  61511. * Gets a new Angle object from the given float in degrees
  61512. * @param degrees defines the angle value in degrees
  61513. * @returns a new Angle
  61514. */
  61515. static FromDegrees(degrees: number): Angle;
  61516. }
  61517. /**
  61518. * This represents an arc in a 2d space.
  61519. */
  61520. export class Arc2 {
  61521. /** Defines the start point of the arc */
  61522. startPoint: Vector2;
  61523. /** Defines the mid point of the arc */
  61524. midPoint: Vector2;
  61525. /** Defines the end point of the arc */
  61526. endPoint: Vector2;
  61527. /**
  61528. * Defines the center point of the arc.
  61529. */
  61530. centerPoint: Vector2;
  61531. /**
  61532. * Defines the radius of the arc.
  61533. */
  61534. radius: number;
  61535. /**
  61536. * Defines the angle of the arc (from mid point to end point).
  61537. */
  61538. angle: Angle;
  61539. /**
  61540. * Defines the start angle of the arc (from start point to middle point).
  61541. */
  61542. startAngle: Angle;
  61543. /**
  61544. * Defines the orientation of the arc (clock wise/counter clock wise).
  61545. */
  61546. orientation: Orientation;
  61547. /**
  61548. * Creates an Arc object from the three given points : start, middle and end.
  61549. * @param startPoint Defines the start point of the arc
  61550. * @param midPoint Defines the midlle point of the arc
  61551. * @param endPoint Defines the end point of the arc
  61552. */
  61553. constructor(
  61554. /** Defines the start point of the arc */
  61555. startPoint: Vector2,
  61556. /** Defines the mid point of the arc */
  61557. midPoint: Vector2,
  61558. /** Defines the end point of the arc */
  61559. endPoint: Vector2);
  61560. }
  61561. /**
  61562. * Represents a 2D path made up of multiple 2D points
  61563. */
  61564. export class Path2 {
  61565. private _points;
  61566. private _length;
  61567. /**
  61568. * If the path start and end point are the same
  61569. */
  61570. closed: boolean;
  61571. /**
  61572. * Creates a Path2 object from the starting 2D coordinates x and y.
  61573. * @param x the starting points x value
  61574. * @param y the starting points y value
  61575. */
  61576. constructor(x: number, y: number);
  61577. /**
  61578. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  61579. * @param x the added points x value
  61580. * @param y the added points y value
  61581. * @returns the updated Path2.
  61582. */
  61583. addLineTo(x: number, y: number): Path2;
  61584. /**
  61585. * 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.
  61586. * @param midX middle point x value
  61587. * @param midY middle point y value
  61588. * @param endX end point x value
  61589. * @param endY end point y value
  61590. * @param numberOfSegments (default: 36)
  61591. * @returns the updated Path2.
  61592. */
  61593. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  61594. /**
  61595. * Closes the Path2.
  61596. * @returns the Path2.
  61597. */
  61598. close(): Path2;
  61599. /**
  61600. * Gets the sum of the distance between each sequential point in the path
  61601. * @returns the Path2 total length (float).
  61602. */
  61603. length(): number;
  61604. /**
  61605. * Gets the points which construct the path
  61606. * @returns the Path2 internal array of points.
  61607. */
  61608. getPoints(): Vector2[];
  61609. /**
  61610. * Retreives the point at the distance aways from the starting point
  61611. * @param normalizedLengthPosition the length along the path to retreive the point from
  61612. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  61613. */
  61614. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  61615. /**
  61616. * Creates a new path starting from an x and y position
  61617. * @param x starting x value
  61618. * @param y starting y value
  61619. * @returns a new Path2 starting at the coordinates (x, y).
  61620. */
  61621. static StartingAt(x: number, y: number): Path2;
  61622. }
  61623. /**
  61624. * Represents a 3D path made up of multiple 3D points
  61625. */
  61626. export class Path3D {
  61627. /**
  61628. * an array of Vector3, the curve axis of the Path3D
  61629. */
  61630. path: Vector3[];
  61631. private _curve;
  61632. private _distances;
  61633. private _tangents;
  61634. private _normals;
  61635. private _binormals;
  61636. private _raw;
  61637. /**
  61638. * new Path3D(path, normal, raw)
  61639. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  61640. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  61641. * @param path an array of Vector3, the curve axis of the Path3D
  61642. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  61643. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  61644. */
  61645. constructor(
  61646. /**
  61647. * an array of Vector3, the curve axis of the Path3D
  61648. */
  61649. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  61650. /**
  61651. * Returns the Path3D array of successive Vector3 designing its curve.
  61652. * @returns the Path3D array of successive Vector3 designing its curve.
  61653. */
  61654. getCurve(): Vector3[];
  61655. /**
  61656. * Returns an array populated with tangent vectors on each Path3D curve point.
  61657. * @returns an array populated with tangent vectors on each Path3D curve point.
  61658. */
  61659. getTangents(): Vector3[];
  61660. /**
  61661. * Returns an array populated with normal vectors on each Path3D curve point.
  61662. * @returns an array populated with normal vectors on each Path3D curve point.
  61663. */
  61664. getNormals(): Vector3[];
  61665. /**
  61666. * Returns an array populated with binormal vectors on each Path3D curve point.
  61667. * @returns an array populated with binormal vectors on each Path3D curve point.
  61668. */
  61669. getBinormals(): Vector3[];
  61670. /**
  61671. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  61672. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  61673. */
  61674. getDistances(): number[];
  61675. /**
  61676. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  61677. * @param path path which all values are copied into the curves points
  61678. * @param firstNormal which should be projected onto the curve
  61679. * @returns the same object updated.
  61680. */
  61681. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  61682. private _compute;
  61683. private _getFirstNonNullVector;
  61684. private _getLastNonNullVector;
  61685. private _normalVector;
  61686. }
  61687. /**
  61688. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  61689. * A Curve3 is designed from a series of successive Vector3.
  61690. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  61691. */
  61692. export class Curve3 {
  61693. private _points;
  61694. private _length;
  61695. /**
  61696. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  61697. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  61698. * @param v1 (Vector3) the control point
  61699. * @param v2 (Vector3) the end point of the Quadratic Bezier
  61700. * @param nbPoints (integer) the wanted number of points in the curve
  61701. * @returns the created Curve3
  61702. */
  61703. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  61704. /**
  61705. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  61706. * @param v0 (Vector3) the origin point of the Cubic Bezier
  61707. * @param v1 (Vector3) the first control point
  61708. * @param v2 (Vector3) the second control point
  61709. * @param v3 (Vector3) the end point of the Cubic Bezier
  61710. * @param nbPoints (integer) the wanted number of points in the curve
  61711. * @returns the created Curve3
  61712. */
  61713. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  61714. /**
  61715. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  61716. * @param p1 (Vector3) the origin point of the Hermite Spline
  61717. * @param t1 (Vector3) the tangent vector at the origin point
  61718. * @param p2 (Vector3) the end point of the Hermite Spline
  61719. * @param t2 (Vector3) the tangent vector at the end point
  61720. * @param nbPoints (integer) the wanted number of points in the curve
  61721. * @returns the created Curve3
  61722. */
  61723. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  61724. /**
  61725. * Returns a Curve3 object along a CatmullRom Spline curve :
  61726. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  61727. * @param nbPoints (integer) the wanted number of points between each curve control points
  61728. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  61729. * @returns the created Curve3
  61730. */
  61731. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  61732. /**
  61733. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  61734. * A Curve3 is designed from a series of successive Vector3.
  61735. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  61736. * @param points points which make up the curve
  61737. */
  61738. constructor(points: Vector3[]);
  61739. /**
  61740. * @returns the Curve3 stored array of successive Vector3
  61741. */
  61742. getPoints(): Vector3[];
  61743. /**
  61744. * @returns the computed length (float) of the curve.
  61745. */
  61746. length(): number;
  61747. /**
  61748. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  61749. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  61750. * curveA and curveB keep unchanged.
  61751. * @param curve the curve to continue from this curve
  61752. * @returns the newly constructed curve
  61753. */
  61754. continue(curve: DeepImmutable<Curve3>): Curve3;
  61755. private _computeLength;
  61756. }
  61757. /**
  61758. * Contains position and normal vectors for a vertex
  61759. */
  61760. export class PositionNormalVertex {
  61761. /** the position of the vertex (defaut: 0,0,0) */
  61762. position: Vector3;
  61763. /** the normal of the vertex (defaut: 0,1,0) */
  61764. normal: Vector3;
  61765. /**
  61766. * Creates a PositionNormalVertex
  61767. * @param position the position of the vertex (defaut: 0,0,0)
  61768. * @param normal the normal of the vertex (defaut: 0,1,0)
  61769. */
  61770. constructor(
  61771. /** the position of the vertex (defaut: 0,0,0) */
  61772. position?: Vector3,
  61773. /** the normal of the vertex (defaut: 0,1,0) */
  61774. normal?: Vector3);
  61775. /**
  61776. * Clones the PositionNormalVertex
  61777. * @returns the cloned PositionNormalVertex
  61778. */
  61779. clone(): PositionNormalVertex;
  61780. }
  61781. /**
  61782. * Contains position, normal and uv vectors for a vertex
  61783. */
  61784. export class PositionNormalTextureVertex {
  61785. /** the position of the vertex (defaut: 0,0,0) */
  61786. position: Vector3;
  61787. /** the normal of the vertex (defaut: 0,1,0) */
  61788. normal: Vector3;
  61789. /** the uv of the vertex (default: 0,0) */
  61790. uv: Vector2;
  61791. /**
  61792. * Creates a PositionNormalTextureVertex
  61793. * @param position the position of the vertex (defaut: 0,0,0)
  61794. * @param normal the normal of the vertex (defaut: 0,1,0)
  61795. * @param uv the uv of the vertex (default: 0,0)
  61796. */
  61797. constructor(
  61798. /** the position of the vertex (defaut: 0,0,0) */
  61799. position?: Vector3,
  61800. /** the normal of the vertex (defaut: 0,1,0) */
  61801. normal?: Vector3,
  61802. /** the uv of the vertex (default: 0,0) */
  61803. uv?: Vector2);
  61804. /**
  61805. * Clones the PositionNormalTextureVertex
  61806. * @returns the cloned PositionNormalTextureVertex
  61807. */
  61808. clone(): PositionNormalTextureVertex;
  61809. }
  61810. /**
  61811. * @hidden
  61812. */
  61813. export class Tmp {
  61814. static Color3: Color3[];
  61815. static Color4: Color4[];
  61816. static Vector2: Vector2[];
  61817. static Vector3: Vector3[];
  61818. static Vector4: Vector4[];
  61819. static Quaternion: Quaternion[];
  61820. static Matrix: Matrix[];
  61821. }
  61822. }
  61823. declare module BABYLON {
  61824. /**
  61825. * Class used to enable access to offline support
  61826. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  61827. */
  61828. export interface IOfflineProvider {
  61829. /**
  61830. * Gets a boolean indicating if scene must be saved in the database
  61831. */
  61832. enableSceneOffline: boolean;
  61833. /**
  61834. * Gets a boolean indicating if textures must be saved in the database
  61835. */
  61836. enableTexturesOffline: boolean;
  61837. /**
  61838. * Open the offline support and make it available
  61839. * @param successCallback defines the callback to call on success
  61840. * @param errorCallback defines the callback to call on error
  61841. */
  61842. open(successCallback: () => void, errorCallback: () => void): void;
  61843. /**
  61844. * Loads an image from the offline support
  61845. * @param url defines the url to load from
  61846. * @param image defines the target DOM image
  61847. */
  61848. loadImage(url: string, image: HTMLImageElement): void;
  61849. /**
  61850. * Loads a file from offline support
  61851. * @param url defines the URL to load from
  61852. * @param sceneLoaded defines a callback to call on success
  61853. * @param progressCallBack defines a callback to call when progress changed
  61854. * @param errorCallback defines a callback to call on error
  61855. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  61856. */
  61857. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  61858. }
  61859. }
  61860. declare module BABYLON {
  61861. /**
  61862. * A class serves as a medium between the observable and its observers
  61863. */
  61864. export class EventState {
  61865. /**
  61866. * Create a new EventState
  61867. * @param mask defines the mask associated with this state
  61868. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  61869. * @param target defines the original target of the state
  61870. * @param currentTarget defines the current target of the state
  61871. */
  61872. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  61873. /**
  61874. * Initialize the current event state
  61875. * @param mask defines the mask associated with this state
  61876. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  61877. * @param target defines the original target of the state
  61878. * @param currentTarget defines the current target of the state
  61879. * @returns the current event state
  61880. */
  61881. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  61882. /**
  61883. * An Observer can set this property to true to prevent subsequent observers of being notified
  61884. */
  61885. skipNextObservers: boolean;
  61886. /**
  61887. * Get the mask value that were used to trigger the event corresponding to this EventState object
  61888. */
  61889. mask: number;
  61890. /**
  61891. * The object that originally notified the event
  61892. */
  61893. target?: any;
  61894. /**
  61895. * The current object in the bubbling phase
  61896. */
  61897. currentTarget?: any;
  61898. /**
  61899. * This will be populated with the return value of the last function that was executed.
  61900. * If it is the first function in the callback chain it will be the event data.
  61901. */
  61902. lastReturnValue?: any;
  61903. }
  61904. /**
  61905. * Represent an Observer registered to a given Observable object.
  61906. */
  61907. export class Observer<T> {
  61908. /**
  61909. * Defines the callback to call when the observer is notified
  61910. */
  61911. callback: (eventData: T, eventState: EventState) => void;
  61912. /**
  61913. * Defines the mask of the observer (used to filter notifications)
  61914. */
  61915. mask: number;
  61916. /**
  61917. * Defines the current scope used to restore the JS context
  61918. */
  61919. scope: any;
  61920. /** @hidden */
  61921. _willBeUnregistered: boolean;
  61922. /**
  61923. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  61924. */
  61925. unregisterOnNextCall: boolean;
  61926. /**
  61927. * Creates a new observer
  61928. * @param callback defines the callback to call when the observer is notified
  61929. * @param mask defines the mask of the observer (used to filter notifications)
  61930. * @param scope defines the current scope used to restore the JS context
  61931. */
  61932. constructor(
  61933. /**
  61934. * Defines the callback to call when the observer is notified
  61935. */
  61936. callback: (eventData: T, eventState: EventState) => void,
  61937. /**
  61938. * Defines the mask of the observer (used to filter notifications)
  61939. */
  61940. mask: number,
  61941. /**
  61942. * Defines the current scope used to restore the JS context
  61943. */
  61944. scope?: any);
  61945. }
  61946. /**
  61947. * Represent a list of observers registered to multiple Observables object.
  61948. */
  61949. export class MultiObserver<T> {
  61950. private _observers;
  61951. private _observables;
  61952. /**
  61953. * Release associated resources
  61954. */
  61955. dispose(): void;
  61956. /**
  61957. * Raise a callback when one of the observable will notify
  61958. * @param observables defines a list of observables to watch
  61959. * @param callback defines the callback to call on notification
  61960. * @param mask defines the mask used to filter notifications
  61961. * @param scope defines the current scope used to restore the JS context
  61962. * @returns the new MultiObserver
  61963. */
  61964. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  61965. }
  61966. /**
  61967. * The Observable class is a simple implementation of the Observable pattern.
  61968. *
  61969. * 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.
  61970. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  61971. * 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).
  61972. * 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.
  61973. */
  61974. export class Observable<T> {
  61975. private _observers;
  61976. private _eventState;
  61977. private _onObserverAdded;
  61978. /**
  61979. * Creates a new observable
  61980. * @param onObserverAdded defines a callback to call when a new observer is added
  61981. */
  61982. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  61983. /**
  61984. * Create a new Observer with the specified callback
  61985. * @param callback the callback that will be executed for that Observer
  61986. * @param mask the mask used to filter observers
  61987. * @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.
  61988. * @param scope optional scope for the callback to be called from
  61989. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  61990. * @returns the new observer created for the callback
  61991. */
  61992. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  61993. /**
  61994. * Create a new Observer with the specified callback and unregisters after the next notification
  61995. * @param callback the callback that will be executed for that Observer
  61996. * @returns the new observer created for the callback
  61997. */
  61998. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  61999. /**
  62000. * Remove an Observer from the Observable object
  62001. * @param observer the instance of the Observer to remove
  62002. * @returns false if it doesn't belong to this Observable
  62003. */
  62004. remove(observer: Nullable<Observer<T>>): boolean;
  62005. /**
  62006. * Remove a callback from the Observable object
  62007. * @param callback the callback to remove
  62008. * @param scope optional scope. If used only the callbacks with this scope will be removed
  62009. * @returns false if it doesn't belong to this Observable
  62010. */
  62011. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  62012. private _deferUnregister;
  62013. private _remove;
  62014. /**
  62015. * Notify all Observers by calling their respective callback with the given data
  62016. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  62017. * @param eventData defines the data to send to all observers
  62018. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  62019. * @param target defines the original target of the state
  62020. * @param currentTarget defines the current target of the state
  62021. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  62022. */
  62023. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  62024. /**
  62025. * Calling this will execute each callback, expecting it to be a promise or return a value.
  62026. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  62027. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  62028. * and it is crucial that all callbacks will be executed.
  62029. * The order of the callbacks is kept, callbacks are not executed parallel.
  62030. *
  62031. * @param eventData The data to be sent to each callback
  62032. * @param mask is used to filter observers defaults to -1
  62033. * @param target defines the callback target (see EventState)
  62034. * @param currentTarget defines he current object in the bubbling phase
  62035. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  62036. */
  62037. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  62038. /**
  62039. * Notify a specific observer
  62040. * @param observer defines the observer to notify
  62041. * @param eventData defines the data to be sent to each callback
  62042. * @param mask is used to filter observers defaults to -1
  62043. */
  62044. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  62045. /**
  62046. * Gets a boolean indicating if the observable has at least one observer
  62047. * @returns true is the Observable has at least one Observer registered
  62048. */
  62049. hasObservers(): boolean;
  62050. /**
  62051. * Clear the list of observers
  62052. */
  62053. clear(): void;
  62054. /**
  62055. * Clone the current observable
  62056. * @returns a new observable
  62057. */
  62058. clone(): Observable<T>;
  62059. /**
  62060. * Does this observable handles observer registered with a given mask
  62061. * @param mask defines the mask to be tested
  62062. * @return whether or not one observer registered with the given mask is handeled
  62063. **/
  62064. hasSpecificMask(mask?: number): boolean;
  62065. }
  62066. }
  62067. declare module BABYLON {
  62068. /**
  62069. * Class used to help managing file picking and drag'n'drop
  62070. * File Storage
  62071. */
  62072. export class FilesInputStore {
  62073. /**
  62074. * List of files ready to be loaded
  62075. */
  62076. static FilesToLoad: {
  62077. [key: string]: File;
  62078. };
  62079. }
  62080. }
  62081. declare module BABYLON {
  62082. /** Defines the cross module used constants to avoid circular dependncies */
  62083. export class Constants {
  62084. /** Defines that alpha blending is disabled */
  62085. static readonly ALPHA_DISABLE: number;
  62086. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  62087. static readonly ALPHA_ADD: number;
  62088. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  62089. static readonly ALPHA_COMBINE: number;
  62090. /** Defines that alpha blending to DEST - SRC * DEST */
  62091. static readonly ALPHA_SUBTRACT: number;
  62092. /** Defines that alpha blending to SRC * DEST */
  62093. static readonly ALPHA_MULTIPLY: number;
  62094. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  62095. static readonly ALPHA_MAXIMIZED: number;
  62096. /** Defines that alpha blending to SRC + DEST */
  62097. static readonly ALPHA_ONEONE: number;
  62098. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  62099. static readonly ALPHA_PREMULTIPLIED: number;
  62100. /**
  62101. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  62102. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  62103. */
  62104. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  62105. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  62106. static readonly ALPHA_INTERPOLATE: number;
  62107. /**
  62108. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  62109. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  62110. */
  62111. static readonly ALPHA_SCREENMODE: number;
  62112. /** Defines that the ressource is not delayed*/
  62113. static readonly DELAYLOADSTATE_NONE: number;
  62114. /** Defines that the ressource was successfully delay loaded */
  62115. static readonly DELAYLOADSTATE_LOADED: number;
  62116. /** Defines that the ressource is currently delay loading */
  62117. static readonly DELAYLOADSTATE_LOADING: number;
  62118. /** Defines that the ressource is delayed and has not started loading */
  62119. static readonly DELAYLOADSTATE_NOTLOADED: number;
  62120. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  62121. static readonly NEVER: number;
  62122. /** 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 */
  62123. static readonly ALWAYS: number;
  62124. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  62125. static readonly LESS: number;
  62126. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  62127. static readonly EQUAL: number;
  62128. /** 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 */
  62129. static readonly LEQUAL: number;
  62130. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  62131. static readonly GREATER: number;
  62132. /** 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 */
  62133. static readonly GEQUAL: number;
  62134. /** 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 */
  62135. static readonly NOTEQUAL: number;
  62136. /** Passed to stencilOperation to specify that stencil value must be kept */
  62137. static readonly KEEP: number;
  62138. /** Passed to stencilOperation to specify that stencil value must be replaced */
  62139. static readonly REPLACE: number;
  62140. /** Passed to stencilOperation to specify that stencil value must be incremented */
  62141. static readonly INCR: number;
  62142. /** Passed to stencilOperation to specify that stencil value must be decremented */
  62143. static readonly DECR: number;
  62144. /** Passed to stencilOperation to specify that stencil value must be inverted */
  62145. static readonly INVERT: number;
  62146. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  62147. static readonly INCR_WRAP: number;
  62148. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  62149. static readonly DECR_WRAP: number;
  62150. /** Texture is not repeating outside of 0..1 UVs */
  62151. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  62152. /** Texture is repeating outside of 0..1 UVs */
  62153. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  62154. /** Texture is repeating and mirrored */
  62155. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  62156. /** ALPHA */
  62157. static readonly TEXTUREFORMAT_ALPHA: number;
  62158. /** LUMINANCE */
  62159. static readonly TEXTUREFORMAT_LUMINANCE: number;
  62160. /** LUMINANCE_ALPHA */
  62161. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  62162. /** RGB */
  62163. static readonly TEXTUREFORMAT_RGB: number;
  62164. /** RGBA */
  62165. static readonly TEXTUREFORMAT_RGBA: number;
  62166. /** RED */
  62167. static readonly TEXTUREFORMAT_RED: number;
  62168. /** RED (2nd reference) */
  62169. static readonly TEXTUREFORMAT_R: number;
  62170. /** RG */
  62171. static readonly TEXTUREFORMAT_RG: number;
  62172. /** RED_INTEGER */
  62173. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  62174. /** RED_INTEGER (2nd reference) */
  62175. static readonly TEXTUREFORMAT_R_INTEGER: number;
  62176. /** RG_INTEGER */
  62177. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  62178. /** RGB_INTEGER */
  62179. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  62180. /** RGBA_INTEGER */
  62181. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  62182. /** UNSIGNED_BYTE */
  62183. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  62184. /** UNSIGNED_BYTE (2nd reference) */
  62185. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  62186. /** FLOAT */
  62187. static readonly TEXTURETYPE_FLOAT: number;
  62188. /** HALF_FLOAT */
  62189. static readonly TEXTURETYPE_HALF_FLOAT: number;
  62190. /** BYTE */
  62191. static readonly TEXTURETYPE_BYTE: number;
  62192. /** SHORT */
  62193. static readonly TEXTURETYPE_SHORT: number;
  62194. /** UNSIGNED_SHORT */
  62195. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  62196. /** INT */
  62197. static readonly TEXTURETYPE_INT: number;
  62198. /** UNSIGNED_INT */
  62199. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  62200. /** UNSIGNED_SHORT_4_4_4_4 */
  62201. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  62202. /** UNSIGNED_SHORT_5_5_5_1 */
  62203. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  62204. /** UNSIGNED_SHORT_5_6_5 */
  62205. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  62206. /** UNSIGNED_INT_2_10_10_10_REV */
  62207. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  62208. /** UNSIGNED_INT_24_8 */
  62209. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  62210. /** UNSIGNED_INT_10F_11F_11F_REV */
  62211. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  62212. /** UNSIGNED_INT_5_9_9_9_REV */
  62213. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  62214. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  62215. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  62216. /** nearest is mag = nearest and min = nearest and mip = linear */
  62217. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  62218. /** Bilinear is mag = linear and min = linear and mip = nearest */
  62219. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  62220. /** Trilinear is mag = linear and min = linear and mip = linear */
  62221. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  62222. /** nearest is mag = nearest and min = nearest and mip = linear */
  62223. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  62224. /** Bilinear is mag = linear and min = linear and mip = nearest */
  62225. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  62226. /** Trilinear is mag = linear and min = linear and mip = linear */
  62227. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  62228. /** mag = nearest and min = nearest and mip = nearest */
  62229. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  62230. /** mag = nearest and min = linear and mip = nearest */
  62231. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  62232. /** mag = nearest and min = linear and mip = linear */
  62233. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  62234. /** mag = nearest and min = linear and mip = none */
  62235. static readonly TEXTURE_NEAREST_LINEAR: number;
  62236. /** mag = nearest and min = nearest and mip = none */
  62237. static readonly TEXTURE_NEAREST_NEAREST: number;
  62238. /** mag = linear and min = nearest and mip = nearest */
  62239. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  62240. /** mag = linear and min = nearest and mip = linear */
  62241. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  62242. /** mag = linear and min = linear and mip = none */
  62243. static readonly TEXTURE_LINEAR_LINEAR: number;
  62244. /** mag = linear and min = nearest and mip = none */
  62245. static readonly TEXTURE_LINEAR_NEAREST: number;
  62246. /** Explicit coordinates mode */
  62247. static readonly TEXTURE_EXPLICIT_MODE: number;
  62248. /** Spherical coordinates mode */
  62249. static readonly TEXTURE_SPHERICAL_MODE: number;
  62250. /** Planar coordinates mode */
  62251. static readonly TEXTURE_PLANAR_MODE: number;
  62252. /** Cubic coordinates mode */
  62253. static readonly TEXTURE_CUBIC_MODE: number;
  62254. /** Projection coordinates mode */
  62255. static readonly TEXTURE_PROJECTION_MODE: number;
  62256. /** Skybox coordinates mode */
  62257. static readonly TEXTURE_SKYBOX_MODE: number;
  62258. /** Inverse Cubic coordinates mode */
  62259. static readonly TEXTURE_INVCUBIC_MODE: number;
  62260. /** Equirectangular coordinates mode */
  62261. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  62262. /** Equirectangular Fixed coordinates mode */
  62263. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  62264. /** Equirectangular Fixed Mirrored coordinates mode */
  62265. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  62266. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  62267. static readonly SCALEMODE_FLOOR: number;
  62268. /** Defines that texture rescaling will look for the nearest power of 2 size */
  62269. static readonly SCALEMODE_NEAREST: number;
  62270. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  62271. static readonly SCALEMODE_CEILING: number;
  62272. /**
  62273. * The dirty texture flag value
  62274. */
  62275. static readonly MATERIAL_TextureDirtyFlag: number;
  62276. /**
  62277. * The dirty light flag value
  62278. */
  62279. static readonly MATERIAL_LightDirtyFlag: number;
  62280. /**
  62281. * The dirty fresnel flag value
  62282. */
  62283. static readonly MATERIAL_FresnelDirtyFlag: number;
  62284. /**
  62285. * The dirty attribute flag value
  62286. */
  62287. static readonly MATERIAL_AttributesDirtyFlag: number;
  62288. /**
  62289. * The dirty misc flag value
  62290. */
  62291. static readonly MATERIAL_MiscDirtyFlag: number;
  62292. /**
  62293. * The all dirty flag value
  62294. */
  62295. static readonly MATERIAL_AllDirtyFlag: number;
  62296. /**
  62297. * Returns the triangle fill mode
  62298. */
  62299. static readonly MATERIAL_TriangleFillMode: number;
  62300. /**
  62301. * Returns the wireframe mode
  62302. */
  62303. static readonly MATERIAL_WireFrameFillMode: number;
  62304. /**
  62305. * Returns the point fill mode
  62306. */
  62307. static readonly MATERIAL_PointFillMode: number;
  62308. /**
  62309. * Returns the point list draw mode
  62310. */
  62311. static readonly MATERIAL_PointListDrawMode: number;
  62312. /**
  62313. * Returns the line list draw mode
  62314. */
  62315. static readonly MATERIAL_LineListDrawMode: number;
  62316. /**
  62317. * Returns the line loop draw mode
  62318. */
  62319. static readonly MATERIAL_LineLoopDrawMode: number;
  62320. /**
  62321. * Returns the line strip draw mode
  62322. */
  62323. static readonly MATERIAL_LineStripDrawMode: number;
  62324. /**
  62325. * Returns the triangle strip draw mode
  62326. */
  62327. static readonly MATERIAL_TriangleStripDrawMode: number;
  62328. /**
  62329. * Returns the triangle fan draw mode
  62330. */
  62331. static readonly MATERIAL_TriangleFanDrawMode: number;
  62332. /**
  62333. * Stores the clock-wise side orientation
  62334. */
  62335. static readonly MATERIAL_ClockWiseSideOrientation: number;
  62336. /**
  62337. * Stores the counter clock-wise side orientation
  62338. */
  62339. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  62340. /**
  62341. * Nothing
  62342. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62343. */
  62344. static readonly ACTION_NothingTrigger: number;
  62345. /**
  62346. * On pick
  62347. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62348. */
  62349. static readonly ACTION_OnPickTrigger: number;
  62350. /**
  62351. * On left pick
  62352. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62353. */
  62354. static readonly ACTION_OnLeftPickTrigger: number;
  62355. /**
  62356. * On right pick
  62357. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62358. */
  62359. static readonly ACTION_OnRightPickTrigger: number;
  62360. /**
  62361. * On center pick
  62362. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62363. */
  62364. static readonly ACTION_OnCenterPickTrigger: number;
  62365. /**
  62366. * On pick down
  62367. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62368. */
  62369. static readonly ACTION_OnPickDownTrigger: number;
  62370. /**
  62371. * On double pick
  62372. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62373. */
  62374. static readonly ACTION_OnDoublePickTrigger: number;
  62375. /**
  62376. * On pick up
  62377. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62378. */
  62379. static readonly ACTION_OnPickUpTrigger: number;
  62380. /**
  62381. * On pick out.
  62382. * This trigger will only be raised if you also declared a OnPickDown
  62383. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62384. */
  62385. static readonly ACTION_OnPickOutTrigger: number;
  62386. /**
  62387. * On long press
  62388. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62389. */
  62390. static readonly ACTION_OnLongPressTrigger: number;
  62391. /**
  62392. * On pointer over
  62393. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62394. */
  62395. static readonly ACTION_OnPointerOverTrigger: number;
  62396. /**
  62397. * On pointer out
  62398. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62399. */
  62400. static readonly ACTION_OnPointerOutTrigger: number;
  62401. /**
  62402. * On every frame
  62403. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62404. */
  62405. static readonly ACTION_OnEveryFrameTrigger: number;
  62406. /**
  62407. * On intersection enter
  62408. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62409. */
  62410. static readonly ACTION_OnIntersectionEnterTrigger: number;
  62411. /**
  62412. * On intersection exit
  62413. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62414. */
  62415. static readonly ACTION_OnIntersectionExitTrigger: number;
  62416. /**
  62417. * On key down
  62418. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62419. */
  62420. static readonly ACTION_OnKeyDownTrigger: number;
  62421. /**
  62422. * On key up
  62423. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62424. */
  62425. static readonly ACTION_OnKeyUpTrigger: number;
  62426. /**
  62427. * Billboard mode will only apply to Y axis
  62428. */
  62429. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  62430. /**
  62431. * Billboard mode will apply to all axes
  62432. */
  62433. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  62434. /**
  62435. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  62436. */
  62437. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  62438. /**
  62439. * Gets or sets base Assets URL
  62440. */
  62441. static readonly PARTICLES_BaseAssetsUrl: string;
  62442. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  62443. * Test order :
  62444. * Is the bounding sphere outside the frustum ?
  62445. * If not, are the bounding box vertices outside the frustum ?
  62446. * It not, then the cullable object is in the frustum.
  62447. */
  62448. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  62449. /** Culling strategy : Bounding Sphere Only.
  62450. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  62451. * It's also less accurate than the standard because some not visible objects can still be selected.
  62452. * Test : is the bounding sphere outside the frustum ?
  62453. * If not, then the cullable object is in the frustum.
  62454. */
  62455. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  62456. /** Culling strategy : Optimistic Inclusion.
  62457. * This in an inclusion test first, then the standard exclusion test.
  62458. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  62459. * 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.
  62460. * Anyway, it's as accurate as the standard strategy.
  62461. * Test :
  62462. * Is the cullable object bounding sphere center in the frustum ?
  62463. * If not, apply the default culling strategy.
  62464. */
  62465. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  62466. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  62467. * This in an inclusion test first, then the bounding sphere only exclusion test.
  62468. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  62469. * 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.
  62470. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  62471. * Test :
  62472. * Is the cullable object bounding sphere center in the frustum ?
  62473. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  62474. */
  62475. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  62476. /**
  62477. * No logging while loading
  62478. */
  62479. static readonly SCENELOADER_NO_LOGGING: number;
  62480. /**
  62481. * Minimal logging while loading
  62482. */
  62483. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  62484. /**
  62485. * Summary logging while loading
  62486. */
  62487. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  62488. /**
  62489. * Detailled logging while loading
  62490. */
  62491. static readonly SCENELOADER_DETAILED_LOGGING: number;
  62492. }
  62493. }
  62494. declare module BABYLON {
  62495. /**
  62496. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  62497. * Babylon.js
  62498. */
  62499. export class DomManagement {
  62500. /**
  62501. * Checks if the window object exists
  62502. * @returns true if the window object exists
  62503. */
  62504. static IsWindowObjectExist(): boolean;
  62505. /**
  62506. * Extracts text content from a DOM element hierarchy
  62507. * @param element defines the root element
  62508. * @returns a string
  62509. */
  62510. static GetDOMTextContent(element: HTMLElement): string;
  62511. }
  62512. }
  62513. declare module BABYLON {
  62514. /**
  62515. * Logger used througouht the application to allow configuration of
  62516. * the log level required for the messages.
  62517. */
  62518. export class Logger {
  62519. /**
  62520. * No log
  62521. */
  62522. static readonly NoneLogLevel: number;
  62523. /**
  62524. * Only message logs
  62525. */
  62526. static readonly MessageLogLevel: number;
  62527. /**
  62528. * Only warning logs
  62529. */
  62530. static readonly WarningLogLevel: number;
  62531. /**
  62532. * Only error logs
  62533. */
  62534. static readonly ErrorLogLevel: number;
  62535. /**
  62536. * All logs
  62537. */
  62538. static readonly AllLogLevel: number;
  62539. private static _LogCache;
  62540. /**
  62541. * Gets a value indicating the number of loading errors
  62542. * @ignorenaming
  62543. */
  62544. static errorsCount: number;
  62545. /**
  62546. * Callback called when a new log is added
  62547. */
  62548. static OnNewCacheEntry: (entry: string) => void;
  62549. private static _AddLogEntry;
  62550. private static _FormatMessage;
  62551. private static _LogDisabled;
  62552. private static _LogEnabled;
  62553. private static _WarnDisabled;
  62554. private static _WarnEnabled;
  62555. private static _ErrorDisabled;
  62556. private static _ErrorEnabled;
  62557. /**
  62558. * Log a message to the console
  62559. */
  62560. static Log: (message: string) => void;
  62561. /**
  62562. * Write a warning message to the console
  62563. */
  62564. static Warn: (message: string) => void;
  62565. /**
  62566. * Write an error message to the console
  62567. */
  62568. static Error: (message: string) => void;
  62569. /**
  62570. * Gets current log cache (list of logs)
  62571. */
  62572. static readonly LogCache: string;
  62573. /**
  62574. * Clears the log cache
  62575. */
  62576. static ClearLogCache(): void;
  62577. /**
  62578. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  62579. */
  62580. static LogLevels: number;
  62581. }
  62582. }
  62583. declare module BABYLON {
  62584. /** @hidden */
  62585. export class _TypeStore {
  62586. /** @hidden */
  62587. static RegisteredTypes: {
  62588. [key: string]: Object;
  62589. };
  62590. /** @hidden */
  62591. static GetClass(fqdn: string): any;
  62592. }
  62593. }
  62594. declare module BABYLON {
  62595. /**
  62596. * Class containing a set of static utilities functions for deep copy.
  62597. */
  62598. export class DeepCopier {
  62599. /**
  62600. * Tries to copy an object by duplicating every property
  62601. * @param source defines the source object
  62602. * @param destination defines the target object
  62603. * @param doNotCopyList defines a list of properties to avoid
  62604. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  62605. */
  62606. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  62607. }
  62608. }
  62609. declare module BABYLON {
  62610. /**
  62611. * Class containing a set of static utilities functions for precision date
  62612. */
  62613. export class PrecisionDate {
  62614. /**
  62615. * Gets either window.performance.now() if supported or Date.now() else
  62616. */
  62617. static readonly Now: number;
  62618. }
  62619. }
  62620. declare module BABYLON {
  62621. /** @hidden */
  62622. export class _DevTools {
  62623. static WarnImport(name: string): string;
  62624. }
  62625. }
  62626. declare module BABYLON {
  62627. /**
  62628. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  62629. */
  62630. export class WebRequest extends XMLHttpRequest {
  62631. /**
  62632. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  62633. * i.e. when loading files, where the server/service expects an Authorization header
  62634. */
  62635. static CustomRequestHeaders: {
  62636. [key: string]: string;
  62637. };
  62638. /**
  62639. * Add callback functions in this array to update all the requests before they get sent to the network
  62640. */
  62641. static CustomRequestModifiers: ((request: WebRequest) => void)[];
  62642. private _injectCustomRequestHeaders;
  62643. open(method: string, url: string): void;
  62644. }
  62645. }
  62646. declare module BABYLON {
  62647. /**
  62648. * Class used to evalaute queries containing `and` and `or` operators
  62649. */
  62650. export class AndOrNotEvaluator {
  62651. /**
  62652. * Evaluate a query
  62653. * @param query defines the query to evaluate
  62654. * @param evaluateCallback defines the callback used to filter result
  62655. * @returns true if the query matches
  62656. */
  62657. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  62658. private static _HandleParenthesisContent;
  62659. private static _SimplifyNegation;
  62660. }
  62661. }
  62662. declare module BABYLON {
  62663. /**
  62664. * Class used to store custom tags
  62665. */
  62666. export class Tags {
  62667. /**
  62668. * Adds support for tags on the given object
  62669. * @param obj defines the object to use
  62670. */
  62671. static EnableFor(obj: any): void;
  62672. /**
  62673. * Removes tags support
  62674. * @param obj defines the object to use
  62675. */
  62676. static DisableFor(obj: any): void;
  62677. /**
  62678. * Gets a boolean indicating if the given object has tags
  62679. * @param obj defines the object to use
  62680. * @returns a boolean
  62681. */
  62682. static HasTags(obj: any): boolean;
  62683. /**
  62684. * Gets the tags available on a given object
  62685. * @param obj defines the object to use
  62686. * @param asString defines if the tags must be returned as a string instead of an array of strings
  62687. * @returns the tags
  62688. */
  62689. static GetTags(obj: any, asString?: boolean): any;
  62690. /**
  62691. * Adds tags to an object
  62692. * @param obj defines the object to use
  62693. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  62694. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  62695. */
  62696. static AddTagsTo(obj: any, tagsString: string): void;
  62697. /**
  62698. * @hidden
  62699. */
  62700. static _AddTagTo(obj: any, tag: string): void;
  62701. /**
  62702. * Removes specific tags from a specific object
  62703. * @param obj defines the object to use
  62704. * @param tagsString defines the tags to remove
  62705. */
  62706. static RemoveTagsFrom(obj: any, tagsString: string): void;
  62707. /**
  62708. * @hidden
  62709. */
  62710. static _RemoveTagFrom(obj: any, tag: string): void;
  62711. /**
  62712. * Defines if tags hosted on an object match a given query
  62713. * @param obj defines the object to use
  62714. * @param tagsQuery defines the tag query
  62715. * @returns a boolean
  62716. */
  62717. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  62718. }
  62719. }
  62720. declare module BABYLON {
  62721. /**
  62722. * Manages the defines for the Material
  62723. */
  62724. export class MaterialDefines {
  62725. private _keys;
  62726. private _isDirty;
  62727. /** @hidden */
  62728. _renderId: number;
  62729. /** @hidden */
  62730. _areLightsDirty: boolean;
  62731. /** @hidden */
  62732. _areAttributesDirty: boolean;
  62733. /** @hidden */
  62734. _areTexturesDirty: boolean;
  62735. /** @hidden */
  62736. _areFresnelDirty: boolean;
  62737. /** @hidden */
  62738. _areMiscDirty: boolean;
  62739. /** @hidden */
  62740. _areImageProcessingDirty: boolean;
  62741. /** @hidden */
  62742. _normals: boolean;
  62743. /** @hidden */
  62744. _uvs: boolean;
  62745. /** @hidden */
  62746. _needNormals: boolean;
  62747. /** @hidden */
  62748. _needUVs: boolean;
  62749. /**
  62750. * Specifies if the material needs to be re-calculated
  62751. */
  62752. readonly isDirty: boolean;
  62753. /**
  62754. * Marks the material to indicate that it has been re-calculated
  62755. */
  62756. markAsProcessed(): void;
  62757. /**
  62758. * Marks the material to indicate that it needs to be re-calculated
  62759. */
  62760. markAsUnprocessed(): void;
  62761. /**
  62762. * Marks the material to indicate all of its defines need to be re-calculated
  62763. */
  62764. markAllAsDirty(): void;
  62765. /**
  62766. * Marks the material to indicate that image processing needs to be re-calculated
  62767. */
  62768. markAsImageProcessingDirty(): void;
  62769. /**
  62770. * Marks the material to indicate the lights need to be re-calculated
  62771. */
  62772. markAsLightDirty(): void;
  62773. /**
  62774. * Marks the attribute state as changed
  62775. */
  62776. markAsAttributesDirty(): void;
  62777. /**
  62778. * Marks the texture state as changed
  62779. */
  62780. markAsTexturesDirty(): void;
  62781. /**
  62782. * Marks the fresnel state as changed
  62783. */
  62784. markAsFresnelDirty(): void;
  62785. /**
  62786. * Marks the misc state as changed
  62787. */
  62788. markAsMiscDirty(): void;
  62789. /**
  62790. * Rebuilds the material defines
  62791. */
  62792. rebuild(): void;
  62793. /**
  62794. * Specifies if two material defines are equal
  62795. * @param other - A material define instance to compare to
  62796. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  62797. */
  62798. isEqual(other: MaterialDefines): boolean;
  62799. /**
  62800. * Clones this instance's defines to another instance
  62801. * @param other - material defines to clone values to
  62802. */
  62803. cloneTo(other: MaterialDefines): void;
  62804. /**
  62805. * Resets the material define values
  62806. */
  62807. reset(): void;
  62808. /**
  62809. * Converts the material define values to a string
  62810. * @returns - String of material define information
  62811. */
  62812. toString(): string;
  62813. }
  62814. }
  62815. declare module BABYLON {
  62816. /**
  62817. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  62818. */
  62819. export class PerformanceMonitor {
  62820. private _enabled;
  62821. private _rollingFrameTime;
  62822. private _lastFrameTimeMs;
  62823. /**
  62824. * constructor
  62825. * @param frameSampleSize The number of samples required to saturate the sliding window
  62826. */
  62827. constructor(frameSampleSize?: number);
  62828. /**
  62829. * Samples current frame
  62830. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  62831. */
  62832. sampleFrame(timeMs?: number): void;
  62833. /**
  62834. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  62835. */
  62836. readonly averageFrameTime: number;
  62837. /**
  62838. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  62839. */
  62840. readonly averageFrameTimeVariance: number;
  62841. /**
  62842. * Returns the frame time of the most recent frame
  62843. */
  62844. readonly instantaneousFrameTime: number;
  62845. /**
  62846. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  62847. */
  62848. readonly averageFPS: number;
  62849. /**
  62850. * Returns the average framerate in frames per second using the most recent frame time
  62851. */
  62852. readonly instantaneousFPS: number;
  62853. /**
  62854. * Returns true if enough samples have been taken to completely fill the sliding window
  62855. */
  62856. readonly isSaturated: boolean;
  62857. /**
  62858. * Enables contributions to the sliding window sample set
  62859. */
  62860. enable(): void;
  62861. /**
  62862. * Disables contributions to the sliding window sample set
  62863. * Samples will not be interpolated over the disabled period
  62864. */
  62865. disable(): void;
  62866. /**
  62867. * Returns true if sampling is enabled
  62868. */
  62869. readonly isEnabled: boolean;
  62870. /**
  62871. * Resets performance monitor
  62872. */
  62873. reset(): void;
  62874. }
  62875. /**
  62876. * RollingAverage
  62877. *
  62878. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  62879. */
  62880. export class RollingAverage {
  62881. /**
  62882. * Current average
  62883. */
  62884. average: number;
  62885. /**
  62886. * Current variance
  62887. */
  62888. variance: number;
  62889. protected _samples: Array<number>;
  62890. protected _sampleCount: number;
  62891. protected _pos: number;
  62892. protected _m2: number;
  62893. /**
  62894. * constructor
  62895. * @param length The number of samples required to saturate the sliding window
  62896. */
  62897. constructor(length: number);
  62898. /**
  62899. * Adds a sample to the sample set
  62900. * @param v The sample value
  62901. */
  62902. add(v: number): void;
  62903. /**
  62904. * Returns previously added values or null if outside of history or outside the sliding window domain
  62905. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  62906. * @return Value previously recorded with add() or null if outside of range
  62907. */
  62908. history(i: number): number;
  62909. /**
  62910. * Returns true if enough samples have been taken to completely fill the sliding window
  62911. * @return true if sample-set saturated
  62912. */
  62913. isSaturated(): boolean;
  62914. /**
  62915. * Resets the rolling average (equivalent to 0 samples taken so far)
  62916. */
  62917. reset(): void;
  62918. /**
  62919. * Wraps a value around the sample range boundaries
  62920. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  62921. * @return Wrapped position in sample range
  62922. */
  62923. protected _wrapPosition(i: number): number;
  62924. }
  62925. }
  62926. declare module BABYLON {
  62927. /**
  62928. * This class implement a typical dictionary using a string as key and the generic type T as value.
  62929. * The underlying implementation relies on an associative array to ensure the best performances.
  62930. * The value can be anything including 'null' but except 'undefined'
  62931. */
  62932. export class StringDictionary<T> {
  62933. /**
  62934. * This will clear this dictionary and copy the content from the 'source' one.
  62935. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  62936. * @param source the dictionary to take the content from and copy to this dictionary
  62937. */
  62938. copyFrom(source: StringDictionary<T>): void;
  62939. /**
  62940. * Get a value based from its key
  62941. * @param key the given key to get the matching value from
  62942. * @return the value if found, otherwise undefined is returned
  62943. */
  62944. get(key: string): T | undefined;
  62945. /**
  62946. * Get a value from its key or add it if it doesn't exist.
  62947. * This method will ensure you that a given key/data will be present in the dictionary.
  62948. * @param key the given key to get the matching value from
  62949. * @param factory the factory that will create the value if the key is not present in the dictionary.
  62950. * The factory will only be invoked if there's no data for the given key.
  62951. * @return the value corresponding to the key.
  62952. */
  62953. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  62954. /**
  62955. * Get a value from its key if present in the dictionary otherwise add it
  62956. * @param key the key to get the value from
  62957. * @param val if there's no such key/value pair in the dictionary add it with this value
  62958. * @return the value corresponding to the key
  62959. */
  62960. getOrAdd(key: string, val: T): T;
  62961. /**
  62962. * Check if there's a given key in the dictionary
  62963. * @param key the key to check for
  62964. * @return true if the key is present, false otherwise
  62965. */
  62966. contains(key: string): boolean;
  62967. /**
  62968. * Add a new key and its corresponding value
  62969. * @param key the key to add
  62970. * @param value the value corresponding to the key
  62971. * @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
  62972. */
  62973. add(key: string, value: T): boolean;
  62974. /**
  62975. * Update a specific value associated to a key
  62976. * @param key defines the key to use
  62977. * @param value defines the value to store
  62978. * @returns true if the value was updated (or false if the key was not found)
  62979. */
  62980. set(key: string, value: T): boolean;
  62981. /**
  62982. * Get the element of the given key and remove it from the dictionary
  62983. * @param key defines the key to search
  62984. * @returns the value associated with the key or null if not found
  62985. */
  62986. getAndRemove(key: string): Nullable<T>;
  62987. /**
  62988. * Remove a key/value from the dictionary.
  62989. * @param key the key to remove
  62990. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  62991. */
  62992. remove(key: string): boolean;
  62993. /**
  62994. * Clear the whole content of the dictionary
  62995. */
  62996. clear(): void;
  62997. /**
  62998. * Gets the current count
  62999. */
  63000. readonly count: number;
  63001. /**
  63002. * Execute a callback on each key/val of the dictionary.
  63003. * Note that you can remove any element in this dictionary in the callback implementation
  63004. * @param callback the callback to execute on a given key/value pair
  63005. */
  63006. forEach(callback: (key: string, val: T) => void): void;
  63007. /**
  63008. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  63009. * If the callback returns null or undefined the method will iterate to the next key/value pair
  63010. * Note that you can remove any element in this dictionary in the callback implementation
  63011. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  63012. * @returns the first item
  63013. */
  63014. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  63015. private _count;
  63016. private _data;
  63017. }
  63018. }
  63019. declare module BABYLON {
  63020. /**
  63021. * Helper class that provides a small promise polyfill
  63022. */
  63023. export class PromisePolyfill {
  63024. /**
  63025. * Static function used to check if the polyfill is required
  63026. * If this is the case then the function will inject the polyfill to window.Promise
  63027. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  63028. */
  63029. static Apply(force?: boolean): void;
  63030. }
  63031. }
  63032. declare module BABYLON {
  63033. /**
  63034. * Class used to store data that will be store in GPU memory
  63035. */
  63036. export class Buffer {
  63037. private _engine;
  63038. private _buffer;
  63039. /** @hidden */
  63040. _data: Nullable<DataArray>;
  63041. private _updatable;
  63042. private _instanced;
  63043. /**
  63044. * Gets the byte stride.
  63045. */
  63046. readonly byteStride: number;
  63047. /**
  63048. * Constructor
  63049. * @param engine the engine
  63050. * @param data the data to use for this buffer
  63051. * @param updatable whether the data is updatable
  63052. * @param stride the stride (optional)
  63053. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  63054. * @param instanced whether the buffer is instanced (optional)
  63055. * @param useBytes set to true if the stride in in bytes (optional)
  63056. */
  63057. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  63058. /**
  63059. * Create a new VertexBuffer based on the current buffer
  63060. * @param kind defines the vertex buffer kind (position, normal, etc.)
  63061. * @param offset defines offset in the buffer (0 by default)
  63062. * @param size defines the size in floats of attributes (position is 3 for instance)
  63063. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  63064. * @param instanced defines if the vertex buffer contains indexed data
  63065. * @param useBytes defines if the offset and stride are in bytes
  63066. * @returns the new vertex buffer
  63067. */
  63068. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  63069. /**
  63070. * Gets a boolean indicating if the Buffer is updatable?
  63071. * @returns true if the buffer is updatable
  63072. */
  63073. isUpdatable(): boolean;
  63074. /**
  63075. * Gets current buffer's data
  63076. * @returns a DataArray or null
  63077. */
  63078. getData(): Nullable<DataArray>;
  63079. /**
  63080. * Gets underlying native buffer
  63081. * @returns underlying native buffer
  63082. */
  63083. getBuffer(): Nullable<WebGLBuffer>;
  63084. /**
  63085. * Gets the stride in float32 units (i.e. byte stride / 4).
  63086. * May not be an integer if the byte stride is not divisible by 4.
  63087. * DEPRECATED. Use byteStride instead.
  63088. * @returns the stride in float32 units
  63089. */
  63090. getStrideSize(): number;
  63091. /**
  63092. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  63093. * @param data defines the data to store
  63094. */
  63095. create(data?: Nullable<DataArray>): void;
  63096. /** @hidden */
  63097. _rebuild(): void;
  63098. /**
  63099. * Update current buffer data
  63100. * @param data defines the data to store
  63101. */
  63102. update(data: DataArray): void;
  63103. /**
  63104. * Updates the data directly.
  63105. * @param data the new data
  63106. * @param offset the new offset
  63107. * @param vertexCount the vertex count (optional)
  63108. * @param useBytes set to true if the offset is in bytes
  63109. */
  63110. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  63111. /**
  63112. * Release all resources
  63113. */
  63114. dispose(): void;
  63115. }
  63116. /**
  63117. * Specialized buffer used to store vertex data
  63118. */
  63119. export class VertexBuffer {
  63120. /** @hidden */
  63121. _buffer: Buffer;
  63122. private _kind;
  63123. private _size;
  63124. private _ownsBuffer;
  63125. private _instanced;
  63126. private _instanceDivisor;
  63127. /**
  63128. * The byte type.
  63129. */
  63130. static readonly BYTE: number;
  63131. /**
  63132. * The unsigned byte type.
  63133. */
  63134. static readonly UNSIGNED_BYTE: number;
  63135. /**
  63136. * The short type.
  63137. */
  63138. static readonly SHORT: number;
  63139. /**
  63140. * The unsigned short type.
  63141. */
  63142. static readonly UNSIGNED_SHORT: number;
  63143. /**
  63144. * The integer type.
  63145. */
  63146. static readonly INT: number;
  63147. /**
  63148. * The unsigned integer type.
  63149. */
  63150. static readonly UNSIGNED_INT: number;
  63151. /**
  63152. * The float type.
  63153. */
  63154. static readonly FLOAT: number;
  63155. /**
  63156. * Gets or sets the instance divisor when in instanced mode
  63157. */
  63158. instanceDivisor: number;
  63159. /**
  63160. * Gets the byte stride.
  63161. */
  63162. readonly byteStride: number;
  63163. /**
  63164. * Gets the byte offset.
  63165. */
  63166. readonly byteOffset: number;
  63167. /**
  63168. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  63169. */
  63170. readonly normalized: boolean;
  63171. /**
  63172. * Gets the data type of each component in the array.
  63173. */
  63174. readonly type: number;
  63175. /**
  63176. * Constructor
  63177. * @param engine the engine
  63178. * @param data the data to use for this vertex buffer
  63179. * @param kind the vertex buffer kind
  63180. * @param updatable whether the data is updatable
  63181. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  63182. * @param stride the stride (optional)
  63183. * @param instanced whether the buffer is instanced (optional)
  63184. * @param offset the offset of the data (optional)
  63185. * @param size the number of components (optional)
  63186. * @param type the type of the component (optional)
  63187. * @param normalized whether the data contains normalized data (optional)
  63188. * @param useBytes set to true if stride and offset are in bytes (optional)
  63189. */
  63190. 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);
  63191. /** @hidden */
  63192. _rebuild(): void;
  63193. /**
  63194. * Returns the kind of the VertexBuffer (string)
  63195. * @returns a string
  63196. */
  63197. getKind(): string;
  63198. /**
  63199. * Gets a boolean indicating if the VertexBuffer is updatable?
  63200. * @returns true if the buffer is updatable
  63201. */
  63202. isUpdatable(): boolean;
  63203. /**
  63204. * Gets current buffer's data
  63205. * @returns a DataArray or null
  63206. */
  63207. getData(): Nullable<DataArray>;
  63208. /**
  63209. * Gets underlying native buffer
  63210. * @returns underlying native buffer
  63211. */
  63212. getBuffer(): Nullable<WebGLBuffer>;
  63213. /**
  63214. * Gets the stride in float32 units (i.e. byte stride / 4).
  63215. * May not be an integer if the byte stride is not divisible by 4.
  63216. * DEPRECATED. Use byteStride instead.
  63217. * @returns the stride in float32 units
  63218. */
  63219. getStrideSize(): number;
  63220. /**
  63221. * Returns the offset as a multiple of the type byte length.
  63222. * DEPRECATED. Use byteOffset instead.
  63223. * @returns the offset in bytes
  63224. */
  63225. getOffset(): number;
  63226. /**
  63227. * Returns the number of components per vertex attribute (integer)
  63228. * @returns the size in float
  63229. */
  63230. getSize(): number;
  63231. /**
  63232. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  63233. * @returns true if this buffer is instanced
  63234. */
  63235. getIsInstanced(): boolean;
  63236. /**
  63237. * Returns the instancing divisor, zero for non-instanced (integer).
  63238. * @returns a number
  63239. */
  63240. getInstanceDivisor(): number;
  63241. /**
  63242. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  63243. * @param data defines the data to store
  63244. */
  63245. create(data?: DataArray): void;
  63246. /**
  63247. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  63248. * This function will create a new buffer if the current one is not updatable
  63249. * @param data defines the data to store
  63250. */
  63251. update(data: DataArray): void;
  63252. /**
  63253. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  63254. * Returns the directly updated WebGLBuffer.
  63255. * @param data the new data
  63256. * @param offset the new offset
  63257. * @param useBytes set to true if the offset is in bytes
  63258. */
  63259. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  63260. /**
  63261. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  63262. */
  63263. dispose(): void;
  63264. /**
  63265. * Enumerates each value of this vertex buffer as numbers.
  63266. * @param count the number of values to enumerate
  63267. * @param callback the callback function called for each value
  63268. */
  63269. forEach(count: number, callback: (value: number, index: number) => void): void;
  63270. /**
  63271. * Positions
  63272. */
  63273. static readonly PositionKind: string;
  63274. /**
  63275. * Normals
  63276. */
  63277. static readonly NormalKind: string;
  63278. /**
  63279. * Tangents
  63280. */
  63281. static readonly TangentKind: string;
  63282. /**
  63283. * Texture coordinates
  63284. */
  63285. static readonly UVKind: string;
  63286. /**
  63287. * Texture coordinates 2
  63288. */
  63289. static readonly UV2Kind: string;
  63290. /**
  63291. * Texture coordinates 3
  63292. */
  63293. static readonly UV3Kind: string;
  63294. /**
  63295. * Texture coordinates 4
  63296. */
  63297. static readonly UV4Kind: string;
  63298. /**
  63299. * Texture coordinates 5
  63300. */
  63301. static readonly UV5Kind: string;
  63302. /**
  63303. * Texture coordinates 6
  63304. */
  63305. static readonly UV6Kind: string;
  63306. /**
  63307. * Colors
  63308. */
  63309. static readonly ColorKind: string;
  63310. /**
  63311. * Matrix indices (for bones)
  63312. */
  63313. static readonly MatricesIndicesKind: string;
  63314. /**
  63315. * Matrix weights (for bones)
  63316. */
  63317. static readonly MatricesWeightsKind: string;
  63318. /**
  63319. * Additional matrix indices (for bones)
  63320. */
  63321. static readonly MatricesIndicesExtraKind: string;
  63322. /**
  63323. * Additional matrix weights (for bones)
  63324. */
  63325. static readonly MatricesWeightsExtraKind: string;
  63326. /**
  63327. * Deduces the stride given a kind.
  63328. * @param kind The kind string to deduce
  63329. * @returns The deduced stride
  63330. */
  63331. static DeduceStride(kind: string): number;
  63332. /**
  63333. * Gets the byte length of the given type.
  63334. * @param type the type
  63335. * @returns the number of bytes
  63336. */
  63337. static GetTypeByteLength(type: number): number;
  63338. /**
  63339. * Enumerates each value of the given parameters as numbers.
  63340. * @param data the data to enumerate
  63341. * @param byteOffset the byte offset of the data
  63342. * @param byteStride the byte stride of the data
  63343. * @param componentCount the number of components per element
  63344. * @param componentType the type of the component
  63345. * @param count the total number of components
  63346. * @param normalized whether the data is normalized
  63347. * @param callback the callback function called for each value
  63348. */
  63349. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  63350. private static _GetFloatValue;
  63351. }
  63352. }
  63353. declare module BABYLON {
  63354. /**
  63355. * Class representing spherical polynomial coefficients to the 3rd degree
  63356. */
  63357. export class SphericalPolynomial {
  63358. /**
  63359. * The x coefficients of the spherical polynomial
  63360. */
  63361. x: Vector3;
  63362. /**
  63363. * The y coefficients of the spherical polynomial
  63364. */
  63365. y: Vector3;
  63366. /**
  63367. * The z coefficients of the spherical polynomial
  63368. */
  63369. z: Vector3;
  63370. /**
  63371. * The xx coefficients of the spherical polynomial
  63372. */
  63373. xx: Vector3;
  63374. /**
  63375. * The yy coefficients of the spherical polynomial
  63376. */
  63377. yy: Vector3;
  63378. /**
  63379. * The zz coefficients of the spherical polynomial
  63380. */
  63381. zz: Vector3;
  63382. /**
  63383. * The xy coefficients of the spherical polynomial
  63384. */
  63385. xy: Vector3;
  63386. /**
  63387. * The yz coefficients of the spherical polynomial
  63388. */
  63389. yz: Vector3;
  63390. /**
  63391. * The zx coefficients of the spherical polynomial
  63392. */
  63393. zx: Vector3;
  63394. /**
  63395. * Adds an ambient color to the spherical polynomial
  63396. * @param color the color to add
  63397. */
  63398. addAmbient(color: Color3): void;
  63399. /**
  63400. * Scales the spherical polynomial by the given amount
  63401. * @param scale the amount to scale
  63402. */
  63403. scale(scale: number): void;
  63404. /**
  63405. * Gets the spherical polynomial from harmonics
  63406. * @param harmonics the spherical harmonics
  63407. * @returns the spherical polynomial
  63408. */
  63409. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  63410. /**
  63411. * Constructs a spherical polynomial from an array.
  63412. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  63413. * @returns the spherical polynomial
  63414. */
  63415. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  63416. }
  63417. /**
  63418. * Class representing spherical harmonics coefficients to the 3rd degree
  63419. */
  63420. export class SphericalHarmonics {
  63421. /**
  63422. * The l0,0 coefficients of the spherical harmonics
  63423. */
  63424. l00: Vector3;
  63425. /**
  63426. * The l1,-1 coefficients of the spherical harmonics
  63427. */
  63428. l1_1: Vector3;
  63429. /**
  63430. * The l1,0 coefficients of the spherical harmonics
  63431. */
  63432. l10: Vector3;
  63433. /**
  63434. * The l1,1 coefficients of the spherical harmonics
  63435. */
  63436. l11: Vector3;
  63437. /**
  63438. * The l2,-2 coefficients of the spherical harmonics
  63439. */
  63440. l2_2: Vector3;
  63441. /**
  63442. * The l2,-1 coefficients of the spherical harmonics
  63443. */
  63444. l2_1: Vector3;
  63445. /**
  63446. * The l2,0 coefficients of the spherical harmonics
  63447. */
  63448. l20: Vector3;
  63449. /**
  63450. * The l2,1 coefficients of the spherical harmonics
  63451. */
  63452. l21: Vector3;
  63453. /**
  63454. * The l2,2 coefficients of the spherical harmonics
  63455. */
  63456. lL22: Vector3;
  63457. /**
  63458. * Adds a light to the spherical harmonics
  63459. * @param direction the direction of the light
  63460. * @param color the color of the light
  63461. * @param deltaSolidAngle the delta solid angle of the light
  63462. */
  63463. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  63464. /**
  63465. * Scales the spherical harmonics by the given amount
  63466. * @param scale the amount to scale
  63467. */
  63468. scale(scale: number): void;
  63469. /**
  63470. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  63471. *
  63472. * ```
  63473. * E_lm = A_l * L_lm
  63474. * ```
  63475. *
  63476. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  63477. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  63478. * the scaling factors are given in equation 9.
  63479. */
  63480. convertIncidentRadianceToIrradiance(): void;
  63481. /**
  63482. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  63483. *
  63484. * ```
  63485. * L = (1/pi) * E * rho
  63486. * ```
  63487. *
  63488. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  63489. */
  63490. convertIrradianceToLambertianRadiance(): void;
  63491. /**
  63492. * Gets the spherical harmonics from polynomial
  63493. * @param polynomial the spherical polynomial
  63494. * @returns the spherical harmonics
  63495. */
  63496. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  63497. /**
  63498. * Constructs a spherical harmonics from an array.
  63499. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  63500. * @returns the spherical harmonics
  63501. */
  63502. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  63503. }
  63504. }
  63505. declare module BABYLON {
  63506. /**
  63507. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  63508. */
  63509. export interface CubeMapInfo {
  63510. /**
  63511. * The pixel array for the front face.
  63512. * This is stored in format, left to right, up to down format.
  63513. */
  63514. front: Nullable<ArrayBufferView>;
  63515. /**
  63516. * The pixel array for the back face.
  63517. * This is stored in format, left to right, up to down format.
  63518. */
  63519. back: Nullable<ArrayBufferView>;
  63520. /**
  63521. * The pixel array for the left face.
  63522. * This is stored in format, left to right, up to down format.
  63523. */
  63524. left: Nullable<ArrayBufferView>;
  63525. /**
  63526. * The pixel array for the right face.
  63527. * This is stored in format, left to right, up to down format.
  63528. */
  63529. right: Nullable<ArrayBufferView>;
  63530. /**
  63531. * The pixel array for the up face.
  63532. * This is stored in format, left to right, up to down format.
  63533. */
  63534. up: Nullable<ArrayBufferView>;
  63535. /**
  63536. * The pixel array for the down face.
  63537. * This is stored in format, left to right, up to down format.
  63538. */
  63539. down: Nullable<ArrayBufferView>;
  63540. /**
  63541. * The size of the cubemap stored.
  63542. *
  63543. * Each faces will be size * size pixels.
  63544. */
  63545. size: number;
  63546. /**
  63547. * The format of the texture.
  63548. *
  63549. * RGBA, RGB.
  63550. */
  63551. format: number;
  63552. /**
  63553. * The type of the texture data.
  63554. *
  63555. * UNSIGNED_INT, FLOAT.
  63556. */
  63557. type: number;
  63558. /**
  63559. * Specifies whether the texture is in gamma space.
  63560. */
  63561. gammaSpace: boolean;
  63562. }
  63563. /**
  63564. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  63565. */
  63566. export class PanoramaToCubeMapTools {
  63567. private static FACE_FRONT;
  63568. private static FACE_BACK;
  63569. private static FACE_RIGHT;
  63570. private static FACE_LEFT;
  63571. private static FACE_DOWN;
  63572. private static FACE_UP;
  63573. /**
  63574. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  63575. *
  63576. * @param float32Array The source data.
  63577. * @param inputWidth The width of the input panorama.
  63578. * @param inputHeight The height of the input panorama.
  63579. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  63580. * @return The cubemap data
  63581. */
  63582. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  63583. private static CreateCubemapTexture;
  63584. private static CalcProjectionSpherical;
  63585. }
  63586. }
  63587. declare module BABYLON {
  63588. /**
  63589. * Helper class dealing with the extraction of spherical polynomial dataArray
  63590. * from a cube map.
  63591. */
  63592. export class CubeMapToSphericalPolynomialTools {
  63593. private static FileFaces;
  63594. /**
  63595. * Converts a texture to the according Spherical Polynomial data.
  63596. * This extracts the first 3 orders only as they are the only one used in the lighting.
  63597. *
  63598. * @param texture The texture to extract the information from.
  63599. * @return The Spherical Polynomial data.
  63600. */
  63601. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  63602. /**
  63603. * Converts a cubemap to the according Spherical Polynomial data.
  63604. * This extracts the first 3 orders only as they are the only one used in the lighting.
  63605. *
  63606. * @param cubeInfo The Cube map to extract the information from.
  63607. * @return The Spherical Polynomial data.
  63608. */
  63609. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  63610. }
  63611. }
  63612. declare module BABYLON {
  63613. /**
  63614. * The engine store class is responsible to hold all the instances of Engine and Scene created
  63615. * during the life time of the application.
  63616. */
  63617. export class EngineStore {
  63618. /** Gets the list of created engines */
  63619. static Instances: Engine[];
  63620. /**
  63621. * Gets the latest created engine
  63622. */
  63623. static readonly LastCreatedEngine: Nullable<Engine>;
  63624. /**
  63625. * Gets the latest created scene
  63626. */
  63627. static readonly LastCreatedScene: Nullable<Scene>;
  63628. }
  63629. }
  63630. declare module BABYLON {
  63631. /**
  63632. * Define options used to create a render target texture
  63633. */
  63634. export class RenderTargetCreationOptions {
  63635. /**
  63636. * Specifies is mipmaps must be generated
  63637. */
  63638. generateMipMaps?: boolean;
  63639. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  63640. generateDepthBuffer?: boolean;
  63641. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  63642. generateStencilBuffer?: boolean;
  63643. /** Defines texture type (int by default) */
  63644. type?: number;
  63645. /** Defines sampling mode (trilinear by default) */
  63646. samplingMode?: number;
  63647. /** Defines format (RGBA by default) */
  63648. format?: number;
  63649. }
  63650. }
  63651. declare module BABYLON {
  63652. /**
  63653. * @hidden
  63654. **/
  63655. export class _AlphaState {
  63656. private _isAlphaBlendDirty;
  63657. private _isBlendFunctionParametersDirty;
  63658. private _isBlendEquationParametersDirty;
  63659. private _isBlendConstantsDirty;
  63660. private _alphaBlend;
  63661. private _blendFunctionParameters;
  63662. private _blendEquationParameters;
  63663. private _blendConstants;
  63664. /**
  63665. * Initializes the state.
  63666. */
  63667. constructor();
  63668. readonly isDirty: boolean;
  63669. alphaBlend: boolean;
  63670. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  63671. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  63672. setAlphaEquationParameters(rgb: number, alpha: number): void;
  63673. reset(): void;
  63674. apply(gl: WebGLRenderingContext): void;
  63675. }
  63676. }
  63677. declare module BABYLON {
  63678. /**
  63679. * @hidden
  63680. **/
  63681. export class _DepthCullingState {
  63682. private _isDepthTestDirty;
  63683. private _isDepthMaskDirty;
  63684. private _isDepthFuncDirty;
  63685. private _isCullFaceDirty;
  63686. private _isCullDirty;
  63687. private _isZOffsetDirty;
  63688. private _isFrontFaceDirty;
  63689. private _depthTest;
  63690. private _depthMask;
  63691. private _depthFunc;
  63692. private _cull;
  63693. private _cullFace;
  63694. private _zOffset;
  63695. private _frontFace;
  63696. /**
  63697. * Initializes the state.
  63698. */
  63699. constructor();
  63700. readonly isDirty: boolean;
  63701. zOffset: number;
  63702. cullFace: Nullable<number>;
  63703. cull: Nullable<boolean>;
  63704. depthFunc: Nullable<number>;
  63705. depthMask: boolean;
  63706. depthTest: boolean;
  63707. frontFace: Nullable<number>;
  63708. reset(): void;
  63709. apply(gl: WebGLRenderingContext): void;
  63710. }
  63711. }
  63712. declare module BABYLON {
  63713. /**
  63714. * @hidden
  63715. **/
  63716. export class _StencilState {
  63717. /** 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 */
  63718. static readonly ALWAYS: number;
  63719. /** Passed to stencilOperation to specify that stencil value must be kept */
  63720. static readonly KEEP: number;
  63721. /** Passed to stencilOperation to specify that stencil value must be replaced */
  63722. static readonly REPLACE: number;
  63723. private _isStencilTestDirty;
  63724. private _isStencilMaskDirty;
  63725. private _isStencilFuncDirty;
  63726. private _isStencilOpDirty;
  63727. private _stencilTest;
  63728. private _stencilMask;
  63729. private _stencilFunc;
  63730. private _stencilFuncRef;
  63731. private _stencilFuncMask;
  63732. private _stencilOpStencilFail;
  63733. private _stencilOpDepthFail;
  63734. private _stencilOpStencilDepthPass;
  63735. readonly isDirty: boolean;
  63736. stencilFunc: number;
  63737. stencilFuncRef: number;
  63738. stencilFuncMask: number;
  63739. stencilOpStencilFail: number;
  63740. stencilOpDepthFail: number;
  63741. stencilOpStencilDepthPass: number;
  63742. stencilMask: number;
  63743. stencilTest: boolean;
  63744. constructor();
  63745. reset(): void;
  63746. apply(gl: WebGLRenderingContext): void;
  63747. }
  63748. }
  63749. declare module BABYLON {
  63750. /**
  63751. * @hidden
  63752. **/
  63753. export class _TimeToken {
  63754. _startTimeQuery: Nullable<WebGLQuery>;
  63755. _endTimeQuery: Nullable<WebGLQuery>;
  63756. _timeElapsedQuery: Nullable<WebGLQuery>;
  63757. _timeElapsedQueryEnded: boolean;
  63758. }
  63759. }
  63760. declare module BABYLON {
  63761. /**
  63762. * Internal interface used to track InternalTexture already bound to the GL context
  63763. */
  63764. export interface IInternalTextureTracker {
  63765. /**
  63766. * Gets or set the previous tracker in the list
  63767. */
  63768. previous: Nullable<IInternalTextureTracker>;
  63769. /**
  63770. * Gets or set the next tracker in the list
  63771. */
  63772. next: Nullable<IInternalTextureTracker>;
  63773. }
  63774. /**
  63775. * Internal class used by the engine to get list of InternalTexture already bound to the GL context
  63776. */
  63777. export class DummyInternalTextureTracker {
  63778. /**
  63779. * Gets or set the previous tracker in the list
  63780. */
  63781. previous: Nullable<IInternalTextureTracker>;
  63782. /**
  63783. * Gets or set the next tracker in the list
  63784. */
  63785. next: Nullable<IInternalTextureTracker>;
  63786. }
  63787. }
  63788. declare module BABYLON {
  63789. /**
  63790. * Class used to store data associated with WebGL texture data for the engine
  63791. * This class should not be used directly
  63792. */
  63793. export class InternalTexture implements IInternalTextureTracker {
  63794. /** hidden */
  63795. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  63796. /**
  63797. * The source of the texture data is unknown
  63798. */
  63799. static DATASOURCE_UNKNOWN: number;
  63800. /**
  63801. * Texture data comes from an URL
  63802. */
  63803. static DATASOURCE_URL: number;
  63804. /**
  63805. * Texture data is only used for temporary storage
  63806. */
  63807. static DATASOURCE_TEMP: number;
  63808. /**
  63809. * Texture data comes from raw data (ArrayBuffer)
  63810. */
  63811. static DATASOURCE_RAW: number;
  63812. /**
  63813. * Texture content is dynamic (video or dynamic texture)
  63814. */
  63815. static DATASOURCE_DYNAMIC: number;
  63816. /**
  63817. * Texture content is generated by rendering to it
  63818. */
  63819. static DATASOURCE_RENDERTARGET: number;
  63820. /**
  63821. * Texture content is part of a multi render target process
  63822. */
  63823. static DATASOURCE_MULTIRENDERTARGET: number;
  63824. /**
  63825. * Texture data comes from a cube data file
  63826. */
  63827. static DATASOURCE_CUBE: number;
  63828. /**
  63829. * Texture data comes from a raw cube data
  63830. */
  63831. static DATASOURCE_CUBERAW: number;
  63832. /**
  63833. * Texture data come from a prefiltered cube data file
  63834. */
  63835. static DATASOURCE_CUBEPREFILTERED: number;
  63836. /**
  63837. * Texture content is raw 3D data
  63838. */
  63839. static DATASOURCE_RAW3D: number;
  63840. /**
  63841. * Texture content is a depth texture
  63842. */
  63843. static DATASOURCE_DEPTHTEXTURE: number;
  63844. /**
  63845. * Texture data comes from a raw cube data encoded with RGBD
  63846. */
  63847. static DATASOURCE_CUBERAW_RGBD: number;
  63848. /**
  63849. * Defines if the texture is ready
  63850. */
  63851. isReady: boolean;
  63852. /**
  63853. * Defines if the texture is a cube texture
  63854. */
  63855. isCube: boolean;
  63856. /**
  63857. * Defines if the texture contains 3D data
  63858. */
  63859. is3D: boolean;
  63860. /**
  63861. * Gets the URL used to load this texture
  63862. */
  63863. url: string;
  63864. /**
  63865. * Gets the sampling mode of the texture
  63866. */
  63867. samplingMode: number;
  63868. /**
  63869. * Gets a boolean indicating if the texture needs mipmaps generation
  63870. */
  63871. generateMipMaps: boolean;
  63872. /**
  63873. * Gets the number of samples used by the texture (WebGL2+ only)
  63874. */
  63875. samples: number;
  63876. /**
  63877. * Gets the type of the texture (int, float...)
  63878. */
  63879. type: number;
  63880. /**
  63881. * Gets the format of the texture (RGB, RGBA...)
  63882. */
  63883. format: number;
  63884. /**
  63885. * Observable called when the texture is loaded
  63886. */
  63887. onLoadedObservable: Observable<InternalTexture>;
  63888. /**
  63889. * Gets the width of the texture
  63890. */
  63891. width: number;
  63892. /**
  63893. * Gets the height of the texture
  63894. */
  63895. height: number;
  63896. /**
  63897. * Gets the depth of the texture
  63898. */
  63899. depth: number;
  63900. /**
  63901. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  63902. */
  63903. baseWidth: number;
  63904. /**
  63905. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  63906. */
  63907. baseHeight: number;
  63908. /**
  63909. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  63910. */
  63911. baseDepth: number;
  63912. /**
  63913. * Gets a boolean indicating if the texture is inverted on Y axis
  63914. */
  63915. invertY: boolean;
  63916. /**
  63917. * Gets or set the previous tracker in the list
  63918. */
  63919. previous: Nullable<IInternalTextureTracker>;
  63920. /**
  63921. * Gets or set the next tracker in the list
  63922. */
  63923. next: Nullable<IInternalTextureTracker>;
  63924. /** @hidden */
  63925. _invertVScale: boolean;
  63926. /** @hidden */
  63927. _initialSlot: number;
  63928. /** @hidden */
  63929. _designatedSlot: number;
  63930. /** @hidden */
  63931. _dataSource: number;
  63932. /** @hidden */
  63933. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  63934. /** @hidden */
  63935. _bufferView: Nullable<ArrayBufferView>;
  63936. /** @hidden */
  63937. _bufferViewArray: Nullable<ArrayBufferView[]>;
  63938. /** @hidden */
  63939. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  63940. /** @hidden */
  63941. _size: number;
  63942. /** @hidden */
  63943. _extension: string;
  63944. /** @hidden */
  63945. _files: Nullable<string[]>;
  63946. /** @hidden */
  63947. _workingCanvas: HTMLCanvasElement;
  63948. /** @hidden */
  63949. _workingContext: CanvasRenderingContext2D;
  63950. /** @hidden */
  63951. _framebuffer: Nullable<WebGLFramebuffer>;
  63952. /** @hidden */
  63953. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  63954. /** @hidden */
  63955. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  63956. /** @hidden */
  63957. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  63958. /** @hidden */
  63959. _attachments: Nullable<number[]>;
  63960. /** @hidden */
  63961. _cachedCoordinatesMode: Nullable<number>;
  63962. /** @hidden */
  63963. _cachedWrapU: Nullable<number>;
  63964. /** @hidden */
  63965. _cachedWrapV: Nullable<number>;
  63966. /** @hidden */
  63967. _cachedWrapR: Nullable<number>;
  63968. /** @hidden */
  63969. _cachedAnisotropicFilteringLevel: Nullable<number>;
  63970. /** @hidden */
  63971. _isDisabled: boolean;
  63972. /** @hidden */
  63973. _compression: Nullable<string>;
  63974. /** @hidden */
  63975. _generateStencilBuffer: boolean;
  63976. /** @hidden */
  63977. _generateDepthBuffer: boolean;
  63978. /** @hidden */
  63979. _comparisonFunction: number;
  63980. /** @hidden */
  63981. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  63982. /** @hidden */
  63983. _lodGenerationScale: number;
  63984. /** @hidden */
  63985. _lodGenerationOffset: number;
  63986. /** @hidden */
  63987. _lodTextureHigh: BaseTexture;
  63988. /** @hidden */
  63989. _lodTextureMid: BaseTexture;
  63990. /** @hidden */
  63991. _lodTextureLow: BaseTexture;
  63992. /** @hidden */
  63993. _isRGBD: boolean;
  63994. /** @hidden */
  63995. _webGLTexture: Nullable<WebGLTexture>;
  63996. /** @hidden */
  63997. _references: number;
  63998. private _engine;
  63999. /**
  64000. * Gets the Engine the texture belongs to.
  64001. * @returns The babylon engine
  64002. */
  64003. getEngine(): Engine;
  64004. /**
  64005. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  64006. */
  64007. readonly dataSource: number;
  64008. /**
  64009. * Creates a new InternalTexture
  64010. * @param engine defines the engine to use
  64011. * @param dataSource defines the type of data that will be used
  64012. * @param delayAllocation if the texture allocation should be delayed (default: false)
  64013. */
  64014. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  64015. /**
  64016. * Increments the number of references (ie. the number of Texture that point to it)
  64017. */
  64018. incrementReferences(): void;
  64019. /**
  64020. * Change the size of the texture (not the size of the content)
  64021. * @param width defines the new width
  64022. * @param height defines the new height
  64023. * @param depth defines the new depth (1 by default)
  64024. */
  64025. updateSize(width: int, height: int, depth?: int): void;
  64026. /** @hidden */
  64027. _rebuild(): void;
  64028. /** @hidden */
  64029. _swapAndDie(target: InternalTexture): void;
  64030. /**
  64031. * Dispose the current allocated resources
  64032. */
  64033. dispose(): void;
  64034. }
  64035. }
  64036. declare module BABYLON {
  64037. /**
  64038. * This represents the main contract an easing function should follow.
  64039. * Easing functions are used throughout the animation system.
  64040. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  64041. */
  64042. export interface IEasingFunction {
  64043. /**
  64044. * Given an input gradient between 0 and 1, this returns the corrseponding value
  64045. * of the easing function.
  64046. * The link below provides some of the most common examples of easing functions.
  64047. * @see https://easings.net/
  64048. * @param gradient Defines the value between 0 and 1 we want the easing value for
  64049. * @returns the corresponding value on the curve defined by the easing function
  64050. */
  64051. ease(gradient: number): number;
  64052. }
  64053. /**
  64054. * Base class used for every default easing function.
  64055. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  64056. */
  64057. export class EasingFunction implements IEasingFunction {
  64058. /**
  64059. * Interpolation follows the mathematical formula associated with the easing function.
  64060. */
  64061. static readonly EASINGMODE_EASEIN: number;
  64062. /**
  64063. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  64064. */
  64065. static readonly EASINGMODE_EASEOUT: number;
  64066. /**
  64067. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  64068. */
  64069. static readonly EASINGMODE_EASEINOUT: number;
  64070. private _easingMode;
  64071. /**
  64072. * Sets the easing mode of the current function.
  64073. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  64074. */
  64075. setEasingMode(easingMode: number): void;
  64076. /**
  64077. * Gets the current easing mode.
  64078. * @returns the easing mode
  64079. */
  64080. getEasingMode(): number;
  64081. /**
  64082. * @hidden
  64083. */
  64084. easeInCore(gradient: number): number;
  64085. /**
  64086. * Given an input gradient between 0 and 1, this returns the corrseponding value
  64087. * of the easing function.
  64088. * @param gradient Defines the value between 0 and 1 we want the easing value for
  64089. * @returns the corresponding value on the curve defined by the easing function
  64090. */
  64091. ease(gradient: number): number;
  64092. }
  64093. /**
  64094. * Easing function with a circle shape (see link below).
  64095. * @see https://easings.net/#easeInCirc
  64096. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  64097. */
  64098. export class CircleEase extends EasingFunction implements IEasingFunction {
  64099. /** @hidden */
  64100. easeInCore(gradient: number): number;
  64101. }
  64102. /**
  64103. * Easing function with a ease back shape (see link below).
  64104. * @see https://easings.net/#easeInBack
  64105. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  64106. */
  64107. export class BackEase extends EasingFunction implements IEasingFunction {
  64108. /** Defines the amplitude of the function */
  64109. amplitude: number;
  64110. /**
  64111. * Instantiates a back ease easing
  64112. * @see https://easings.net/#easeInBack
  64113. * @param amplitude Defines the amplitude of the function
  64114. */
  64115. constructor(
  64116. /** Defines the amplitude of the function */
  64117. amplitude?: number);
  64118. /** @hidden */
  64119. easeInCore(gradient: number): number;
  64120. }
  64121. /**
  64122. * Easing function with a bouncing shape (see link below).
  64123. * @see https://easings.net/#easeInBounce
  64124. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  64125. */
  64126. export class BounceEase extends EasingFunction implements IEasingFunction {
  64127. /** Defines the number of bounces */
  64128. bounces: number;
  64129. /** Defines the amplitude of the bounce */
  64130. bounciness: number;
  64131. /**
  64132. * Instantiates a bounce easing
  64133. * @see https://easings.net/#easeInBounce
  64134. * @param bounces Defines the number of bounces
  64135. * @param bounciness Defines the amplitude of the bounce
  64136. */
  64137. constructor(
  64138. /** Defines the number of bounces */
  64139. bounces?: number,
  64140. /** Defines the amplitude of the bounce */
  64141. bounciness?: number);
  64142. /** @hidden */
  64143. easeInCore(gradient: number): number;
  64144. }
  64145. /**
  64146. * Easing function with a power of 3 shape (see link below).
  64147. * @see https://easings.net/#easeInCubic
  64148. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  64149. */
  64150. export class CubicEase extends EasingFunction implements IEasingFunction {
  64151. /** @hidden */
  64152. easeInCore(gradient: number): number;
  64153. }
  64154. /**
  64155. * Easing function with an elastic shape (see link below).
  64156. * @see https://easings.net/#easeInElastic
  64157. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  64158. */
  64159. export class ElasticEase extends EasingFunction implements IEasingFunction {
  64160. /** Defines the number of oscillations*/
  64161. oscillations: number;
  64162. /** Defines the amplitude of the oscillations*/
  64163. springiness: number;
  64164. /**
  64165. * Instantiates an elastic easing function
  64166. * @see https://easings.net/#easeInElastic
  64167. * @param oscillations Defines the number of oscillations
  64168. * @param springiness Defines the amplitude of the oscillations
  64169. */
  64170. constructor(
  64171. /** Defines the number of oscillations*/
  64172. oscillations?: number,
  64173. /** Defines the amplitude of the oscillations*/
  64174. springiness?: number);
  64175. /** @hidden */
  64176. easeInCore(gradient: number): number;
  64177. }
  64178. /**
  64179. * Easing function with an exponential shape (see link below).
  64180. * @see https://easings.net/#easeInExpo
  64181. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  64182. */
  64183. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  64184. /** Defines the exponent of the function */
  64185. exponent: number;
  64186. /**
  64187. * Instantiates an exponential easing function
  64188. * @see https://easings.net/#easeInExpo
  64189. * @param exponent Defines the exponent of the function
  64190. */
  64191. constructor(
  64192. /** Defines the exponent of the function */
  64193. exponent?: number);
  64194. /** @hidden */
  64195. easeInCore(gradient: number): number;
  64196. }
  64197. /**
  64198. * Easing function with a power shape (see link below).
  64199. * @see https://easings.net/#easeInQuad
  64200. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  64201. */
  64202. export class PowerEase extends EasingFunction implements IEasingFunction {
  64203. /** Defines the power of the function */
  64204. power: number;
  64205. /**
  64206. * Instantiates an power base easing function
  64207. * @see https://easings.net/#easeInQuad
  64208. * @param power Defines the power of the function
  64209. */
  64210. constructor(
  64211. /** Defines the power of the function */
  64212. power?: number);
  64213. /** @hidden */
  64214. easeInCore(gradient: number): number;
  64215. }
  64216. /**
  64217. * Easing function with a power of 2 shape (see link below).
  64218. * @see https://easings.net/#easeInQuad
  64219. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  64220. */
  64221. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  64222. /** @hidden */
  64223. easeInCore(gradient: number): number;
  64224. }
  64225. /**
  64226. * Easing function with a power of 4 shape (see link below).
  64227. * @see https://easings.net/#easeInQuart
  64228. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  64229. */
  64230. export class QuarticEase extends EasingFunction implements IEasingFunction {
  64231. /** @hidden */
  64232. easeInCore(gradient: number): number;
  64233. }
  64234. /**
  64235. * Easing function with a power of 5 shape (see link below).
  64236. * @see https://easings.net/#easeInQuint
  64237. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  64238. */
  64239. export class QuinticEase extends EasingFunction implements IEasingFunction {
  64240. /** @hidden */
  64241. easeInCore(gradient: number): number;
  64242. }
  64243. /**
  64244. * Easing function with a sin shape (see link below).
  64245. * @see https://easings.net/#easeInSine
  64246. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  64247. */
  64248. export class SineEase extends EasingFunction implements IEasingFunction {
  64249. /** @hidden */
  64250. easeInCore(gradient: number): number;
  64251. }
  64252. /**
  64253. * Easing function with a bezier shape (see link below).
  64254. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  64255. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  64256. */
  64257. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  64258. /** Defines the x component of the start tangent in the bezier curve */
  64259. x1: number;
  64260. /** Defines the y component of the start tangent in the bezier curve */
  64261. y1: number;
  64262. /** Defines the x component of the end tangent in the bezier curve */
  64263. x2: number;
  64264. /** Defines the y component of the end tangent in the bezier curve */
  64265. y2: number;
  64266. /**
  64267. * Instantiates a bezier function
  64268. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  64269. * @param x1 Defines the x component of the start tangent in the bezier curve
  64270. * @param y1 Defines the y component of the start tangent in the bezier curve
  64271. * @param x2 Defines the x component of the end tangent in the bezier curve
  64272. * @param y2 Defines the y component of the end tangent in the bezier curve
  64273. */
  64274. constructor(
  64275. /** Defines the x component of the start tangent in the bezier curve */
  64276. x1?: number,
  64277. /** Defines the y component of the start tangent in the bezier curve */
  64278. y1?: number,
  64279. /** Defines the x component of the end tangent in the bezier curve */
  64280. x2?: number,
  64281. /** Defines the y component of the end tangent in the bezier curve */
  64282. y2?: number);
  64283. /** @hidden */
  64284. easeInCore(gradient: number): number;
  64285. }
  64286. }
  64287. declare module BABYLON {
  64288. /**
  64289. * Defines an interface which represents an animation key frame
  64290. */
  64291. export interface IAnimationKey {
  64292. /**
  64293. * Frame of the key frame
  64294. */
  64295. frame: number;
  64296. /**
  64297. * Value at the specifies key frame
  64298. */
  64299. value: any;
  64300. /**
  64301. * The input tangent for the cubic hermite spline
  64302. */
  64303. inTangent?: any;
  64304. /**
  64305. * The output tangent for the cubic hermite spline
  64306. */
  64307. outTangent?: any;
  64308. /**
  64309. * The animation interpolation type
  64310. */
  64311. interpolation?: AnimationKeyInterpolation;
  64312. }
  64313. /**
  64314. * Enum for the animation key frame interpolation type
  64315. */
  64316. export enum AnimationKeyInterpolation {
  64317. /**
  64318. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  64319. */
  64320. STEP = 1
  64321. }
  64322. }
  64323. declare module BABYLON {
  64324. /**
  64325. * Represents the range of an animation
  64326. */
  64327. export class AnimationRange {
  64328. /**The name of the animation range**/
  64329. name: string;
  64330. /**The starting frame of the animation */
  64331. from: number;
  64332. /**The ending frame of the animation*/
  64333. to: number;
  64334. /**
  64335. * Initializes the range of an animation
  64336. * @param name The name of the animation range
  64337. * @param from The starting frame of the animation
  64338. * @param to The ending frame of the animation
  64339. */
  64340. constructor(
  64341. /**The name of the animation range**/
  64342. name: string,
  64343. /**The starting frame of the animation */
  64344. from: number,
  64345. /**The ending frame of the animation*/
  64346. to: number);
  64347. /**
  64348. * Makes a copy of the animation range
  64349. * @returns A copy of the animation range
  64350. */
  64351. clone(): AnimationRange;
  64352. }
  64353. }
  64354. declare module BABYLON {
  64355. /**
  64356. * Composed of a frame, and an action function
  64357. */
  64358. export class AnimationEvent {
  64359. /** The frame for which the event is triggered **/
  64360. frame: number;
  64361. /** The event to perform when triggered **/
  64362. action: (currentFrame: number) => void;
  64363. /** Specifies if the event should be triggered only once**/
  64364. onlyOnce?: boolean | undefined;
  64365. /**
  64366. * Specifies if the animation event is done
  64367. */
  64368. isDone: boolean;
  64369. /**
  64370. * Initializes the animation event
  64371. * @param frame The frame for which the event is triggered
  64372. * @param action The event to perform when triggered
  64373. * @param onlyOnce Specifies if the event should be triggered only once
  64374. */
  64375. constructor(
  64376. /** The frame for which the event is triggered **/
  64377. frame: number,
  64378. /** The event to perform when triggered **/
  64379. action: (currentFrame: number) => void,
  64380. /** Specifies if the event should be triggered only once**/
  64381. onlyOnce?: boolean | undefined);
  64382. /** @hidden */
  64383. _clone(): AnimationEvent;
  64384. }
  64385. }
  64386. declare module BABYLON {
  64387. /**
  64388. * Interface used to define a behavior
  64389. */
  64390. export interface Behavior<T> {
  64391. /** gets or sets behavior's name */
  64392. name: string;
  64393. /**
  64394. * Function called when the behavior needs to be initialized (after attaching it to a target)
  64395. */
  64396. init(): void;
  64397. /**
  64398. * Called when the behavior is attached to a target
  64399. * @param target defines the target where the behavior is attached to
  64400. */
  64401. attach(target: T): void;
  64402. /**
  64403. * Called when the behavior is detached from its target
  64404. */
  64405. detach(): void;
  64406. }
  64407. /**
  64408. * Interface implemented by classes supporting behaviors
  64409. */
  64410. export interface IBehaviorAware<T> {
  64411. /**
  64412. * Attach a behavior
  64413. * @param behavior defines the behavior to attach
  64414. * @returns the current host
  64415. */
  64416. addBehavior(behavior: Behavior<T>): T;
  64417. /**
  64418. * Remove a behavior from the current object
  64419. * @param behavior defines the behavior to detach
  64420. * @returns the current host
  64421. */
  64422. removeBehavior(behavior: Behavior<T>): T;
  64423. /**
  64424. * Gets a behavior using its name to search
  64425. * @param name defines the name to search
  64426. * @returns the behavior or null if not found
  64427. */
  64428. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  64429. }
  64430. }
  64431. declare module BABYLON {
  64432. /**
  64433. * @hidden
  64434. */
  64435. export class IntersectionInfo {
  64436. bu: Nullable<number>;
  64437. bv: Nullable<number>;
  64438. distance: number;
  64439. faceId: number;
  64440. subMeshId: number;
  64441. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  64442. }
  64443. }
  64444. declare module BABYLON {
  64445. /**
  64446. * Class used to store bounding sphere information
  64447. */
  64448. export class BoundingSphere {
  64449. /**
  64450. * Gets the center of the bounding sphere in local space
  64451. */
  64452. readonly center: Vector3;
  64453. /**
  64454. * Radius of the bounding sphere in local space
  64455. */
  64456. radius: number;
  64457. /**
  64458. * Gets the center of the bounding sphere in world space
  64459. */
  64460. readonly centerWorld: Vector3;
  64461. /**
  64462. * Radius of the bounding sphere in world space
  64463. */
  64464. radiusWorld: number;
  64465. /**
  64466. * Gets the minimum vector in local space
  64467. */
  64468. readonly minimum: Vector3;
  64469. /**
  64470. * Gets the maximum vector in local space
  64471. */
  64472. readonly maximum: Vector3;
  64473. private _worldMatrix;
  64474. private static readonly TmpVector3;
  64475. /**
  64476. * Creates a new bounding sphere
  64477. * @param min defines the minimum vector (in local space)
  64478. * @param max defines the maximum vector (in local space)
  64479. * @param worldMatrix defines the new world matrix
  64480. */
  64481. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  64482. /**
  64483. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  64484. * @param min defines the new minimum vector (in local space)
  64485. * @param max defines the new maximum vector (in local space)
  64486. * @param worldMatrix defines the new world matrix
  64487. */
  64488. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  64489. /**
  64490. * Scale the current bounding sphere by applying a scale factor
  64491. * @param factor defines the scale factor to apply
  64492. * @returns the current bounding box
  64493. */
  64494. scale(factor: number): BoundingSphere;
  64495. /**
  64496. * Gets the world matrix of the bounding box
  64497. * @returns a matrix
  64498. */
  64499. getWorldMatrix(): DeepImmutable<Matrix>;
  64500. /** @hidden */
  64501. _update(worldMatrix: DeepImmutable<Matrix>): void;
  64502. /**
  64503. * Tests if the bounding sphere is intersecting the frustum planes
  64504. * @param frustumPlanes defines the frustum planes to test
  64505. * @returns true if there is an intersection
  64506. */
  64507. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  64508. /**
  64509. * Tests if the bounding sphere center is in between the frustum planes.
  64510. * Used for optimistic fast inclusion.
  64511. * @param frustumPlanes defines the frustum planes to test
  64512. * @returns true if the sphere center is in between the frustum planes
  64513. */
  64514. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  64515. /**
  64516. * Tests if a point is inside the bounding sphere
  64517. * @param point defines the point to test
  64518. * @returns true if the point is inside the bounding sphere
  64519. */
  64520. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  64521. /**
  64522. * Checks if two sphere intersct
  64523. * @param sphere0 sphere 0
  64524. * @param sphere1 sphere 1
  64525. * @returns true if the speres intersect
  64526. */
  64527. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  64528. }
  64529. }
  64530. declare module BABYLON {
  64531. /**
  64532. * Class used to store bounding box information
  64533. */
  64534. export class BoundingBox implements ICullable {
  64535. /**
  64536. * Gets the 8 vectors representing the bounding box in local space
  64537. */
  64538. readonly vectors: Vector3[];
  64539. /**
  64540. * Gets the center of the bounding box in local space
  64541. */
  64542. readonly center: Vector3;
  64543. /**
  64544. * Gets the center of the bounding box in world space
  64545. */
  64546. readonly centerWorld: Vector3;
  64547. /**
  64548. * Gets the extend size in local space
  64549. */
  64550. readonly extendSize: Vector3;
  64551. /**
  64552. * Gets the extend size in world space
  64553. */
  64554. readonly extendSizeWorld: Vector3;
  64555. /**
  64556. * Gets the OBB (object bounding box) directions
  64557. */
  64558. readonly directions: Vector3[];
  64559. /**
  64560. * Gets the 8 vectors representing the bounding box in world space
  64561. */
  64562. readonly vectorsWorld: Vector3[];
  64563. /**
  64564. * Gets the minimum vector in world space
  64565. */
  64566. readonly minimumWorld: Vector3;
  64567. /**
  64568. * Gets the maximum vector in world space
  64569. */
  64570. readonly maximumWorld: Vector3;
  64571. /**
  64572. * Gets the minimum vector in local space
  64573. */
  64574. readonly minimum: Vector3;
  64575. /**
  64576. * Gets the maximum vector in local space
  64577. */
  64578. readonly maximum: Vector3;
  64579. private _worldMatrix;
  64580. private static readonly TmpVector3;
  64581. /**
  64582. * @hidden
  64583. */
  64584. _tag: number;
  64585. /**
  64586. * Creates a new bounding box
  64587. * @param min defines the minimum vector (in local space)
  64588. * @param max defines the maximum vector (in local space)
  64589. * @param worldMatrix defines the new world matrix
  64590. */
  64591. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  64592. /**
  64593. * Recreates the entire bounding box from scratch as if we call the constructor in place
  64594. * @param min defines the new minimum vector (in local space)
  64595. * @param max defines the new maximum vector (in local space)
  64596. * @param worldMatrix defines the new world matrix
  64597. */
  64598. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  64599. /**
  64600. * Scale the current bounding box by applying a scale factor
  64601. * @param factor defines the scale factor to apply
  64602. * @returns the current bounding box
  64603. */
  64604. scale(factor: number): BoundingBox;
  64605. /**
  64606. * Gets the world matrix of the bounding box
  64607. * @returns a matrix
  64608. */
  64609. getWorldMatrix(): DeepImmutable<Matrix>;
  64610. /** @hidden */
  64611. _update(world: DeepImmutable<Matrix>): void;
  64612. /**
  64613. * Tests if the bounding box is intersecting the frustum planes
  64614. * @param frustumPlanes defines the frustum planes to test
  64615. * @returns true if there is an intersection
  64616. */
  64617. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  64618. /**
  64619. * Tests if the bounding box is entirely inside the frustum planes
  64620. * @param frustumPlanes defines the frustum planes to test
  64621. * @returns true if there is an inclusion
  64622. */
  64623. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  64624. /**
  64625. * Tests if a point is inside the bounding box
  64626. * @param point defines the point to test
  64627. * @returns true if the point is inside the bounding box
  64628. */
  64629. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  64630. /**
  64631. * Tests if the bounding box intersects with a bounding sphere
  64632. * @param sphere defines the sphere to test
  64633. * @returns true if there is an intersection
  64634. */
  64635. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  64636. /**
  64637. * Tests if the bounding box intersects with a box defined by a min and max vectors
  64638. * @param min defines the min vector to use
  64639. * @param max defines the max vector to use
  64640. * @returns true if there is an intersection
  64641. */
  64642. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  64643. /**
  64644. * Tests if two bounding boxes are intersections
  64645. * @param box0 defines the first box to test
  64646. * @param box1 defines the second box to test
  64647. * @returns true if there is an intersection
  64648. */
  64649. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  64650. /**
  64651. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  64652. * @param minPoint defines the minimum vector of the bounding box
  64653. * @param maxPoint defines the maximum vector of the bounding box
  64654. * @param sphereCenter defines the sphere center
  64655. * @param sphereRadius defines the sphere radius
  64656. * @returns true if there is an intersection
  64657. */
  64658. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  64659. /**
  64660. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  64661. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  64662. * @param frustumPlanes defines the frustum planes to test
  64663. * @return true if there is an inclusion
  64664. */
  64665. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  64666. /**
  64667. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  64668. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  64669. * @param frustumPlanes defines the frustum planes to test
  64670. * @return true if there is an intersection
  64671. */
  64672. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  64673. }
  64674. }
  64675. declare module BABYLON {
  64676. /** @hidden */
  64677. export class Collider {
  64678. /** Define if a collision was found */
  64679. collisionFound: boolean;
  64680. /**
  64681. * Define last intersection point in local space
  64682. */
  64683. intersectionPoint: Vector3;
  64684. /**
  64685. * Define last collided mesh
  64686. */
  64687. collidedMesh: Nullable<AbstractMesh>;
  64688. private _collisionPoint;
  64689. private _planeIntersectionPoint;
  64690. private _tempVector;
  64691. private _tempVector2;
  64692. private _tempVector3;
  64693. private _tempVector4;
  64694. private _edge;
  64695. private _baseToVertex;
  64696. private _destinationPoint;
  64697. private _slidePlaneNormal;
  64698. private _displacementVector;
  64699. /** @hidden */
  64700. _radius: Vector3;
  64701. /** @hidden */
  64702. _retry: number;
  64703. private _velocity;
  64704. private _basePoint;
  64705. private _epsilon;
  64706. /** @hidden */
  64707. _velocityWorldLength: number;
  64708. /** @hidden */
  64709. _basePointWorld: Vector3;
  64710. private _velocityWorld;
  64711. private _normalizedVelocity;
  64712. /** @hidden */
  64713. _initialVelocity: Vector3;
  64714. /** @hidden */
  64715. _initialPosition: Vector3;
  64716. private _nearestDistance;
  64717. private _collisionMask;
  64718. collisionMask: number;
  64719. /**
  64720. * Gets the plane normal used to compute the sliding response (in local space)
  64721. */
  64722. readonly slidePlaneNormal: Vector3;
  64723. /** @hidden */
  64724. _initialize(source: Vector3, dir: Vector3, e: number): void;
  64725. /** @hidden */
  64726. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  64727. /** @hidden */
  64728. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  64729. /** @hidden */
  64730. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  64731. /** @hidden */
  64732. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  64733. /** @hidden */
  64734. _getResponse(pos: Vector3, vel: Vector3): void;
  64735. }
  64736. }
  64737. declare module BABYLON {
  64738. /**
  64739. * Interface for cullable objects
  64740. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  64741. */
  64742. export interface ICullable {
  64743. /**
  64744. * Checks if the object or part of the object is in the frustum
  64745. * @param frustumPlanes Camera near/planes
  64746. * @returns true if the object is in frustum otherwise false
  64747. */
  64748. isInFrustum(frustumPlanes: Plane[]): boolean;
  64749. /**
  64750. * Checks if a cullable object (mesh...) is in the camera frustum
  64751. * Unlike isInFrustum this cheks the full bounding box
  64752. * @param frustumPlanes Camera near/planes
  64753. * @returns true if the object is in frustum otherwise false
  64754. */
  64755. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  64756. }
  64757. /**
  64758. * Info for a bounding data of a mesh
  64759. */
  64760. export class BoundingInfo implements ICullable {
  64761. /**
  64762. * Bounding box for the mesh
  64763. */
  64764. readonly boundingBox: BoundingBox;
  64765. /**
  64766. * Bounding sphere for the mesh
  64767. */
  64768. readonly boundingSphere: BoundingSphere;
  64769. private _isLocked;
  64770. private static readonly TmpVector3;
  64771. /**
  64772. * Constructs bounding info
  64773. * @param minimum min vector of the bounding box/sphere
  64774. * @param maximum max vector of the bounding box/sphere
  64775. * @param worldMatrix defines the new world matrix
  64776. */
  64777. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  64778. /**
  64779. * Recreates the entire bounding info from scratch as if we call the constructor in place
  64780. * @param min defines the new minimum vector (in local space)
  64781. * @param max defines the new maximum vector (in local space)
  64782. * @param worldMatrix defines the new world matrix
  64783. */
  64784. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  64785. /**
  64786. * min vector of the bounding box/sphere
  64787. */
  64788. readonly minimum: Vector3;
  64789. /**
  64790. * max vector of the bounding box/sphere
  64791. */
  64792. readonly maximum: Vector3;
  64793. /**
  64794. * If the info is locked and won't be updated to avoid perf overhead
  64795. */
  64796. isLocked: boolean;
  64797. /**
  64798. * Updates the bounding sphere and box
  64799. * @param world world matrix to be used to update
  64800. */
  64801. update(world: DeepImmutable<Matrix>): void;
  64802. /**
  64803. * Recreate the bounding info to be centered around a specific point given a specific extend.
  64804. * @param center New center of the bounding info
  64805. * @param extend New extend of the bounding info
  64806. * @returns the current bounding info
  64807. */
  64808. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  64809. /**
  64810. * Scale the current bounding info by applying a scale factor
  64811. * @param factor defines the scale factor to apply
  64812. * @returns the current bounding info
  64813. */
  64814. scale(factor: number): BoundingInfo;
  64815. /**
  64816. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  64817. * @param frustumPlanes defines the frustum to test
  64818. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  64819. * @returns true if the bounding info is in the frustum planes
  64820. */
  64821. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  64822. /**
  64823. * Gets the world distance between the min and max points of the bounding box
  64824. */
  64825. readonly diagonalLength: number;
  64826. /**
  64827. * Checks if a cullable object (mesh...) is in the camera frustum
  64828. * Unlike isInFrustum this cheks the full bounding box
  64829. * @param frustumPlanes Camera near/planes
  64830. * @returns true if the object is in frustum otherwise false
  64831. */
  64832. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  64833. /** @hidden */
  64834. _checkCollision(collider: Collider): boolean;
  64835. /**
  64836. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  64837. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  64838. * @param point the point to check intersection with
  64839. * @returns if the point intersects
  64840. */
  64841. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  64842. /**
  64843. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  64844. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  64845. * @param boundingInfo the bounding info to check intersection with
  64846. * @param precise if the intersection should be done using OBB
  64847. * @returns if the bounding info intersects
  64848. */
  64849. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  64850. }
  64851. }
  64852. declare module BABYLON {
  64853. /**
  64854. * Defines an array and its length.
  64855. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  64856. */
  64857. export interface ISmartArrayLike<T> {
  64858. /**
  64859. * The data of the array.
  64860. */
  64861. data: Array<T>;
  64862. /**
  64863. * The active length of the array.
  64864. */
  64865. length: number;
  64866. }
  64867. /**
  64868. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  64869. */
  64870. export class SmartArray<T> implements ISmartArrayLike<T> {
  64871. /**
  64872. * The full set of data from the array.
  64873. */
  64874. data: Array<T>;
  64875. /**
  64876. * The active length of the array.
  64877. */
  64878. length: number;
  64879. protected _id: number;
  64880. /**
  64881. * Instantiates a Smart Array.
  64882. * @param capacity defines the default capacity of the array.
  64883. */
  64884. constructor(capacity: number);
  64885. /**
  64886. * Pushes a value at the end of the active data.
  64887. * @param value defines the object to push in the array.
  64888. */
  64889. push(value: T): void;
  64890. /**
  64891. * Iterates over the active data and apply the lambda to them.
  64892. * @param func defines the action to apply on each value.
  64893. */
  64894. forEach(func: (content: T) => void): void;
  64895. /**
  64896. * Sorts the full sets of data.
  64897. * @param compareFn defines the comparison function to apply.
  64898. */
  64899. sort(compareFn: (a: T, b: T) => number): void;
  64900. /**
  64901. * Resets the active data to an empty array.
  64902. */
  64903. reset(): void;
  64904. /**
  64905. * Releases all the data from the array as well as the array.
  64906. */
  64907. dispose(): void;
  64908. /**
  64909. * Concats the active data with a given array.
  64910. * @param array defines the data to concatenate with.
  64911. */
  64912. concat(array: any): void;
  64913. /**
  64914. * Returns the position of a value in the active data.
  64915. * @param value defines the value to find the index for
  64916. * @returns the index if found in the active data otherwise -1
  64917. */
  64918. indexOf(value: T): number;
  64919. /**
  64920. * Returns whether an element is part of the active data.
  64921. * @param value defines the value to look for
  64922. * @returns true if found in the active data otherwise false
  64923. */
  64924. contains(value: T): boolean;
  64925. private static _GlobalId;
  64926. }
  64927. /**
  64928. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  64929. * The data in this array can only be present once
  64930. */
  64931. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  64932. private _duplicateId;
  64933. /**
  64934. * Pushes a value at the end of the active data.
  64935. * THIS DOES NOT PREVENT DUPPLICATE DATA
  64936. * @param value defines the object to push in the array.
  64937. */
  64938. push(value: T): void;
  64939. /**
  64940. * Pushes a value at the end of the active data.
  64941. * If the data is already present, it won t be added again
  64942. * @param value defines the object to push in the array.
  64943. * @returns true if added false if it was already present
  64944. */
  64945. pushNoDuplicate(value: T): boolean;
  64946. /**
  64947. * Resets the active data to an empty array.
  64948. */
  64949. reset(): void;
  64950. /**
  64951. * Concats the active data with a given array.
  64952. * This ensures no dupplicate will be present in the result.
  64953. * @param array defines the data to concatenate with.
  64954. */
  64955. concatWithNoDuplicate(array: any): void;
  64956. }
  64957. }
  64958. declare module BABYLON {
  64959. /**
  64960. * A multi-material is used to apply different materials to different parts of the same object without the need of
  64961. * separate meshes. This can be use to improve performances.
  64962. * @see http://doc.babylonjs.com/how_to/multi_materials
  64963. */
  64964. export class MultiMaterial extends Material {
  64965. private _subMaterials;
  64966. /**
  64967. * Gets or Sets the list of Materials used within the multi material.
  64968. * They need to be ordered according to the submeshes order in the associated mesh
  64969. */
  64970. subMaterials: Nullable<Material>[];
  64971. /**
  64972. * Function used to align with Node.getChildren()
  64973. * @returns the list of Materials used within the multi material
  64974. */
  64975. getChildren(): Nullable<Material>[];
  64976. /**
  64977. * Instantiates a new Multi Material
  64978. * A multi-material is used to apply different materials to different parts of the same object without the need of
  64979. * separate meshes. This can be use to improve performances.
  64980. * @see http://doc.babylonjs.com/how_to/multi_materials
  64981. * @param name Define the name in the scene
  64982. * @param scene Define the scene the material belongs to
  64983. */
  64984. constructor(name: string, scene: Scene);
  64985. private _hookArray;
  64986. /**
  64987. * Get one of the submaterial by its index in the submaterials array
  64988. * @param index The index to look the sub material at
  64989. * @returns The Material if the index has been defined
  64990. */
  64991. getSubMaterial(index: number): Nullable<Material>;
  64992. /**
  64993. * Get the list of active textures for the whole sub materials list.
  64994. * @returns All the textures that will be used during the rendering
  64995. */
  64996. getActiveTextures(): BaseTexture[];
  64997. /**
  64998. * Gets the current class name of the material e.g. "MultiMaterial"
  64999. * Mainly use in serialization.
  65000. * @returns the class name
  65001. */
  65002. getClassName(): string;
  65003. /**
  65004. * Checks if the material is ready to render the requested sub mesh
  65005. * @param mesh Define the mesh the submesh belongs to
  65006. * @param subMesh Define the sub mesh to look readyness for
  65007. * @param useInstances Define whether or not the material is used with instances
  65008. * @returns true if ready, otherwise false
  65009. */
  65010. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  65011. /**
  65012. * Clones the current material and its related sub materials
  65013. * @param name Define the name of the newly cloned material
  65014. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  65015. * @returns the cloned material
  65016. */
  65017. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  65018. /**
  65019. * Serializes the materials into a JSON representation.
  65020. * @returns the JSON representation
  65021. */
  65022. serialize(): any;
  65023. /**
  65024. * Dispose the material and release its associated resources
  65025. * @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)
  65026. * @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)
  65027. * @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)
  65028. */
  65029. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  65030. /**
  65031. * Creates a MultiMaterial from parsed MultiMaterial data.
  65032. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  65033. * @param scene defines the hosting scene
  65034. * @returns a new MultiMaterial
  65035. */
  65036. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  65037. }
  65038. }
  65039. declare module BABYLON {
  65040. /**
  65041. * Class used to represent data loading progression
  65042. */
  65043. export class SceneLoaderFlags {
  65044. private static _ForceFullSceneLoadingForIncremental;
  65045. private static _ShowLoadingScreen;
  65046. private static _CleanBoneMatrixWeights;
  65047. private static _loggingLevel;
  65048. /**
  65049. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  65050. */
  65051. static ForceFullSceneLoadingForIncremental: boolean;
  65052. /**
  65053. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  65054. */
  65055. static ShowLoadingScreen: boolean;
  65056. /**
  65057. * Defines the current logging level (while loading the scene)
  65058. * @ignorenaming
  65059. */
  65060. static loggingLevel: number;
  65061. /**
  65062. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  65063. */
  65064. static CleanBoneMatrixWeights: boolean;
  65065. }
  65066. }
  65067. declare module BABYLON {
  65068. /**
  65069. * 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.
  65070. * @see https://doc.babylonjs.com/how_to/transformnode
  65071. */
  65072. export class TransformNode extends Node {
  65073. /**
  65074. * Object will not rotate to face the camera
  65075. */
  65076. static BILLBOARDMODE_NONE: number;
  65077. /**
  65078. * Object will rotate to face the camera but only on the x axis
  65079. */
  65080. static BILLBOARDMODE_X: number;
  65081. /**
  65082. * Object will rotate to face the camera but only on the y axis
  65083. */
  65084. static BILLBOARDMODE_Y: number;
  65085. /**
  65086. * Object will rotate to face the camera but only on the z axis
  65087. */
  65088. static BILLBOARDMODE_Z: number;
  65089. /**
  65090. * Object will rotate to face the camera
  65091. */
  65092. static BILLBOARDMODE_ALL: number;
  65093. private _forward;
  65094. private _forwardInverted;
  65095. private _up;
  65096. private _right;
  65097. private _rightInverted;
  65098. private _position;
  65099. private _rotation;
  65100. private _rotationQuaternion;
  65101. protected _scaling: Vector3;
  65102. protected _isDirty: boolean;
  65103. private _transformToBoneReferal;
  65104. /**
  65105. * Set the billboard mode. Default is 0.
  65106. *
  65107. * | Value | Type | Description |
  65108. * | --- | --- | --- |
  65109. * | 0 | BILLBOARDMODE_NONE | |
  65110. * | 1 | BILLBOARDMODE_X | |
  65111. * | 2 | BILLBOARDMODE_Y | |
  65112. * | 4 | BILLBOARDMODE_Z | |
  65113. * | 7 | BILLBOARDMODE_ALL | |
  65114. *
  65115. */
  65116. billboardMode: number;
  65117. /**
  65118. * 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
  65119. */
  65120. scalingDeterminant: number;
  65121. /**
  65122. * Sets the distance of the object to max, often used by skybox
  65123. */
  65124. infiniteDistance: boolean;
  65125. /**
  65126. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  65127. * By default the system will update normals to compensate
  65128. */
  65129. ignoreNonUniformScaling: boolean;
  65130. /** @hidden */
  65131. _poseMatrix: Matrix;
  65132. /** @hidden */
  65133. _localMatrix: Matrix;
  65134. private _absolutePosition;
  65135. private _pivotMatrix;
  65136. private _pivotMatrixInverse;
  65137. protected _postMultiplyPivotMatrix: boolean;
  65138. private _tempMatrix;
  65139. private _tempMatrix2;
  65140. protected _isWorldMatrixFrozen: boolean;
  65141. /** @hidden */
  65142. _indexInSceneTransformNodesArray: number;
  65143. /**
  65144. * An event triggered after the world matrix is updated
  65145. */
  65146. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  65147. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  65148. /**
  65149. * Gets a string identifying the name of the class
  65150. * @returns "TransformNode" string
  65151. */
  65152. getClassName(): string;
  65153. /**
  65154. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  65155. */
  65156. position: Vector3;
  65157. /**
  65158. * 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)).
  65159. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  65160. */
  65161. rotation: Vector3;
  65162. /**
  65163. * 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)).
  65164. */
  65165. scaling: Vector3;
  65166. /**
  65167. * 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).
  65168. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  65169. */
  65170. rotationQuaternion: Nullable<Quaternion>;
  65171. /**
  65172. * The forward direction of that transform in world space.
  65173. */
  65174. readonly forward: Vector3;
  65175. /**
  65176. * The up direction of that transform in world space.
  65177. */
  65178. readonly up: Vector3;
  65179. /**
  65180. * The right direction of that transform in world space.
  65181. */
  65182. readonly right: Vector3;
  65183. /**
  65184. * Copies the parameter passed Matrix into the mesh Pose matrix.
  65185. * @param matrix the matrix to copy the pose from
  65186. * @returns this TransformNode.
  65187. */
  65188. updatePoseMatrix(matrix: Matrix): TransformNode;
  65189. /**
  65190. * Returns the mesh Pose matrix.
  65191. * @returns the pose matrix
  65192. */
  65193. getPoseMatrix(): Matrix;
  65194. /** @hidden */
  65195. _isSynchronized(): boolean;
  65196. /** @hidden */
  65197. _initCache(): void;
  65198. /**
  65199. * Flag the transform node as dirty (Forcing it to update everything)
  65200. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  65201. * @returns this transform node
  65202. */
  65203. markAsDirty(property: string): TransformNode;
  65204. /**
  65205. * Returns the current mesh absolute position.
  65206. * Returns a Vector3.
  65207. */
  65208. readonly absolutePosition: Vector3;
  65209. /**
  65210. * Sets a new matrix to apply before all other transformation
  65211. * @param matrix defines the transform matrix
  65212. * @returns the current TransformNode
  65213. */
  65214. setPreTransformMatrix(matrix: Matrix): TransformNode;
  65215. /**
  65216. * Sets a new pivot matrix to the current node
  65217. * @param matrix defines the new pivot matrix to use
  65218. * @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
  65219. * @returns the current TransformNode
  65220. */
  65221. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  65222. /**
  65223. * Returns the mesh pivot matrix.
  65224. * Default : Identity.
  65225. * @returns the matrix
  65226. */
  65227. getPivotMatrix(): Matrix;
  65228. /**
  65229. * Prevents the World matrix to be computed any longer.
  65230. * @returns the TransformNode.
  65231. */
  65232. freezeWorldMatrix(): TransformNode;
  65233. /**
  65234. * Allows back the World matrix computation.
  65235. * @returns the TransformNode.
  65236. */
  65237. unfreezeWorldMatrix(): this;
  65238. /**
  65239. * True if the World matrix has been frozen.
  65240. */
  65241. readonly isWorldMatrixFrozen: boolean;
  65242. /**
  65243. * Retuns the mesh absolute position in the World.
  65244. * @returns a Vector3.
  65245. */
  65246. getAbsolutePosition(): Vector3;
  65247. /**
  65248. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  65249. * @param absolutePosition the absolute position to set
  65250. * @returns the TransformNode.
  65251. */
  65252. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  65253. /**
  65254. * Sets the mesh position in its local space.
  65255. * @param vector3 the position to set in localspace
  65256. * @returns the TransformNode.
  65257. */
  65258. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  65259. /**
  65260. * Returns the mesh position in the local space from the current World matrix values.
  65261. * @returns a new Vector3.
  65262. */
  65263. getPositionExpressedInLocalSpace(): Vector3;
  65264. /**
  65265. * Translates the mesh along the passed Vector3 in its local space.
  65266. * @param vector3 the distance to translate in localspace
  65267. * @returns the TransformNode.
  65268. */
  65269. locallyTranslate(vector3: Vector3): TransformNode;
  65270. private static _lookAtVectorCache;
  65271. /**
  65272. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  65273. * @param targetPoint the position (must be in same space as current mesh) to look at
  65274. * @param yawCor optional yaw (y-axis) correction in radians
  65275. * @param pitchCor optional pitch (x-axis) correction in radians
  65276. * @param rollCor optional roll (z-axis) correction in radians
  65277. * @param space the choosen space of the target
  65278. * @returns the TransformNode.
  65279. */
  65280. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  65281. /**
  65282. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  65283. * This Vector3 is expressed in the World space.
  65284. * @param localAxis axis to rotate
  65285. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  65286. */
  65287. getDirection(localAxis: Vector3): Vector3;
  65288. /**
  65289. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  65290. * localAxis is expressed in the mesh local space.
  65291. * result is computed in the Wordl space from the mesh World matrix.
  65292. * @param localAxis axis to rotate
  65293. * @param result the resulting transformnode
  65294. * @returns this TransformNode.
  65295. */
  65296. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  65297. /**
  65298. * Sets this transform node rotation to the given local axis.
  65299. * @param localAxis the axis in local space
  65300. * @param yawCor optional yaw (y-axis) correction in radians
  65301. * @param pitchCor optional pitch (x-axis) correction in radians
  65302. * @param rollCor optional roll (z-axis) correction in radians
  65303. * @returns this TransformNode
  65304. */
  65305. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  65306. /**
  65307. * Sets a new pivot point to the current node
  65308. * @param point defines the new pivot point to use
  65309. * @param space defines if the point is in world or local space (local by default)
  65310. * @returns the current TransformNode
  65311. */
  65312. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  65313. /**
  65314. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  65315. * @returns the pivot point
  65316. */
  65317. getPivotPoint(): Vector3;
  65318. /**
  65319. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  65320. * @param result the vector3 to store the result
  65321. * @returns this TransformNode.
  65322. */
  65323. getPivotPointToRef(result: Vector3): TransformNode;
  65324. /**
  65325. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  65326. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  65327. */
  65328. getAbsolutePivotPoint(): Vector3;
  65329. /**
  65330. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  65331. * @param result vector3 to store the result
  65332. * @returns this TransformNode.
  65333. */
  65334. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  65335. /**
  65336. * Defines the passed node as the parent of the current node.
  65337. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  65338. * @param node the node ot set as the parent
  65339. * @returns this TransformNode.
  65340. */
  65341. setParent(node: Nullable<Node>): TransformNode;
  65342. private _nonUniformScaling;
  65343. /**
  65344. * True if the scaling property of this object is non uniform eg. (1,2,1)
  65345. */
  65346. readonly nonUniformScaling: boolean;
  65347. /** @hidden */
  65348. _updateNonUniformScalingState(value: boolean): boolean;
  65349. /**
  65350. * Attach the current TransformNode to another TransformNode associated with a bone
  65351. * @param bone Bone affecting the TransformNode
  65352. * @param affectedTransformNode TransformNode associated with the bone
  65353. * @returns this object
  65354. */
  65355. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  65356. /**
  65357. * Detach the transform node if its associated with a bone
  65358. * @returns this object
  65359. */
  65360. detachFromBone(): TransformNode;
  65361. private static _rotationAxisCache;
  65362. /**
  65363. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  65364. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  65365. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  65366. * The passed axis is also normalized.
  65367. * @param axis the axis to rotate around
  65368. * @param amount the amount to rotate in radians
  65369. * @param space Space to rotate in (Default: local)
  65370. * @returns the TransformNode.
  65371. */
  65372. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  65373. /**
  65374. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  65375. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  65376. * The passed axis is also normalized. .
  65377. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  65378. * @param point the point to rotate around
  65379. * @param axis the axis to rotate around
  65380. * @param amount the amount to rotate in radians
  65381. * @returns the TransformNode
  65382. */
  65383. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  65384. /**
  65385. * Translates the mesh along the axis vector for the passed distance in the given space.
  65386. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  65387. * @param axis the axis to translate in
  65388. * @param distance the distance to translate
  65389. * @param space Space to rotate in (Default: local)
  65390. * @returns the TransformNode.
  65391. */
  65392. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  65393. /**
  65394. * Adds a rotation step to the mesh current rotation.
  65395. * x, y, z are Euler angles expressed in radians.
  65396. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  65397. * This means this rotation is made in the mesh local space only.
  65398. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  65399. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  65400. * ```javascript
  65401. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  65402. * ```
  65403. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  65404. * 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.
  65405. * @param x Rotation to add
  65406. * @param y Rotation to add
  65407. * @param z Rotation to add
  65408. * @returns the TransformNode.
  65409. */
  65410. addRotation(x: number, y: number, z: number): TransformNode;
  65411. /**
  65412. * Computes the world matrix of the node
  65413. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  65414. * @returns the world matrix
  65415. */
  65416. computeWorldMatrix(force?: boolean): Matrix;
  65417. protected _afterComputeWorldMatrix(): void;
  65418. /**
  65419. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  65420. * @param func callback function to add
  65421. *
  65422. * @returns the TransformNode.
  65423. */
  65424. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  65425. /**
  65426. * Removes a registered callback function.
  65427. * @param func callback function to remove
  65428. * @returns the TransformNode.
  65429. */
  65430. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  65431. /**
  65432. * Gets the position of the current mesh in camera space
  65433. * @param camera defines the camera to use
  65434. * @returns a position
  65435. */
  65436. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  65437. /**
  65438. * Returns the distance from the mesh to the active camera
  65439. * @param camera defines the camera to use
  65440. * @returns the distance
  65441. */
  65442. getDistanceToCamera(camera?: Nullable<Camera>): number;
  65443. /**
  65444. * Clone the current transform node
  65445. * @param name Name of the new clone
  65446. * @param newParent New parent for the clone
  65447. * @param doNotCloneChildren Do not clone children hierarchy
  65448. * @returns the new transform node
  65449. */
  65450. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  65451. /**
  65452. * Serializes the objects information.
  65453. * @param currentSerializationObject defines the object to serialize in
  65454. * @returns the serialized object
  65455. */
  65456. serialize(currentSerializationObject?: any): any;
  65457. /**
  65458. * Returns a new TransformNode object parsed from the source provided.
  65459. * @param parsedTransformNode is the source.
  65460. * @param scene the scne the object belongs to
  65461. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  65462. * @returns a new TransformNode object parsed from the source provided.
  65463. */
  65464. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  65465. /**
  65466. * Get all child-transformNodes of this node
  65467. * @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
  65468. * @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
  65469. * @returns an array of TransformNode
  65470. */
  65471. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  65472. /**
  65473. * Releases resources associated with this transform node.
  65474. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  65475. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  65476. */
  65477. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  65478. }
  65479. }
  65480. declare module BABYLON {
  65481. /**
  65482. * Class used to override all child animations of a given target
  65483. */
  65484. export class AnimationPropertiesOverride {
  65485. /**
  65486. * Gets or sets a value indicating if animation blending must be used
  65487. */
  65488. enableBlending: boolean;
  65489. /**
  65490. * Gets or sets the blending speed to use when enableBlending is true
  65491. */
  65492. blendingSpeed: number;
  65493. /**
  65494. * Gets or sets the default loop mode to use
  65495. */
  65496. loopMode: number;
  65497. }
  65498. }
  65499. declare module BABYLON {
  65500. /**
  65501. * Class used to store bone information
  65502. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  65503. */
  65504. export class Bone extends Node {
  65505. /**
  65506. * defines the bone name
  65507. */
  65508. name: string;
  65509. private static _tmpVecs;
  65510. private static _tmpQuat;
  65511. private static _tmpMats;
  65512. /**
  65513. * Gets the list of child bones
  65514. */
  65515. children: Bone[];
  65516. /** Gets the animations associated with this bone */
  65517. animations: Animation[];
  65518. /**
  65519. * Gets or sets bone length
  65520. */
  65521. length: number;
  65522. /**
  65523. * @hidden Internal only
  65524. * Set this value to map this bone to a different index in the transform matrices
  65525. * Set this value to -1 to exclude the bone from the transform matrices
  65526. */
  65527. _index: Nullable<number>;
  65528. private _skeleton;
  65529. private _localMatrix;
  65530. private _restPose;
  65531. private _baseMatrix;
  65532. private _absoluteTransform;
  65533. private _invertedAbsoluteTransform;
  65534. private _parent;
  65535. private _scalingDeterminant;
  65536. private _worldTransform;
  65537. private _localScaling;
  65538. private _localRotation;
  65539. private _localPosition;
  65540. private _needToDecompose;
  65541. private _needToCompose;
  65542. /** @hidden */
  65543. _linkedTransformNode: Nullable<TransformNode>;
  65544. /** @hidden */
  65545. /** @hidden */
  65546. _matrix: Matrix;
  65547. /**
  65548. * Create a new bone
  65549. * @param name defines the bone name
  65550. * @param skeleton defines the parent skeleton
  65551. * @param parentBone defines the parent (can be null if the bone is the root)
  65552. * @param localMatrix defines the local matrix
  65553. * @param restPose defines the rest pose matrix
  65554. * @param baseMatrix defines the base matrix
  65555. * @param index defines index of the bone in the hiearchy
  65556. */
  65557. constructor(
  65558. /**
  65559. * defines the bone name
  65560. */
  65561. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  65562. /**
  65563. * Gets the current object class name.
  65564. * @return the class name
  65565. */
  65566. getClassName(): string;
  65567. /**
  65568. * Gets the parent skeleton
  65569. * @returns a skeleton
  65570. */
  65571. getSkeleton(): Skeleton;
  65572. /**
  65573. * Gets parent bone
  65574. * @returns a bone or null if the bone is the root of the bone hierarchy
  65575. */
  65576. getParent(): Nullable<Bone>;
  65577. /**
  65578. * Returns an array containing the root bones
  65579. * @returns an array containing the root bones
  65580. */
  65581. getChildren(): Array<Bone>;
  65582. /**
  65583. * Sets the parent bone
  65584. * @param parent defines the parent (can be null if the bone is the root)
  65585. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  65586. */
  65587. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  65588. /**
  65589. * Gets the local matrix
  65590. * @returns a matrix
  65591. */
  65592. getLocalMatrix(): Matrix;
  65593. /**
  65594. * Gets the base matrix (initial matrix which remains unchanged)
  65595. * @returns a matrix
  65596. */
  65597. getBaseMatrix(): Matrix;
  65598. /**
  65599. * Gets the rest pose matrix
  65600. * @returns a matrix
  65601. */
  65602. getRestPose(): Matrix;
  65603. /**
  65604. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  65605. */
  65606. getWorldMatrix(): Matrix;
  65607. /**
  65608. * Sets the local matrix to rest pose matrix
  65609. */
  65610. returnToRest(): void;
  65611. /**
  65612. * Gets the inverse of the absolute transform matrix.
  65613. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  65614. * @returns a matrix
  65615. */
  65616. getInvertedAbsoluteTransform(): Matrix;
  65617. /**
  65618. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  65619. * @returns a matrix
  65620. */
  65621. getAbsoluteTransform(): Matrix;
  65622. /**
  65623. * Links with the given transform node.
  65624. * The local matrix of this bone is copied from the transform node every frame.
  65625. * @param transformNode defines the transform node to link to
  65626. */
  65627. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  65628. /** Gets or sets current position (in local space) */
  65629. position: Vector3;
  65630. /** Gets or sets current rotation (in local space) */
  65631. rotation: Vector3;
  65632. /** Gets or sets current rotation quaternion (in local space) */
  65633. rotationQuaternion: Quaternion;
  65634. /** Gets or sets current scaling (in local space) */
  65635. scaling: Vector3;
  65636. /**
  65637. * Gets the animation properties override
  65638. */
  65639. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  65640. private _decompose;
  65641. private _compose;
  65642. /**
  65643. * Update the base and local matrices
  65644. * @param matrix defines the new base or local matrix
  65645. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  65646. * @param updateLocalMatrix defines if the local matrix should be updated
  65647. */
  65648. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  65649. /** @hidden */
  65650. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  65651. /**
  65652. * Flag the bone as dirty (Forcing it to update everything)
  65653. */
  65654. markAsDirty(): void;
  65655. private _markAsDirtyAndCompose;
  65656. private _markAsDirtyAndDecompose;
  65657. /**
  65658. * Translate the bone in local or world space
  65659. * @param vec The amount to translate the bone
  65660. * @param space The space that the translation is in
  65661. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65662. */
  65663. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  65664. /**
  65665. * Set the postion of the bone in local or world space
  65666. * @param position The position to set the bone
  65667. * @param space The space that the position is in
  65668. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65669. */
  65670. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  65671. /**
  65672. * Set the absolute position of the bone (world space)
  65673. * @param position The position to set the bone
  65674. * @param mesh The mesh that this bone is attached to
  65675. */
  65676. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  65677. /**
  65678. * Scale the bone on the x, y and z axes (in local space)
  65679. * @param x The amount to scale the bone on the x axis
  65680. * @param y The amount to scale the bone on the y axis
  65681. * @param z The amount to scale the bone on the z axis
  65682. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  65683. */
  65684. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  65685. /**
  65686. * Set the bone scaling in local space
  65687. * @param scale defines the scaling vector
  65688. */
  65689. setScale(scale: Vector3): void;
  65690. /**
  65691. * Gets the current scaling in local space
  65692. * @returns the current scaling vector
  65693. */
  65694. getScale(): Vector3;
  65695. /**
  65696. * Gets the current scaling in local space and stores it in a target vector
  65697. * @param result defines the target vector
  65698. */
  65699. getScaleToRef(result: Vector3): void;
  65700. /**
  65701. * Set the yaw, pitch, and roll of the bone in local or world space
  65702. * @param yaw The rotation of the bone on the y axis
  65703. * @param pitch The rotation of the bone on the x axis
  65704. * @param roll The rotation of the bone on the z axis
  65705. * @param space The space that the axes of rotation are in
  65706. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65707. */
  65708. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  65709. /**
  65710. * Add a rotation to the bone on an axis in local or world space
  65711. * @param axis The axis to rotate the bone on
  65712. * @param amount The amount to rotate the bone
  65713. * @param space The space that the axis is in
  65714. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65715. */
  65716. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  65717. /**
  65718. * Set the rotation of the bone to a particular axis angle in local or world space
  65719. * @param axis The axis to rotate the bone on
  65720. * @param angle The angle that the bone should be rotated to
  65721. * @param space The space that the axis is in
  65722. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65723. */
  65724. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  65725. /**
  65726. * Set the euler rotation of the bone in local of world space
  65727. * @param rotation The euler rotation that the bone should be set to
  65728. * @param space The space that the rotation is in
  65729. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65730. */
  65731. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  65732. /**
  65733. * Set the quaternion rotation of the bone in local of world space
  65734. * @param quat The quaternion rotation that the bone should be set to
  65735. * @param space The space that the rotation is in
  65736. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65737. */
  65738. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  65739. /**
  65740. * Set the rotation matrix of the bone in local of world space
  65741. * @param rotMat The rotation matrix that the bone should be set to
  65742. * @param space The space that the rotation is in
  65743. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65744. */
  65745. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  65746. private _rotateWithMatrix;
  65747. private _getNegativeRotationToRef;
  65748. /**
  65749. * Get the position of the bone in local or world space
  65750. * @param space The space that the returned position is in
  65751. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65752. * @returns The position of the bone
  65753. */
  65754. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  65755. /**
  65756. * Copy the position of the bone to a vector3 in local or world space
  65757. * @param space The space that the returned position is in
  65758. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65759. * @param result The vector3 to copy the position to
  65760. */
  65761. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  65762. /**
  65763. * Get the absolute position of the bone (world space)
  65764. * @param mesh The mesh that this bone is attached to
  65765. * @returns The absolute position of the bone
  65766. */
  65767. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  65768. /**
  65769. * Copy the absolute position of the bone (world space) to the result param
  65770. * @param mesh The mesh that this bone is attached to
  65771. * @param result The vector3 to copy the absolute position to
  65772. */
  65773. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  65774. /**
  65775. * Compute the absolute transforms of this bone and its children
  65776. */
  65777. computeAbsoluteTransforms(): void;
  65778. /**
  65779. * Get the world direction from an axis that is in the local space of the bone
  65780. * @param localAxis The local direction that is used to compute the world direction
  65781. * @param mesh The mesh that this bone is attached to
  65782. * @returns The world direction
  65783. */
  65784. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  65785. /**
  65786. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  65787. * @param localAxis The local direction that is used to compute the world direction
  65788. * @param mesh The mesh that this bone is attached to
  65789. * @param result The vector3 that the world direction will be copied to
  65790. */
  65791. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  65792. /**
  65793. * Get the euler rotation of the bone in local or world space
  65794. * @param space The space that the rotation should be in
  65795. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65796. * @returns The euler rotation
  65797. */
  65798. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  65799. /**
  65800. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  65801. * @param space The space that the rotation should be in
  65802. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65803. * @param result The vector3 that the rotation should be copied to
  65804. */
  65805. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  65806. /**
  65807. * Get the quaternion rotation of the bone in either local or world space
  65808. * @param space The space that the rotation should be in
  65809. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65810. * @returns The quaternion rotation
  65811. */
  65812. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  65813. /**
  65814. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  65815. * @param space The space that the rotation should be in
  65816. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65817. * @param result The quaternion that the rotation should be copied to
  65818. */
  65819. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  65820. /**
  65821. * Get the rotation matrix of the bone in local or world space
  65822. * @param space The space that the rotation should be in
  65823. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65824. * @returns The rotation matrix
  65825. */
  65826. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  65827. /**
  65828. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  65829. * @param space The space that the rotation should be in
  65830. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65831. * @param result The quaternion that the rotation should be copied to
  65832. */
  65833. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  65834. /**
  65835. * Get the world position of a point that is in the local space of the bone
  65836. * @param position The local position
  65837. * @param mesh The mesh that this bone is attached to
  65838. * @returns The world position
  65839. */
  65840. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  65841. /**
  65842. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  65843. * @param position The local position
  65844. * @param mesh The mesh that this bone is attached to
  65845. * @param result The vector3 that the world position should be copied to
  65846. */
  65847. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  65848. /**
  65849. * Get the local position of a point that is in world space
  65850. * @param position The world position
  65851. * @param mesh The mesh that this bone is attached to
  65852. * @returns The local position
  65853. */
  65854. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  65855. /**
  65856. * Get the local position of a point that is in world space and copy it to the result param
  65857. * @param position The world position
  65858. * @param mesh The mesh that this bone is attached to
  65859. * @param result The vector3 that the local position should be copied to
  65860. */
  65861. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  65862. }
  65863. }
  65864. declare module BABYLON {
  65865. /**
  65866. * Class for creating a cube texture
  65867. */
  65868. export class CubeTexture extends BaseTexture {
  65869. private _delayedOnLoad;
  65870. /**
  65871. * The url of the texture
  65872. */
  65873. url: string;
  65874. /**
  65875. * Gets or sets the center of the bounding box associated with the cube texture.
  65876. * It must define where the camera used to render the texture was set
  65877. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  65878. */
  65879. boundingBoxPosition: Vector3;
  65880. private _boundingBoxSize;
  65881. /**
  65882. * Gets or sets the size of the bounding box associated with the cube texture
  65883. * When defined, the cubemap will switch to local mode
  65884. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  65885. * @example https://www.babylonjs-playground.com/#RNASML
  65886. */
  65887. /**
  65888. * Returns the bounding box size
  65889. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  65890. */
  65891. boundingBoxSize: Vector3;
  65892. protected _rotationY: number;
  65893. /**
  65894. * Sets texture matrix rotation angle around Y axis in radians.
  65895. */
  65896. /**
  65897. * Gets texture matrix rotation angle around Y axis radians.
  65898. */
  65899. rotationY: number;
  65900. /**
  65901. * Are mip maps generated for this texture or not.
  65902. */
  65903. readonly noMipmap: boolean;
  65904. private _noMipmap;
  65905. private _files;
  65906. private _extensions;
  65907. private _textureMatrix;
  65908. private _format;
  65909. private _createPolynomials;
  65910. /** @hidden */
  65911. _prefiltered: boolean;
  65912. /**
  65913. * Creates a cube texture from an array of image urls
  65914. * @param files defines an array of image urls
  65915. * @param scene defines the hosting scene
  65916. * @param noMipmap specifies if mip maps are not used
  65917. * @returns a cube texture
  65918. */
  65919. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  65920. /**
  65921. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  65922. * @param url defines the url of the prefiltered texture
  65923. * @param scene defines the scene the texture is attached to
  65924. * @param forcedExtension defines the extension of the file if different from the url
  65925. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  65926. * @return the prefiltered texture
  65927. */
  65928. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  65929. /**
  65930. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  65931. * as prefiltered data.
  65932. * @param rootUrl defines the url of the texture or the root name of the six images
  65933. * @param scene defines the scene the texture is attached to
  65934. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  65935. * @param noMipmap defines if mipmaps should be created or not
  65936. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  65937. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  65938. * @param onError defines a callback triggered in case of error during load
  65939. * @param format defines the internal format to use for the texture once loaded
  65940. * @param prefiltered defines whether or not the texture is created from prefiltered data
  65941. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  65942. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  65943. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  65944. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  65945. * @return the cube texture
  65946. */
  65947. 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);
  65948. /**
  65949. * Get the current class name of the texture useful for serialization or dynamic coding.
  65950. * @returns "CubeTexture"
  65951. */
  65952. getClassName(): string;
  65953. /**
  65954. * Update the url (and optional buffer) of this texture if url was null during construction.
  65955. * @param url the url of the texture
  65956. * @param forcedExtension defines the extension to use
  65957. * @param onLoad callback called when the texture is loaded (defaults to null)
  65958. */
  65959. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  65960. /**
  65961. * Delays loading of the cube texture
  65962. * @param forcedExtension defines the extension to use
  65963. */
  65964. delayLoad(forcedExtension?: string): void;
  65965. /**
  65966. * Returns the reflection texture matrix
  65967. * @returns the reflection texture matrix
  65968. */
  65969. getReflectionTextureMatrix(): Matrix;
  65970. /**
  65971. * Sets the reflection texture matrix
  65972. * @param value Reflection texture matrix
  65973. */
  65974. setReflectionTextureMatrix(value: Matrix): void;
  65975. /**
  65976. * Parses text to create a cube texture
  65977. * @param parsedTexture define the serialized text to read from
  65978. * @param scene defines the hosting scene
  65979. * @param rootUrl defines the root url of the cube texture
  65980. * @returns a cube texture
  65981. */
  65982. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  65983. /**
  65984. * Makes a clone, or deep copy, of the cube texture
  65985. * @returns a new cube texture
  65986. */
  65987. clone(): CubeTexture;
  65988. }
  65989. }
  65990. declare module BABYLON {
  65991. /** @hidden */
  65992. export var postprocessVertexShader: {
  65993. name: string;
  65994. shader: string;
  65995. };
  65996. }
  65997. declare module BABYLON {
  65998. /**
  65999. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  66000. * This is the base of the follow, arc rotate cameras and Free camera
  66001. * @see http://doc.babylonjs.com/features/cameras
  66002. */
  66003. export class TargetCamera extends Camera {
  66004. private static _RigCamTransformMatrix;
  66005. private static _TargetTransformMatrix;
  66006. private static _TargetFocalPoint;
  66007. /**
  66008. * Define the current direction the camera is moving to
  66009. */
  66010. cameraDirection: Vector3;
  66011. /**
  66012. * Define the current rotation the camera is rotating to
  66013. */
  66014. cameraRotation: Vector2;
  66015. /**
  66016. * When set, the up vector of the camera will be updated by the rotation of the camera
  66017. */
  66018. updateUpVectorFromRotation: boolean;
  66019. private _tmpQuaternion;
  66020. /**
  66021. * Define the current rotation of the camera
  66022. */
  66023. rotation: Vector3;
  66024. /**
  66025. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  66026. */
  66027. rotationQuaternion: Quaternion;
  66028. /**
  66029. * Define the current speed of the camera
  66030. */
  66031. speed: number;
  66032. /**
  66033. * Add cconstraint to the camera to prevent it to move freely in all directions and
  66034. * around all axis.
  66035. */
  66036. noRotationConstraint: boolean;
  66037. /**
  66038. * Define the current target of the camera as an object or a position.
  66039. */
  66040. lockedTarget: any;
  66041. /** @hidden */
  66042. _currentTarget: Vector3;
  66043. /** @hidden */
  66044. _initialFocalDistance: number;
  66045. /** @hidden */
  66046. _viewMatrix: Matrix;
  66047. /** @hidden */
  66048. _camMatrix: Matrix;
  66049. /** @hidden */
  66050. _cameraTransformMatrix: Matrix;
  66051. /** @hidden */
  66052. _cameraRotationMatrix: Matrix;
  66053. /** @hidden */
  66054. _referencePoint: Vector3;
  66055. /** @hidden */
  66056. _transformedReferencePoint: Vector3;
  66057. protected _globalCurrentTarget: Vector3;
  66058. protected _globalCurrentUpVector: Vector3;
  66059. /** @hidden */
  66060. _reset: () => void;
  66061. private _defaultUp;
  66062. /**
  66063. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  66064. * This is the base of the follow, arc rotate cameras and Free camera
  66065. * @see http://doc.babylonjs.com/features/cameras
  66066. * @param name Defines the name of the camera in the scene
  66067. * @param position Defines the start position of the camera in the scene
  66068. * @param scene Defines the scene the camera belongs to
  66069. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  66070. */
  66071. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  66072. /**
  66073. * Gets the position in front of the camera at a given distance.
  66074. * @param distance The distance from the camera we want the position to be
  66075. * @returns the position
  66076. */
  66077. getFrontPosition(distance: number): Vector3;
  66078. /** @hidden */
  66079. _getLockedTargetPosition(): Nullable<Vector3>;
  66080. private _storedPosition;
  66081. private _storedRotation;
  66082. private _storedRotationQuaternion;
  66083. /**
  66084. * Store current camera state of the camera (fov, position, rotation, etc..)
  66085. * @returns the camera
  66086. */
  66087. storeState(): Camera;
  66088. /**
  66089. * Restored camera state. You must call storeState() first
  66090. * @returns whether it was successful or not
  66091. * @hidden
  66092. */
  66093. _restoreStateValues(): boolean;
  66094. /** @hidden */
  66095. _initCache(): void;
  66096. /** @hidden */
  66097. _updateCache(ignoreParentClass?: boolean): void;
  66098. /** @hidden */
  66099. _isSynchronizedViewMatrix(): boolean;
  66100. /** @hidden */
  66101. _computeLocalCameraSpeed(): number;
  66102. /**
  66103. * Defines the target the camera should look at.
  66104. * This will automatically adapt alpha beta and radius to fit within the new target.
  66105. * @param target Defines the new target as a Vector or a mesh
  66106. */
  66107. setTarget(target: Vector3): void;
  66108. /**
  66109. * Return the current target position of the camera. This value is expressed in local space.
  66110. * @returns the target position
  66111. */
  66112. getTarget(): Vector3;
  66113. /** @hidden */
  66114. _decideIfNeedsToMove(): boolean;
  66115. /** @hidden */
  66116. _updatePosition(): void;
  66117. /** @hidden */
  66118. _checkInputs(): void;
  66119. protected _updateCameraRotationMatrix(): void;
  66120. /**
  66121. * 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)
  66122. * @returns the current camera
  66123. */
  66124. private _rotateUpVectorWithCameraRotationMatrix;
  66125. private _cachedRotationZ;
  66126. private _cachedQuaternionRotationZ;
  66127. /** @hidden */
  66128. _getViewMatrix(): Matrix;
  66129. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  66130. /**
  66131. * @hidden
  66132. */
  66133. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  66134. /**
  66135. * @hidden
  66136. */
  66137. _updateRigCameras(): void;
  66138. private _getRigCamPositionAndTarget;
  66139. /**
  66140. * Gets the current object class name.
  66141. * @return the class name
  66142. */
  66143. getClassName(): string;
  66144. }
  66145. }
  66146. declare module BABYLON {
  66147. /**
  66148. * @ignore
  66149. * This is a list of all the different input types that are available in the application.
  66150. * Fo instance: ArcRotateCameraGamepadInput...
  66151. */
  66152. export var CameraInputTypes: {};
  66153. /**
  66154. * This is the contract to implement in order to create a new input class.
  66155. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  66156. */
  66157. export interface ICameraInput<TCamera extends Camera> {
  66158. /**
  66159. * Defines the camera the input is attached to.
  66160. */
  66161. camera: Nullable<TCamera>;
  66162. /**
  66163. * Gets the class name of the current intput.
  66164. * @returns the class name
  66165. */
  66166. getClassName(): string;
  66167. /**
  66168. * Get the friendly name associated with the input class.
  66169. * @returns the input friendly name
  66170. */
  66171. getSimpleName(): string;
  66172. /**
  66173. * Attach the input controls to a specific dom element to get the input from.
  66174. * @param element Defines the element the controls should be listened from
  66175. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  66176. */
  66177. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  66178. /**
  66179. * Detach the current controls from the specified dom element.
  66180. * @param element Defines the element to stop listening the inputs from
  66181. */
  66182. detachControl(element: Nullable<HTMLElement>): void;
  66183. /**
  66184. * Update the current camera state depending on the inputs that have been used this frame.
  66185. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  66186. */
  66187. checkInputs?: () => void;
  66188. }
  66189. /**
  66190. * Represents a map of input types to input instance or input index to input instance.
  66191. */
  66192. export interface CameraInputsMap<TCamera extends Camera> {
  66193. /**
  66194. * Accessor to the input by input type.
  66195. */
  66196. [name: string]: ICameraInput<TCamera>;
  66197. /**
  66198. * Accessor to the input by input index.
  66199. */
  66200. [idx: number]: ICameraInput<TCamera>;
  66201. }
  66202. /**
  66203. * This represents the input manager used within a camera.
  66204. * It helps dealing with all the different kind of input attached to a camera.
  66205. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  66206. */
  66207. export class CameraInputsManager<TCamera extends Camera> {
  66208. /**
  66209. * Defines the list of inputs attahed to the camera.
  66210. */
  66211. attached: CameraInputsMap<TCamera>;
  66212. /**
  66213. * Defines the dom element the camera is collecting inputs from.
  66214. * This is null if the controls have not been attached.
  66215. */
  66216. attachedElement: Nullable<HTMLElement>;
  66217. /**
  66218. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  66219. */
  66220. noPreventDefault: boolean;
  66221. /**
  66222. * Defined the camera the input manager belongs to.
  66223. */
  66224. camera: TCamera;
  66225. /**
  66226. * Update the current camera state depending on the inputs that have been used this frame.
  66227. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  66228. */
  66229. checkInputs: () => void;
  66230. /**
  66231. * Instantiate a new Camera Input Manager.
  66232. * @param camera Defines the camera the input manager blongs to
  66233. */
  66234. constructor(camera: TCamera);
  66235. /**
  66236. * Add an input method to a camera
  66237. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  66238. * @param input camera input method
  66239. */
  66240. add(input: ICameraInput<TCamera>): void;
  66241. /**
  66242. * Remove a specific input method from a camera
  66243. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  66244. * @param inputToRemove camera input method
  66245. */
  66246. remove(inputToRemove: ICameraInput<TCamera>): void;
  66247. /**
  66248. * Remove a specific input type from a camera
  66249. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  66250. * @param inputType the type of the input to remove
  66251. */
  66252. removeByType(inputType: string): void;
  66253. private _addCheckInputs;
  66254. /**
  66255. * Attach the input controls to the currently attached dom element to listen the events from.
  66256. * @param input Defines the input to attach
  66257. */
  66258. attachInput(input: ICameraInput<TCamera>): void;
  66259. /**
  66260. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  66261. * @param element Defines the dom element to collect the events from
  66262. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  66263. */
  66264. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  66265. /**
  66266. * Detach the current manager inputs controls from a specific dom element.
  66267. * @param element Defines the dom element to collect the events from
  66268. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  66269. */
  66270. detachElement(element: HTMLElement, disconnect?: boolean): void;
  66271. /**
  66272. * Rebuild the dynamic inputCheck function from the current list of
  66273. * defined inputs in the manager.
  66274. */
  66275. rebuildInputCheck(): void;
  66276. /**
  66277. * Remove all attached input methods from a camera
  66278. */
  66279. clear(): void;
  66280. /**
  66281. * Serialize the current input manager attached to a camera.
  66282. * This ensures than once parsed,
  66283. * the input associated to the camera will be identical to the current ones
  66284. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  66285. */
  66286. serialize(serializedCamera: any): void;
  66287. /**
  66288. * Parses an input manager serialized JSON to restore the previous list of inputs
  66289. * and states associated to a camera.
  66290. * @param parsedCamera Defines the JSON to parse
  66291. */
  66292. parse(parsedCamera: any): void;
  66293. }
  66294. }
  66295. declare module BABYLON {
  66296. /**
  66297. * Gather the list of keyboard event types as constants.
  66298. */
  66299. export class KeyboardEventTypes {
  66300. /**
  66301. * The keydown event is fired when a key becomes active (pressed).
  66302. */
  66303. static readonly KEYDOWN: number;
  66304. /**
  66305. * The keyup event is fired when a key has been released.
  66306. */
  66307. static readonly KEYUP: number;
  66308. }
  66309. /**
  66310. * This class is used to store keyboard related info for the onKeyboardObservable event.
  66311. */
  66312. export class KeyboardInfo {
  66313. /**
  66314. * Defines the type of event (KeyboardEventTypes)
  66315. */
  66316. type: number;
  66317. /**
  66318. * Defines the related dom event
  66319. */
  66320. event: KeyboardEvent;
  66321. /**
  66322. * Instantiates a new keyboard info.
  66323. * This class is used to store keyboard related info for the onKeyboardObservable event.
  66324. * @param type Defines the type of event (KeyboardEventTypes)
  66325. * @param event Defines the related dom event
  66326. */
  66327. constructor(
  66328. /**
  66329. * Defines the type of event (KeyboardEventTypes)
  66330. */
  66331. type: number,
  66332. /**
  66333. * Defines the related dom event
  66334. */
  66335. event: KeyboardEvent);
  66336. }
  66337. /**
  66338. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  66339. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  66340. */
  66341. export class KeyboardInfoPre extends KeyboardInfo {
  66342. /**
  66343. * Defines the type of event (KeyboardEventTypes)
  66344. */
  66345. type: number;
  66346. /**
  66347. * Defines the related dom event
  66348. */
  66349. event: KeyboardEvent;
  66350. /**
  66351. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  66352. */
  66353. skipOnPointerObservable: boolean;
  66354. /**
  66355. * Instantiates a new keyboard pre info.
  66356. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  66357. * @param type Defines the type of event (KeyboardEventTypes)
  66358. * @param event Defines the related dom event
  66359. */
  66360. constructor(
  66361. /**
  66362. * Defines the type of event (KeyboardEventTypes)
  66363. */
  66364. type: number,
  66365. /**
  66366. * Defines the related dom event
  66367. */
  66368. event: KeyboardEvent);
  66369. }
  66370. }
  66371. declare module BABYLON {
  66372. /**
  66373. * Manage the keyboard inputs to control the movement of a free camera.
  66374. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  66375. */
  66376. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  66377. /**
  66378. * Defines the camera the input is attached to.
  66379. */
  66380. camera: FreeCamera;
  66381. /**
  66382. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  66383. */
  66384. keysUp: number[];
  66385. /**
  66386. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  66387. */
  66388. keysDown: number[];
  66389. /**
  66390. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  66391. */
  66392. keysLeft: number[];
  66393. /**
  66394. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  66395. */
  66396. keysRight: number[];
  66397. private _keys;
  66398. private _onCanvasBlurObserver;
  66399. private _onKeyboardObserver;
  66400. private _engine;
  66401. private _scene;
  66402. /**
  66403. * Attach the input controls to a specific dom element to get the input from.
  66404. * @param element Defines the element the controls should be listened from
  66405. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  66406. */
  66407. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  66408. /**
  66409. * Detach the current controls from the specified dom element.
  66410. * @param element Defines the element to stop listening the inputs from
  66411. */
  66412. detachControl(element: Nullable<HTMLElement>): void;
  66413. /**
  66414. * Update the current camera state depending on the inputs that have been used this frame.
  66415. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  66416. */
  66417. checkInputs(): void;
  66418. /**
  66419. * Gets the class name of the current intput.
  66420. * @returns the class name
  66421. */
  66422. getClassName(): string;
  66423. /** @hidden */
  66424. _onLostFocus(): void;
  66425. /**
  66426. * Get the friendly name associated with the input class.
  66427. * @returns the input friendly name
  66428. */
  66429. getSimpleName(): string;
  66430. }
  66431. }
  66432. declare module BABYLON {
  66433. /**
  66434. * Interface describing all the common properties and methods a shadow light needs to implement.
  66435. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  66436. * as well as binding the different shadow properties to the effects.
  66437. */
  66438. export interface IShadowLight extends Light {
  66439. /**
  66440. * The light id in the scene (used in scene.findLighById for instance)
  66441. */
  66442. id: string;
  66443. /**
  66444. * The position the shdow will be casted from.
  66445. */
  66446. position: Vector3;
  66447. /**
  66448. * In 2d mode (needCube being false), the direction used to cast the shadow.
  66449. */
  66450. direction: Vector3;
  66451. /**
  66452. * The transformed position. Position of the light in world space taking parenting in account.
  66453. */
  66454. transformedPosition: Vector3;
  66455. /**
  66456. * The transformed direction. Direction of the light in world space taking parenting in account.
  66457. */
  66458. transformedDirection: Vector3;
  66459. /**
  66460. * The friendly name of the light in the scene.
  66461. */
  66462. name: string;
  66463. /**
  66464. * Defines the shadow projection clipping minimum z value.
  66465. */
  66466. shadowMinZ: number;
  66467. /**
  66468. * Defines the shadow projection clipping maximum z value.
  66469. */
  66470. shadowMaxZ: number;
  66471. /**
  66472. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  66473. * @returns true if the information has been computed, false if it does not need to (no parenting)
  66474. */
  66475. computeTransformedInformation(): boolean;
  66476. /**
  66477. * Gets the scene the light belongs to.
  66478. * @returns The scene
  66479. */
  66480. getScene(): Scene;
  66481. /**
  66482. * Callback defining a custom Projection Matrix Builder.
  66483. * This can be used to override the default projection matrix computation.
  66484. */
  66485. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  66486. /**
  66487. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  66488. * @param matrix The materix to updated with the projection information
  66489. * @param viewMatrix The transform matrix of the light
  66490. * @param renderList The list of mesh to render in the map
  66491. * @returns The current light
  66492. */
  66493. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  66494. /**
  66495. * Gets the current depth scale used in ESM.
  66496. * @returns The scale
  66497. */
  66498. getDepthScale(): number;
  66499. /**
  66500. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  66501. * @returns true if a cube texture needs to be use
  66502. */
  66503. needCube(): boolean;
  66504. /**
  66505. * Detects if the projection matrix requires to be recomputed this frame.
  66506. * @returns true if it requires to be recomputed otherwise, false.
  66507. */
  66508. needProjectionMatrixCompute(): boolean;
  66509. /**
  66510. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  66511. */
  66512. forceProjectionMatrixCompute(): void;
  66513. /**
  66514. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  66515. * @param faceIndex The index of the face we are computed the direction to generate shadow
  66516. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  66517. */
  66518. getShadowDirection(faceIndex?: number): Vector3;
  66519. /**
  66520. * Gets the minZ used for shadow according to both the scene and the light.
  66521. * @param activeCamera The camera we are returning the min for
  66522. * @returns the depth min z
  66523. */
  66524. getDepthMinZ(activeCamera: Camera): number;
  66525. /**
  66526. * Gets the maxZ used for shadow according to both the scene and the light.
  66527. * @param activeCamera The camera we are returning the max for
  66528. * @returns the depth max z
  66529. */
  66530. getDepthMaxZ(activeCamera: Camera): number;
  66531. }
  66532. /**
  66533. * Base implementation IShadowLight
  66534. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  66535. */
  66536. export abstract class ShadowLight extends Light implements IShadowLight {
  66537. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  66538. protected _position: Vector3;
  66539. protected _setPosition(value: Vector3): void;
  66540. /**
  66541. * Sets the position the shadow will be casted from. Also use as the light position for both
  66542. * point and spot lights.
  66543. */
  66544. /**
  66545. * Sets the position the shadow will be casted from. Also use as the light position for both
  66546. * point and spot lights.
  66547. */
  66548. position: Vector3;
  66549. protected _direction: Vector3;
  66550. protected _setDirection(value: Vector3): void;
  66551. /**
  66552. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  66553. * Also use as the light direction on spot and directional lights.
  66554. */
  66555. /**
  66556. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  66557. * Also use as the light direction on spot and directional lights.
  66558. */
  66559. direction: Vector3;
  66560. private _shadowMinZ;
  66561. /**
  66562. * Gets the shadow projection clipping minimum z value.
  66563. */
  66564. /**
  66565. * Sets the shadow projection clipping minimum z value.
  66566. */
  66567. shadowMinZ: number;
  66568. private _shadowMaxZ;
  66569. /**
  66570. * Sets the shadow projection clipping maximum z value.
  66571. */
  66572. /**
  66573. * Gets the shadow projection clipping maximum z value.
  66574. */
  66575. shadowMaxZ: number;
  66576. /**
  66577. * Callback defining a custom Projection Matrix Builder.
  66578. * This can be used to override the default projection matrix computation.
  66579. */
  66580. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  66581. /**
  66582. * The transformed position. Position of the light in world space taking parenting in account.
  66583. */
  66584. transformedPosition: Vector3;
  66585. /**
  66586. * The transformed direction. Direction of the light in world space taking parenting in account.
  66587. */
  66588. transformedDirection: Vector3;
  66589. private _needProjectionMatrixCompute;
  66590. /**
  66591. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  66592. * @returns true if the information has been computed, false if it does not need to (no parenting)
  66593. */
  66594. computeTransformedInformation(): boolean;
  66595. /**
  66596. * Return the depth scale used for the shadow map.
  66597. * @returns the depth scale.
  66598. */
  66599. getDepthScale(): number;
  66600. /**
  66601. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  66602. * @param faceIndex The index of the face we are computed the direction to generate shadow
  66603. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  66604. */
  66605. getShadowDirection(faceIndex?: number): Vector3;
  66606. /**
  66607. * Returns the ShadowLight absolute position in the World.
  66608. * @returns the position vector in world space
  66609. */
  66610. getAbsolutePosition(): Vector3;
  66611. /**
  66612. * Sets the ShadowLight direction toward the passed target.
  66613. * @param target The point to target in local space
  66614. * @returns the updated ShadowLight direction
  66615. */
  66616. setDirectionToTarget(target: Vector3): Vector3;
  66617. /**
  66618. * Returns the light rotation in euler definition.
  66619. * @returns the x y z rotation in local space.
  66620. */
  66621. getRotation(): Vector3;
  66622. /**
  66623. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  66624. * @returns true if a cube texture needs to be use
  66625. */
  66626. needCube(): boolean;
  66627. /**
  66628. * Detects if the projection matrix requires to be recomputed this frame.
  66629. * @returns true if it requires to be recomputed otherwise, false.
  66630. */
  66631. needProjectionMatrixCompute(): boolean;
  66632. /**
  66633. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  66634. */
  66635. forceProjectionMatrixCompute(): void;
  66636. /** @hidden */
  66637. _initCache(): void;
  66638. /** @hidden */
  66639. _isSynchronized(): boolean;
  66640. /**
  66641. * Computes the world matrix of the node
  66642. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  66643. * @returns the world matrix
  66644. */
  66645. computeWorldMatrix(force?: boolean): Matrix;
  66646. /**
  66647. * Gets the minZ used for shadow according to both the scene and the light.
  66648. * @param activeCamera The camera we are returning the min for
  66649. * @returns the depth min z
  66650. */
  66651. getDepthMinZ(activeCamera: Camera): number;
  66652. /**
  66653. * Gets the maxZ used for shadow according to both the scene and the light.
  66654. * @param activeCamera The camera we are returning the max for
  66655. * @returns the depth max z
  66656. */
  66657. getDepthMaxZ(activeCamera: Camera): number;
  66658. /**
  66659. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  66660. * @param matrix The materix to updated with the projection information
  66661. * @param viewMatrix The transform matrix of the light
  66662. * @param renderList The list of mesh to render in the map
  66663. * @returns The current light
  66664. */
  66665. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  66666. }
  66667. }
  66668. declare module BABYLON {
  66669. /**
  66670. * "Static Class" containing the most commonly used helper while dealing with material for
  66671. * rendering purpose.
  66672. *
  66673. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  66674. *
  66675. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  66676. */
  66677. export class MaterialHelper {
  66678. /**
  66679. * Bind the current view position to an effect.
  66680. * @param effect The effect to be bound
  66681. * @param scene The scene the eyes position is used from
  66682. */
  66683. static BindEyePosition(effect: Effect, scene: Scene): void;
  66684. /**
  66685. * Helps preparing the defines values about the UVs in used in the effect.
  66686. * UVs are shared as much as we can accross channels in the shaders.
  66687. * @param texture The texture we are preparing the UVs for
  66688. * @param defines The defines to update
  66689. * @param key The channel key "diffuse", "specular"... used in the shader
  66690. */
  66691. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  66692. /**
  66693. * Binds a texture matrix value to its corrsponding uniform
  66694. * @param texture The texture to bind the matrix for
  66695. * @param uniformBuffer The uniform buffer receivin the data
  66696. * @param key The channel key "diffuse", "specular"... used in the shader
  66697. */
  66698. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  66699. /**
  66700. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  66701. * @param mesh defines the current mesh
  66702. * @param scene defines the current scene
  66703. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  66704. * @param pointsCloud defines if point cloud rendering has to be turned on
  66705. * @param fogEnabled defines if fog has to be turned on
  66706. * @param alphaTest defines if alpha testing has to be turned on
  66707. * @param defines defines the current list of defines
  66708. */
  66709. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  66710. /**
  66711. * Helper used to prepare the list of defines associated with frame values for shader compilation
  66712. * @param scene defines the current scene
  66713. * @param engine defines the current engine
  66714. * @param defines specifies the list of active defines
  66715. * @param useInstances defines if instances have to be turned on
  66716. * @param useClipPlane defines if clip plane have to be turned on
  66717. */
  66718. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  66719. /**
  66720. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  66721. * @param mesh The mesh containing the geometry data we will draw
  66722. * @param defines The defines to update
  66723. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  66724. * @param useBones Precise whether bones should be used or not (override mesh info)
  66725. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  66726. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  66727. * @returns false if defines are considered not dirty and have not been checked
  66728. */
  66729. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  66730. /**
  66731. * Prepares the defines related to the light information passed in parameter
  66732. * @param scene The scene we are intending to draw
  66733. * @param mesh The mesh the effect is compiling for
  66734. * @param defines The defines to update
  66735. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  66736. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  66737. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  66738. * @returns true if normals will be required for the rest of the effect
  66739. */
  66740. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  66741. /**
  66742. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  66743. * that won t be acctive due to defines being turned off.
  66744. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  66745. * @param samplersList The samplers list
  66746. * @param defines The defines helping in the list generation
  66747. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  66748. */
  66749. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  66750. /**
  66751. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  66752. * @param defines The defines to update while falling back
  66753. * @param fallbacks The authorized effect fallbacks
  66754. * @param maxSimultaneousLights The maximum number of lights allowed
  66755. * @param rank the current rank of the Effect
  66756. * @returns The newly affected rank
  66757. */
  66758. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  66759. /**
  66760. * Prepares the list of attributes required for morph targets according to the effect defines.
  66761. * @param attribs The current list of supported attribs
  66762. * @param mesh The mesh to prepare the morph targets attributes for
  66763. * @param defines The current Defines of the effect
  66764. */
  66765. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  66766. /**
  66767. * Prepares the list of attributes required for bones according to the effect defines.
  66768. * @param attribs The current list of supported attribs
  66769. * @param mesh The mesh to prepare the bones attributes for
  66770. * @param defines The current Defines of the effect
  66771. * @param fallbacks The current efffect fallback strategy
  66772. */
  66773. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  66774. /**
  66775. * Prepares the list of attributes required for instances according to the effect defines.
  66776. * @param attribs The current list of supported attribs
  66777. * @param defines The current Defines of the effect
  66778. */
  66779. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  66780. /**
  66781. * Binds the light shadow information to the effect for the given mesh.
  66782. * @param light The light containing the generator
  66783. * @param scene The scene the lights belongs to
  66784. * @param mesh The mesh we are binding the information to render
  66785. * @param lightIndex The light index in the effect used to render the mesh
  66786. * @param effect The effect we are binding the data to
  66787. */
  66788. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  66789. /**
  66790. * Binds the light information to the effect.
  66791. * @param light The light containing the generator
  66792. * @param effect The effect we are binding the data to
  66793. * @param lightIndex The light index in the effect used to render
  66794. */
  66795. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  66796. /**
  66797. * Binds the lights information from the scene to the effect for the given mesh.
  66798. * @param scene The scene the lights belongs to
  66799. * @param mesh The mesh we are binding the information to render
  66800. * @param effect The effect we are binding the data to
  66801. * @param defines The generated defines for the effect
  66802. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  66803. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  66804. */
  66805. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  66806. private static _tempFogColor;
  66807. /**
  66808. * Binds the fog information from the scene to the effect for the given mesh.
  66809. * @param scene The scene the lights belongs to
  66810. * @param mesh The mesh we are binding the information to render
  66811. * @param effect The effect we are binding the data to
  66812. * @param linearSpace Defines if the fog effect is applied in linear space
  66813. */
  66814. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  66815. /**
  66816. * Binds the bones information from the mesh to the effect.
  66817. * @param mesh The mesh we are binding the information to render
  66818. * @param effect The effect we are binding the data to
  66819. */
  66820. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  66821. /**
  66822. * Binds the morph targets information from the mesh to the effect.
  66823. * @param abstractMesh The mesh we are binding the information to render
  66824. * @param effect The effect we are binding the data to
  66825. */
  66826. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  66827. /**
  66828. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  66829. * @param defines The generated defines used in the effect
  66830. * @param effect The effect we are binding the data to
  66831. * @param scene The scene we are willing to render with logarithmic scale for
  66832. */
  66833. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  66834. /**
  66835. * Binds the clip plane information from the scene to the effect.
  66836. * @param scene The scene the clip plane information are extracted from
  66837. * @param effect The effect we are binding the data to
  66838. */
  66839. static BindClipPlane(effect: Effect, scene: Scene): void;
  66840. }
  66841. }
  66842. declare module BABYLON {
  66843. /** @hidden */
  66844. export var kernelBlurVaryingDeclaration: {
  66845. name: string;
  66846. shader: string;
  66847. };
  66848. }
  66849. declare module BABYLON {
  66850. /** @hidden */
  66851. export var kernelBlurFragment: {
  66852. name: string;
  66853. shader: string;
  66854. };
  66855. }
  66856. declare module BABYLON {
  66857. /** @hidden */
  66858. export var kernelBlurFragment2: {
  66859. name: string;
  66860. shader: string;
  66861. };
  66862. }
  66863. declare module BABYLON {
  66864. /** @hidden */
  66865. export var kernelBlurPixelShader: {
  66866. name: string;
  66867. shader: string;
  66868. };
  66869. }
  66870. declare module BABYLON {
  66871. /** @hidden */
  66872. export var kernelBlurVertex: {
  66873. name: string;
  66874. shader: string;
  66875. };
  66876. }
  66877. declare module BABYLON {
  66878. /** @hidden */
  66879. export var kernelBlurVertexShader: {
  66880. name: string;
  66881. shader: string;
  66882. };
  66883. }
  66884. declare module BABYLON {
  66885. /**
  66886. * The Blur Post Process which blurs an image based on a kernel and direction.
  66887. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  66888. */
  66889. export class BlurPostProcess extends PostProcess {
  66890. /** The direction in which to blur the image. */
  66891. direction: Vector2;
  66892. private blockCompilation;
  66893. protected _kernel: number;
  66894. protected _idealKernel: number;
  66895. protected _packedFloat: boolean;
  66896. private _staticDefines;
  66897. /**
  66898. * Sets the length in pixels of the blur sample region
  66899. */
  66900. /**
  66901. * Gets the length in pixels of the blur sample region
  66902. */
  66903. kernel: number;
  66904. /**
  66905. * Sets wether or not the blur needs to unpack/repack floats
  66906. */
  66907. /**
  66908. * Gets wether or not the blur is unpacking/repacking floats
  66909. */
  66910. packedFloat: boolean;
  66911. /**
  66912. * Creates a new instance BlurPostProcess
  66913. * @param name The name of the effect.
  66914. * @param direction The direction in which to blur the image.
  66915. * @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.
  66916. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  66917. * @param camera The camera to apply the render pass to.
  66918. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  66919. * @param engine The engine which the post process will be applied. (default: current engine)
  66920. * @param reusable If the post process can be reused on the same frame. (default: false)
  66921. * @param textureType Type of textures used when performing the post process. (default: 0)
  66922. * @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)
  66923. */
  66924. constructor(name: string,
  66925. /** The direction in which to blur the image. */
  66926. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  66927. /**
  66928. * Updates the effect with the current post process compile time values and recompiles the shader.
  66929. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  66930. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  66931. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  66932. * @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
  66933. * @param onCompiled Called when the shader has been compiled.
  66934. * @param onError Called if there is an error when compiling a shader.
  66935. */
  66936. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  66937. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  66938. /**
  66939. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  66940. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  66941. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  66942. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  66943. * The gaps between physical kernels are compensated for in the weighting of the samples
  66944. * @param idealKernel Ideal blur kernel.
  66945. * @return Nearest best kernel.
  66946. */
  66947. protected _nearestBestKernel(idealKernel: number): number;
  66948. /**
  66949. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  66950. * @param x The point on the Gaussian distribution to sample.
  66951. * @return the value of the Gaussian function at x.
  66952. */
  66953. protected _gaussianWeight(x: number): number;
  66954. /**
  66955. * Generates a string that can be used as a floating point number in GLSL.
  66956. * @param x Value to print.
  66957. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  66958. * @return GLSL float string.
  66959. */
  66960. protected _glslFloat(x: number, decimalFigures?: number): string;
  66961. }
  66962. }
  66963. declare module BABYLON {
  66964. /** @hidden */
  66965. export var shadowMapPixelShader: {
  66966. name: string;
  66967. shader: string;
  66968. };
  66969. }
  66970. declare module BABYLON {
  66971. /** @hidden */
  66972. export var bonesDeclaration: {
  66973. name: string;
  66974. shader: string;
  66975. };
  66976. }
  66977. declare module BABYLON {
  66978. /** @hidden */
  66979. export var morphTargetsVertexGlobalDeclaration: {
  66980. name: string;
  66981. shader: string;
  66982. };
  66983. }
  66984. declare module BABYLON {
  66985. /** @hidden */
  66986. export var morphTargetsVertexDeclaration: {
  66987. name: string;
  66988. shader: string;
  66989. };
  66990. }
  66991. declare module BABYLON {
  66992. /** @hidden */
  66993. export var instancesDeclaration: {
  66994. name: string;
  66995. shader: string;
  66996. };
  66997. }
  66998. declare module BABYLON {
  66999. /** @hidden */
  67000. export var helperFunctions: {
  67001. name: string;
  67002. shader: string;
  67003. };
  67004. }
  67005. declare module BABYLON {
  67006. /** @hidden */
  67007. export var morphTargetsVertex: {
  67008. name: string;
  67009. shader: string;
  67010. };
  67011. }
  67012. declare module BABYLON {
  67013. /** @hidden */
  67014. export var instancesVertex: {
  67015. name: string;
  67016. shader: string;
  67017. };
  67018. }
  67019. declare module BABYLON {
  67020. /** @hidden */
  67021. export var bonesVertex: {
  67022. name: string;
  67023. shader: string;
  67024. };
  67025. }
  67026. declare module BABYLON {
  67027. /** @hidden */
  67028. export var shadowMapVertexShader: {
  67029. name: string;
  67030. shader: string;
  67031. };
  67032. }
  67033. declare module BABYLON {
  67034. /** @hidden */
  67035. export var depthBoxBlurPixelShader: {
  67036. name: string;
  67037. shader: string;
  67038. };
  67039. }
  67040. declare module BABYLON {
  67041. /**
  67042. * Defines the options associated with the creation of a custom shader for a shadow generator.
  67043. */
  67044. export interface ICustomShaderOptions {
  67045. /**
  67046. * Gets or sets the custom shader name to use
  67047. */
  67048. shaderName: string;
  67049. /**
  67050. * The list of attribute names used in the shader
  67051. */
  67052. attributes?: string[];
  67053. /**
  67054. * The list of unifrom names used in the shader
  67055. */
  67056. uniforms?: string[];
  67057. /**
  67058. * The list of sampler names used in the shader
  67059. */
  67060. samplers?: string[];
  67061. /**
  67062. * The list of defines used in the shader
  67063. */
  67064. defines?: string[];
  67065. }
  67066. /**
  67067. * Interface to implement to create a shadow generator compatible with BJS.
  67068. */
  67069. export interface IShadowGenerator {
  67070. /**
  67071. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  67072. * @returns The render target texture if present otherwise, null
  67073. */
  67074. getShadowMap(): Nullable<RenderTargetTexture>;
  67075. /**
  67076. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  67077. * @returns The render target texture if the shadow map is present otherwise, null
  67078. */
  67079. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  67080. /**
  67081. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  67082. * @param subMesh The submesh we want to render in the shadow map
  67083. * @param useInstances Defines wether will draw in the map using instances
  67084. * @returns true if ready otherwise, false
  67085. */
  67086. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  67087. /**
  67088. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  67089. * @param defines Defines of the material we want to update
  67090. * @param lightIndex Index of the light in the enabled light list of the material
  67091. */
  67092. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  67093. /**
  67094. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  67095. * defined in the generator but impacting the effect).
  67096. * It implies the unifroms available on the materials are the standard BJS ones.
  67097. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  67098. * @param effect The effect we are binfing the information for
  67099. */
  67100. bindShadowLight(lightIndex: string, effect: Effect): void;
  67101. /**
  67102. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  67103. * (eq to shadow prjection matrix * light transform matrix)
  67104. * @returns The transform matrix used to create the shadow map
  67105. */
  67106. getTransformMatrix(): Matrix;
  67107. /**
  67108. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  67109. * Cube and 2D textures for instance.
  67110. */
  67111. recreateShadowMap(): void;
  67112. /**
  67113. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  67114. * @param onCompiled Callback triggered at the and of the effects compilation
  67115. * @param options Sets of optional options forcing the compilation with different modes
  67116. */
  67117. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  67118. useInstances: boolean;
  67119. }>): void;
  67120. /**
  67121. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  67122. * @param options Sets of optional options forcing the compilation with different modes
  67123. * @returns A promise that resolves when the compilation completes
  67124. */
  67125. forceCompilationAsync(options?: Partial<{
  67126. useInstances: boolean;
  67127. }>): Promise<void>;
  67128. /**
  67129. * Serializes the shadow generator setup to a json object.
  67130. * @returns The serialized JSON object
  67131. */
  67132. serialize(): any;
  67133. /**
  67134. * Disposes the Shadow map and related Textures and effects.
  67135. */
  67136. dispose(): void;
  67137. }
  67138. /**
  67139. * Default implementation IShadowGenerator.
  67140. * This is the main object responsible of generating shadows in the framework.
  67141. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  67142. */
  67143. export class ShadowGenerator implements IShadowGenerator {
  67144. /**
  67145. * Shadow generator mode None: no filtering applied.
  67146. */
  67147. static readonly FILTER_NONE: number;
  67148. /**
  67149. * Shadow generator mode ESM: Exponential Shadow Mapping.
  67150. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  67151. */
  67152. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  67153. /**
  67154. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  67155. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  67156. */
  67157. static readonly FILTER_POISSONSAMPLING: number;
  67158. /**
  67159. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  67160. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  67161. */
  67162. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  67163. /**
  67164. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  67165. * edge artifacts on steep falloff.
  67166. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  67167. */
  67168. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  67169. /**
  67170. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  67171. * edge artifacts on steep falloff.
  67172. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  67173. */
  67174. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  67175. /**
  67176. * Shadow generator mode PCF: Percentage Closer Filtering
  67177. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  67178. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  67179. */
  67180. static readonly FILTER_PCF: number;
  67181. /**
  67182. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  67183. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  67184. * Contact Hardening
  67185. */
  67186. static readonly FILTER_PCSS: number;
  67187. /**
  67188. * Reserved for PCF and PCSS
  67189. * Highest Quality.
  67190. *
  67191. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  67192. *
  67193. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  67194. */
  67195. static readonly QUALITY_HIGH: number;
  67196. /**
  67197. * Reserved for PCF and PCSS
  67198. * Good tradeoff for quality/perf cross devices
  67199. *
  67200. * Execute PCF on a 3*3 kernel.
  67201. *
  67202. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  67203. */
  67204. static readonly QUALITY_MEDIUM: number;
  67205. /**
  67206. * Reserved for PCF and PCSS
  67207. * The lowest quality but the fastest.
  67208. *
  67209. * Execute PCF on a 1*1 kernel.
  67210. *
  67211. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  67212. */
  67213. static readonly QUALITY_LOW: number;
  67214. /** Gets or sets the custom shader name to use */
  67215. customShaderOptions: ICustomShaderOptions;
  67216. /**
  67217. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  67218. */
  67219. onBeforeShadowMapRenderObservable: Observable<Effect>;
  67220. /**
  67221. * Observable triggered before a mesh is rendered in the shadow map.
  67222. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  67223. */
  67224. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  67225. private _bias;
  67226. /**
  67227. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  67228. */
  67229. /**
  67230. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  67231. */
  67232. bias: number;
  67233. private _normalBias;
  67234. /**
  67235. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  67236. */
  67237. /**
  67238. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  67239. */
  67240. normalBias: number;
  67241. private _blurBoxOffset;
  67242. /**
  67243. * Gets the blur box offset: offset applied during the blur pass.
  67244. * Only useful if useKernelBlur = false
  67245. */
  67246. /**
  67247. * Sets the blur box offset: offset applied during the blur pass.
  67248. * Only useful if useKernelBlur = false
  67249. */
  67250. blurBoxOffset: number;
  67251. private _blurScale;
  67252. /**
  67253. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  67254. * 2 means half of the size.
  67255. */
  67256. /**
  67257. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  67258. * 2 means half of the size.
  67259. */
  67260. blurScale: number;
  67261. private _blurKernel;
  67262. /**
  67263. * Gets the blur kernel: kernel size of the blur pass.
  67264. * Only useful if useKernelBlur = true
  67265. */
  67266. /**
  67267. * Sets the blur kernel: kernel size of the blur pass.
  67268. * Only useful if useKernelBlur = true
  67269. */
  67270. blurKernel: number;
  67271. private _useKernelBlur;
  67272. /**
  67273. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  67274. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  67275. */
  67276. /**
  67277. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  67278. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  67279. */
  67280. useKernelBlur: boolean;
  67281. private _depthScale;
  67282. /**
  67283. * Gets the depth scale used in ESM mode.
  67284. */
  67285. /**
  67286. * Sets the depth scale used in ESM mode.
  67287. * This can override the scale stored on the light.
  67288. */
  67289. depthScale: number;
  67290. private _filter;
  67291. /**
  67292. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  67293. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  67294. */
  67295. /**
  67296. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  67297. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  67298. */
  67299. filter: number;
  67300. /**
  67301. * Gets if the current filter is set to Poisson Sampling.
  67302. */
  67303. /**
  67304. * Sets the current filter to Poisson Sampling.
  67305. */
  67306. usePoissonSampling: boolean;
  67307. /**
  67308. * Gets if the current filter is set to ESM.
  67309. */
  67310. /**
  67311. * Sets the current filter is to ESM.
  67312. */
  67313. useExponentialShadowMap: boolean;
  67314. /**
  67315. * Gets if the current filter is set to filtered ESM.
  67316. */
  67317. /**
  67318. * Gets if the current filter is set to filtered ESM.
  67319. */
  67320. useBlurExponentialShadowMap: boolean;
  67321. /**
  67322. * Gets if the current filter is set to "close ESM" (using the inverse of the
  67323. * exponential to prevent steep falloff artifacts).
  67324. */
  67325. /**
  67326. * Sets the current filter to "close ESM" (using the inverse of the
  67327. * exponential to prevent steep falloff artifacts).
  67328. */
  67329. useCloseExponentialShadowMap: boolean;
  67330. /**
  67331. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  67332. * exponential to prevent steep falloff artifacts).
  67333. */
  67334. /**
  67335. * Sets the current filter to filtered "close ESM" (using the inverse of the
  67336. * exponential to prevent steep falloff artifacts).
  67337. */
  67338. useBlurCloseExponentialShadowMap: boolean;
  67339. /**
  67340. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  67341. */
  67342. /**
  67343. * Sets the current filter to "PCF" (percentage closer filtering).
  67344. */
  67345. usePercentageCloserFiltering: boolean;
  67346. private _filteringQuality;
  67347. /**
  67348. * Gets the PCF or PCSS Quality.
  67349. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  67350. */
  67351. /**
  67352. * Sets the PCF or PCSS Quality.
  67353. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  67354. */
  67355. filteringQuality: number;
  67356. /**
  67357. * Gets if the current filter is set to "PCSS" (contact hardening).
  67358. */
  67359. /**
  67360. * Sets the current filter to "PCSS" (contact hardening).
  67361. */
  67362. useContactHardeningShadow: boolean;
  67363. private _contactHardeningLightSizeUVRatio;
  67364. /**
  67365. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  67366. * Using a ratio helps keeping shape stability independently of the map size.
  67367. *
  67368. * It does not account for the light projection as it was having too much
  67369. * instability during the light setup or during light position changes.
  67370. *
  67371. * Only valid if useContactHardeningShadow is true.
  67372. */
  67373. /**
  67374. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  67375. * Using a ratio helps keeping shape stability independently of the map size.
  67376. *
  67377. * It does not account for the light projection as it was having too much
  67378. * instability during the light setup or during light position changes.
  67379. *
  67380. * Only valid if useContactHardeningShadow is true.
  67381. */
  67382. contactHardeningLightSizeUVRatio: number;
  67383. private _darkness;
  67384. /**
  67385. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  67386. * 0 means strongest and 1 would means no shadow.
  67387. * @returns the darkness.
  67388. */
  67389. getDarkness(): number;
  67390. /**
  67391. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  67392. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  67393. * @returns the shadow generator allowing fluent coding.
  67394. */
  67395. setDarkness(darkness: number): ShadowGenerator;
  67396. private _transparencyShadow;
  67397. /**
  67398. * Sets the ability to have transparent shadow (boolean).
  67399. * @param transparent True if transparent else False
  67400. * @returns the shadow generator allowing fluent coding
  67401. */
  67402. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  67403. private _shadowMap;
  67404. private _shadowMap2;
  67405. /**
  67406. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  67407. * @returns The render target texture if present otherwise, null
  67408. */
  67409. getShadowMap(): Nullable<RenderTargetTexture>;
  67410. /**
  67411. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  67412. * @returns The render target texture if the shadow map is present otherwise, null
  67413. */
  67414. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  67415. /**
  67416. * Helper function to add a mesh and its descendants to the list of shadow casters.
  67417. * @param mesh Mesh to add
  67418. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  67419. * @returns the Shadow Generator itself
  67420. */
  67421. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  67422. /**
  67423. * Helper function to remove a mesh and its descendants from the list of shadow casters
  67424. * @param mesh Mesh to remove
  67425. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  67426. * @returns the Shadow Generator itself
  67427. */
  67428. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  67429. /**
  67430. * Controls the extent to which the shadows fade out at the edge of the frustum
  67431. * Used only by directionals and spots
  67432. */
  67433. frustumEdgeFalloff: number;
  67434. private _light;
  67435. /**
  67436. * Returns the associated light object.
  67437. * @returns the light generating the shadow
  67438. */
  67439. getLight(): IShadowLight;
  67440. /**
  67441. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  67442. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  67443. * It might on the other hand introduce peter panning.
  67444. */
  67445. forceBackFacesOnly: boolean;
  67446. private _scene;
  67447. private _lightDirection;
  67448. private _effect;
  67449. private _viewMatrix;
  67450. private _projectionMatrix;
  67451. private _transformMatrix;
  67452. private _cachedPosition;
  67453. private _cachedDirection;
  67454. private _cachedDefines;
  67455. private _currentRenderID;
  67456. private _boxBlurPostprocess;
  67457. private _kernelBlurXPostprocess;
  67458. private _kernelBlurYPostprocess;
  67459. private _blurPostProcesses;
  67460. private _mapSize;
  67461. private _currentFaceIndex;
  67462. private _currentFaceIndexCache;
  67463. private _textureType;
  67464. private _defaultTextureMatrix;
  67465. /** @hidden */
  67466. static _SceneComponentInitialization: (scene: Scene) => void;
  67467. /**
  67468. * Creates a ShadowGenerator object.
  67469. * A ShadowGenerator is the required tool to use the shadows.
  67470. * Each light casting shadows needs to use its own ShadowGenerator.
  67471. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  67472. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  67473. * @param light The light object generating the shadows.
  67474. * @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.
  67475. */
  67476. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  67477. private _initializeGenerator;
  67478. private _initializeShadowMap;
  67479. private _initializeBlurRTTAndPostProcesses;
  67480. private _renderForShadowMap;
  67481. private _renderSubMeshForShadowMap;
  67482. private _applyFilterValues;
  67483. /**
  67484. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  67485. * @param onCompiled Callback triggered at the and of the effects compilation
  67486. * @param options Sets of optional options forcing the compilation with different modes
  67487. */
  67488. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  67489. useInstances: boolean;
  67490. }>): void;
  67491. /**
  67492. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  67493. * @param options Sets of optional options forcing the compilation with different modes
  67494. * @returns A promise that resolves when the compilation completes
  67495. */
  67496. forceCompilationAsync(options?: Partial<{
  67497. useInstances: boolean;
  67498. }>): Promise<void>;
  67499. /**
  67500. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  67501. * @param subMesh The submesh we want to render in the shadow map
  67502. * @param useInstances Defines wether will draw in the map using instances
  67503. * @returns true if ready otherwise, false
  67504. */
  67505. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  67506. /**
  67507. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  67508. * @param defines Defines of the material we want to update
  67509. * @param lightIndex Index of the light in the enabled light list of the material
  67510. */
  67511. prepareDefines(defines: any, lightIndex: number): void;
  67512. /**
  67513. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  67514. * defined in the generator but impacting the effect).
  67515. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  67516. * @param effect The effect we are binfing the information for
  67517. */
  67518. bindShadowLight(lightIndex: string, effect: Effect): void;
  67519. /**
  67520. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  67521. * (eq to shadow prjection matrix * light transform matrix)
  67522. * @returns The transform matrix used to create the shadow map
  67523. */
  67524. getTransformMatrix(): Matrix;
  67525. /**
  67526. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  67527. * Cube and 2D textures for instance.
  67528. */
  67529. recreateShadowMap(): void;
  67530. private _disposeBlurPostProcesses;
  67531. private _disposeRTTandPostProcesses;
  67532. /**
  67533. * Disposes the ShadowGenerator.
  67534. * Returns nothing.
  67535. */
  67536. dispose(): void;
  67537. /**
  67538. * Serializes the shadow generator setup to a json object.
  67539. * @returns The serialized JSON object
  67540. */
  67541. serialize(): any;
  67542. /**
  67543. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  67544. * @param parsedShadowGenerator The JSON object to parse
  67545. * @param scene The scene to create the shadow map for
  67546. * @returns The parsed shadow generator
  67547. */
  67548. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  67549. }
  67550. }
  67551. declare module BABYLON {
  67552. /**
  67553. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  67554. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  67555. * 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.
  67556. */
  67557. export abstract class Light extends Node {
  67558. /**
  67559. * Falloff Default: light is falling off following the material specification:
  67560. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  67561. */
  67562. static readonly FALLOFF_DEFAULT: number;
  67563. /**
  67564. * Falloff Physical: light is falling off following the inverse squared distance law.
  67565. */
  67566. static readonly FALLOFF_PHYSICAL: number;
  67567. /**
  67568. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  67569. * to enhance interoperability with other engines.
  67570. */
  67571. static readonly FALLOFF_GLTF: number;
  67572. /**
  67573. * Falloff Standard: light is falling off like in the standard material
  67574. * to enhance interoperability with other materials.
  67575. */
  67576. static readonly FALLOFF_STANDARD: number;
  67577. /**
  67578. * If every light affecting the material is in this lightmapMode,
  67579. * material.lightmapTexture adds or multiplies
  67580. * (depends on material.useLightmapAsShadowmap)
  67581. * after every other light calculations.
  67582. */
  67583. static readonly LIGHTMAP_DEFAULT: number;
  67584. /**
  67585. * material.lightmapTexture as only diffuse lighting from this light
  67586. * adds only specular lighting from this light
  67587. * adds dynamic shadows
  67588. */
  67589. static readonly LIGHTMAP_SPECULAR: number;
  67590. /**
  67591. * material.lightmapTexture as only lighting
  67592. * no light calculation from this light
  67593. * only adds dynamic shadows from this light
  67594. */
  67595. static readonly LIGHTMAP_SHADOWSONLY: number;
  67596. /**
  67597. * Each light type uses the default quantity according to its type:
  67598. * point/spot lights use luminous intensity
  67599. * directional lights use illuminance
  67600. */
  67601. static readonly INTENSITYMODE_AUTOMATIC: number;
  67602. /**
  67603. * lumen (lm)
  67604. */
  67605. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  67606. /**
  67607. * candela (lm/sr)
  67608. */
  67609. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  67610. /**
  67611. * lux (lm/m^2)
  67612. */
  67613. static readonly INTENSITYMODE_ILLUMINANCE: number;
  67614. /**
  67615. * nit (cd/m^2)
  67616. */
  67617. static readonly INTENSITYMODE_LUMINANCE: number;
  67618. /**
  67619. * Light type const id of the point light.
  67620. */
  67621. static readonly LIGHTTYPEID_POINTLIGHT: number;
  67622. /**
  67623. * Light type const id of the directional light.
  67624. */
  67625. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  67626. /**
  67627. * Light type const id of the spot light.
  67628. */
  67629. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  67630. /**
  67631. * Light type const id of the hemispheric light.
  67632. */
  67633. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  67634. /**
  67635. * Diffuse gives the basic color to an object.
  67636. */
  67637. diffuse: Color3;
  67638. /**
  67639. * Specular produces a highlight color on an object.
  67640. * Note: This is note affecting PBR materials.
  67641. */
  67642. specular: Color3;
  67643. /**
  67644. * Defines the falloff type for this light. This lets overrriding how punctual light are
  67645. * falling off base on range or angle.
  67646. * This can be set to any values in Light.FALLOFF_x.
  67647. *
  67648. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  67649. * other types of materials.
  67650. */
  67651. falloffType: number;
  67652. /**
  67653. * Strength of the light.
  67654. * Note: By default it is define in the framework own unit.
  67655. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  67656. */
  67657. intensity: number;
  67658. private _range;
  67659. protected _inverseSquaredRange: number;
  67660. /**
  67661. * Defines how far from the source the light is impacting in scene units.
  67662. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  67663. */
  67664. /**
  67665. * Defines how far from the source the light is impacting in scene units.
  67666. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  67667. */
  67668. range: number;
  67669. /**
  67670. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  67671. * of light.
  67672. */
  67673. private _photometricScale;
  67674. private _intensityMode;
  67675. /**
  67676. * Gets the photometric scale used to interpret the intensity.
  67677. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  67678. */
  67679. /**
  67680. * Sets the photometric scale used to interpret the intensity.
  67681. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  67682. */
  67683. intensityMode: number;
  67684. private _radius;
  67685. /**
  67686. * Gets the light radius used by PBR Materials to simulate soft area lights.
  67687. */
  67688. /**
  67689. * sets the light radius used by PBR Materials to simulate soft area lights.
  67690. */
  67691. radius: number;
  67692. private _renderPriority;
  67693. /**
  67694. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  67695. * exceeding the number allowed of the materials.
  67696. */
  67697. renderPriority: number;
  67698. private _shadowEnabled;
  67699. /**
  67700. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  67701. * the current shadow generator.
  67702. */
  67703. /**
  67704. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  67705. * the current shadow generator.
  67706. */
  67707. shadowEnabled: boolean;
  67708. private _includedOnlyMeshes;
  67709. /**
  67710. * Gets the only meshes impacted by this light.
  67711. */
  67712. /**
  67713. * Sets the only meshes impacted by this light.
  67714. */
  67715. includedOnlyMeshes: AbstractMesh[];
  67716. private _excludedMeshes;
  67717. /**
  67718. * Gets the meshes not impacted by this light.
  67719. */
  67720. /**
  67721. * Sets the meshes not impacted by this light.
  67722. */
  67723. excludedMeshes: AbstractMesh[];
  67724. private _excludeWithLayerMask;
  67725. /**
  67726. * Gets the layer id use to find what meshes are not impacted by the light.
  67727. * Inactive if 0
  67728. */
  67729. /**
  67730. * Sets the layer id use to find what meshes are not impacted by the light.
  67731. * Inactive if 0
  67732. */
  67733. excludeWithLayerMask: number;
  67734. private _includeOnlyWithLayerMask;
  67735. /**
  67736. * Gets the layer id use to find what meshes are impacted by the light.
  67737. * Inactive if 0
  67738. */
  67739. /**
  67740. * Sets the layer id use to find what meshes are impacted by the light.
  67741. * Inactive if 0
  67742. */
  67743. includeOnlyWithLayerMask: number;
  67744. private _lightmapMode;
  67745. /**
  67746. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  67747. */
  67748. /**
  67749. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  67750. */
  67751. lightmapMode: number;
  67752. /**
  67753. * Shadow generator associted to the light.
  67754. * @hidden Internal use only.
  67755. */
  67756. _shadowGenerator: Nullable<IShadowGenerator>;
  67757. /**
  67758. * @hidden Internal use only.
  67759. */
  67760. _excludedMeshesIds: string[];
  67761. /**
  67762. * @hidden Internal use only.
  67763. */
  67764. _includedOnlyMeshesIds: string[];
  67765. /**
  67766. * The current light unifom buffer.
  67767. * @hidden Internal use only.
  67768. */
  67769. _uniformBuffer: UniformBuffer;
  67770. /**
  67771. * Creates a Light object in the scene.
  67772. * Documentation : https://doc.babylonjs.com/babylon101/lights
  67773. * @param name The firendly name of the light
  67774. * @param scene The scene the light belongs too
  67775. */
  67776. constructor(name: string, scene: Scene);
  67777. protected abstract _buildUniformLayout(): void;
  67778. /**
  67779. * Sets the passed Effect "effect" with the Light information.
  67780. * @param effect The effect to update
  67781. * @param lightIndex The index of the light in the effect to update
  67782. * @returns The light
  67783. */
  67784. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  67785. /**
  67786. * Returns the string "Light".
  67787. * @returns the class name
  67788. */
  67789. getClassName(): string;
  67790. /** @hidden */
  67791. readonly _isLight: boolean;
  67792. /**
  67793. * Converts the light information to a readable string for debug purpose.
  67794. * @param fullDetails Supports for multiple levels of logging within scene loading
  67795. * @returns the human readable light info
  67796. */
  67797. toString(fullDetails?: boolean): string;
  67798. /** @hidden */
  67799. protected _syncParentEnabledState(): void;
  67800. /**
  67801. * Set the enabled state of this node.
  67802. * @param value - the new enabled state
  67803. */
  67804. setEnabled(value: boolean): void;
  67805. /**
  67806. * Returns the Light associated shadow generator if any.
  67807. * @return the associated shadow generator.
  67808. */
  67809. getShadowGenerator(): Nullable<IShadowGenerator>;
  67810. /**
  67811. * Returns a Vector3, the absolute light position in the World.
  67812. * @returns the world space position of the light
  67813. */
  67814. getAbsolutePosition(): Vector3;
  67815. /**
  67816. * Specifies if the light will affect the passed mesh.
  67817. * @param mesh The mesh to test against the light
  67818. * @return true the mesh is affected otherwise, false.
  67819. */
  67820. canAffectMesh(mesh: AbstractMesh): boolean;
  67821. /**
  67822. * Sort function to order lights for rendering.
  67823. * @param a First Light object to compare to second.
  67824. * @param b Second Light object to compare first.
  67825. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  67826. */
  67827. static CompareLightsPriority(a: Light, b: Light): number;
  67828. /**
  67829. * Releases resources associated with this node.
  67830. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  67831. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  67832. */
  67833. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  67834. /**
  67835. * Returns the light type ID (integer).
  67836. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  67837. */
  67838. getTypeID(): number;
  67839. /**
  67840. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  67841. * @returns the scaled intensity in intensity mode unit
  67842. */
  67843. getScaledIntensity(): number;
  67844. /**
  67845. * Returns a new Light object, named "name", from the current one.
  67846. * @param name The name of the cloned light
  67847. * @returns the new created light
  67848. */
  67849. clone(name: string): Nullable<Light>;
  67850. /**
  67851. * Serializes the current light into a Serialization object.
  67852. * @returns the serialized object.
  67853. */
  67854. serialize(): any;
  67855. /**
  67856. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  67857. * This new light is named "name" and added to the passed scene.
  67858. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  67859. * @param name The friendly name of the light
  67860. * @param scene The scene the new light will belong to
  67861. * @returns the constructor function
  67862. */
  67863. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  67864. /**
  67865. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  67866. * @param parsedLight The JSON representation of the light
  67867. * @param scene The scene to create the parsed light in
  67868. * @returns the created light after parsing
  67869. */
  67870. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  67871. private _hookArrayForExcluded;
  67872. private _hookArrayForIncludedOnly;
  67873. private _resyncMeshes;
  67874. /**
  67875. * Forces the meshes to update their light related information in their rendering used effects
  67876. * @hidden Internal Use Only
  67877. */
  67878. _markMeshesAsLightDirty(): void;
  67879. /**
  67880. * Recomputes the cached photometric scale if needed.
  67881. */
  67882. private _computePhotometricScale;
  67883. /**
  67884. * Returns the Photometric Scale according to the light type and intensity mode.
  67885. */
  67886. private _getPhotometricScale;
  67887. /**
  67888. * Reorder the light in the scene according to their defined priority.
  67889. * @hidden Internal Use Only
  67890. */
  67891. _reorderLightsInScene(): void;
  67892. /**
  67893. * Prepares the list of defines specific to the light type.
  67894. * @param defines the list of defines
  67895. * @param lightIndex defines the index of the light for the effect
  67896. */
  67897. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  67898. }
  67899. }
  67900. declare module BABYLON {
  67901. /**
  67902. * Interface used to define Action
  67903. */
  67904. export interface IAction {
  67905. /**
  67906. * Trigger for the action
  67907. */
  67908. trigger: number;
  67909. /** Options of the trigger */
  67910. triggerOptions: any;
  67911. /**
  67912. * Gets the trigger parameters
  67913. * @returns the trigger parameters
  67914. */
  67915. getTriggerParameter(): any;
  67916. /**
  67917. * Internal only - executes current action event
  67918. * @hidden
  67919. */
  67920. _executeCurrent(evt?: ActionEvent): void;
  67921. /**
  67922. * Serialize placeholder for child classes
  67923. * @param parent of child
  67924. * @returns the serialized object
  67925. */
  67926. serialize(parent: any): any;
  67927. /**
  67928. * Internal only
  67929. * @hidden
  67930. */
  67931. _prepare(): void;
  67932. /**
  67933. * Internal only - manager for action
  67934. * @hidden
  67935. */
  67936. _actionManager: AbstractActionManager;
  67937. }
  67938. /**
  67939. * The action to be carried out following a trigger
  67940. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  67941. */
  67942. export class Action implements IAction {
  67943. /** the trigger, with or without parameters, for the action */
  67944. triggerOptions: any;
  67945. /**
  67946. * Trigger for the action
  67947. */
  67948. trigger: number;
  67949. /**
  67950. * Internal only - manager for action
  67951. * @hidden
  67952. */
  67953. _actionManager: ActionManager;
  67954. private _nextActiveAction;
  67955. private _child;
  67956. private _condition?;
  67957. private _triggerParameter;
  67958. /**
  67959. * An event triggered prior to action being executed.
  67960. */
  67961. onBeforeExecuteObservable: Observable<Action>;
  67962. /**
  67963. * Creates a new Action
  67964. * @param triggerOptions the trigger, with or without parameters, for the action
  67965. * @param condition an optional determinant of action
  67966. */
  67967. constructor(
  67968. /** the trigger, with or without parameters, for the action */
  67969. triggerOptions: any, condition?: Condition);
  67970. /**
  67971. * Internal only
  67972. * @hidden
  67973. */
  67974. _prepare(): void;
  67975. /**
  67976. * Gets the trigger parameters
  67977. * @returns the trigger parameters
  67978. */
  67979. getTriggerParameter(): any;
  67980. /**
  67981. * Internal only - executes current action event
  67982. * @hidden
  67983. */
  67984. _executeCurrent(evt?: ActionEvent): void;
  67985. /**
  67986. * Execute placeholder for child classes
  67987. * @param evt optional action event
  67988. */
  67989. execute(evt?: ActionEvent): void;
  67990. /**
  67991. * Skips to next active action
  67992. */
  67993. skipToNextActiveAction(): void;
  67994. /**
  67995. * Adds action to chain of actions, may be a DoNothingAction
  67996. * @param action defines the next action to execute
  67997. * @returns The action passed in
  67998. * @see https://www.babylonjs-playground.com/#1T30HR#0
  67999. */
  68000. then(action: Action): Action;
  68001. /**
  68002. * Internal only
  68003. * @hidden
  68004. */
  68005. _getProperty(propertyPath: string): string;
  68006. /**
  68007. * Internal only
  68008. * @hidden
  68009. */
  68010. _getEffectiveTarget(target: any, propertyPath: string): any;
  68011. /**
  68012. * Serialize placeholder for child classes
  68013. * @param parent of child
  68014. * @returns the serialized object
  68015. */
  68016. serialize(parent: any): any;
  68017. /**
  68018. * Internal only called by serialize
  68019. * @hidden
  68020. */
  68021. protected _serialize(serializedAction: any, parent?: any): any;
  68022. /**
  68023. * Internal only
  68024. * @hidden
  68025. */
  68026. static _SerializeValueAsString: (value: any) => string;
  68027. /**
  68028. * Internal only
  68029. * @hidden
  68030. */
  68031. static _GetTargetProperty: (target: Scene | Node) => {
  68032. name: string;
  68033. targetType: string;
  68034. value: string;
  68035. };
  68036. }
  68037. }
  68038. declare module BABYLON {
  68039. /**
  68040. * A Condition applied to an Action
  68041. */
  68042. export class Condition {
  68043. /**
  68044. * Internal only - manager for action
  68045. * @hidden
  68046. */
  68047. _actionManager: ActionManager;
  68048. /**
  68049. * Internal only
  68050. * @hidden
  68051. */
  68052. _evaluationId: number;
  68053. /**
  68054. * Internal only
  68055. * @hidden
  68056. */
  68057. _currentResult: boolean;
  68058. /**
  68059. * Creates a new Condition
  68060. * @param actionManager the manager of the action the condition is applied to
  68061. */
  68062. constructor(actionManager: ActionManager);
  68063. /**
  68064. * Check if the current condition is valid
  68065. * @returns a boolean
  68066. */
  68067. isValid(): boolean;
  68068. /**
  68069. * Internal only
  68070. * @hidden
  68071. */
  68072. _getProperty(propertyPath: string): string;
  68073. /**
  68074. * Internal only
  68075. * @hidden
  68076. */
  68077. _getEffectiveTarget(target: any, propertyPath: string): any;
  68078. /**
  68079. * Serialize placeholder for child classes
  68080. * @returns the serialized object
  68081. */
  68082. serialize(): any;
  68083. /**
  68084. * Internal only
  68085. * @hidden
  68086. */
  68087. protected _serialize(serializedCondition: any): any;
  68088. }
  68089. /**
  68090. * Defines specific conditional operators as extensions of Condition
  68091. */
  68092. export class ValueCondition extends Condition {
  68093. /** path to specify the property of the target the conditional operator uses */
  68094. propertyPath: string;
  68095. /** the value compared by the conditional operator against the current value of the property */
  68096. value: any;
  68097. /** the conditional operator, default ValueCondition.IsEqual */
  68098. operator: number;
  68099. /**
  68100. * Internal only
  68101. * @hidden
  68102. */
  68103. private static _IsEqual;
  68104. /**
  68105. * Internal only
  68106. * @hidden
  68107. */
  68108. private static _IsDifferent;
  68109. /**
  68110. * Internal only
  68111. * @hidden
  68112. */
  68113. private static _IsGreater;
  68114. /**
  68115. * Internal only
  68116. * @hidden
  68117. */
  68118. private static _IsLesser;
  68119. /**
  68120. * returns the number for IsEqual
  68121. */
  68122. static readonly IsEqual: number;
  68123. /**
  68124. * Returns the number for IsDifferent
  68125. */
  68126. static readonly IsDifferent: number;
  68127. /**
  68128. * Returns the number for IsGreater
  68129. */
  68130. static readonly IsGreater: number;
  68131. /**
  68132. * Returns the number for IsLesser
  68133. */
  68134. static readonly IsLesser: number;
  68135. /**
  68136. * Internal only The action manager for the condition
  68137. * @hidden
  68138. */
  68139. _actionManager: ActionManager;
  68140. /**
  68141. * Internal only
  68142. * @hidden
  68143. */
  68144. private _target;
  68145. /**
  68146. * Internal only
  68147. * @hidden
  68148. */
  68149. private _effectiveTarget;
  68150. /**
  68151. * Internal only
  68152. * @hidden
  68153. */
  68154. private _property;
  68155. /**
  68156. * Creates a new ValueCondition
  68157. * @param actionManager manager for the action the condition applies to
  68158. * @param target for the action
  68159. * @param propertyPath path to specify the property of the target the conditional operator uses
  68160. * @param value the value compared by the conditional operator against the current value of the property
  68161. * @param operator the conditional operator, default ValueCondition.IsEqual
  68162. */
  68163. constructor(actionManager: ActionManager, target: any,
  68164. /** path to specify the property of the target the conditional operator uses */
  68165. propertyPath: string,
  68166. /** the value compared by the conditional operator against the current value of the property */
  68167. value: any,
  68168. /** the conditional operator, default ValueCondition.IsEqual */
  68169. operator?: number);
  68170. /**
  68171. * Compares the given value with the property value for the specified conditional operator
  68172. * @returns the result of the comparison
  68173. */
  68174. isValid(): boolean;
  68175. /**
  68176. * Serialize the ValueCondition into a JSON compatible object
  68177. * @returns serialization object
  68178. */
  68179. serialize(): any;
  68180. /**
  68181. * Gets the name of the conditional operator for the ValueCondition
  68182. * @param operator the conditional operator
  68183. * @returns the name
  68184. */
  68185. static GetOperatorName(operator: number): string;
  68186. }
  68187. /**
  68188. * Defines a predicate condition as an extension of Condition
  68189. */
  68190. export class PredicateCondition extends Condition {
  68191. /** defines the predicate function used to validate the condition */
  68192. predicate: () => boolean;
  68193. /**
  68194. * Internal only - manager for action
  68195. * @hidden
  68196. */
  68197. _actionManager: ActionManager;
  68198. /**
  68199. * Creates a new PredicateCondition
  68200. * @param actionManager manager for the action the condition applies to
  68201. * @param predicate defines the predicate function used to validate the condition
  68202. */
  68203. constructor(actionManager: ActionManager,
  68204. /** defines the predicate function used to validate the condition */
  68205. predicate: () => boolean);
  68206. /**
  68207. * @returns the validity of the predicate condition
  68208. */
  68209. isValid(): boolean;
  68210. }
  68211. /**
  68212. * Defines a state condition as an extension of Condition
  68213. */
  68214. export class StateCondition extends Condition {
  68215. /** Value to compare with target state */
  68216. value: string;
  68217. /**
  68218. * Internal only - manager for action
  68219. * @hidden
  68220. */
  68221. _actionManager: ActionManager;
  68222. /**
  68223. * Internal only
  68224. * @hidden
  68225. */
  68226. private _target;
  68227. /**
  68228. * Creates a new StateCondition
  68229. * @param actionManager manager for the action the condition applies to
  68230. * @param target of the condition
  68231. * @param value to compare with target state
  68232. */
  68233. constructor(actionManager: ActionManager, target: any,
  68234. /** Value to compare with target state */
  68235. value: string);
  68236. /**
  68237. * Gets a boolean indicating if the current condition is met
  68238. * @returns the validity of the state
  68239. */
  68240. isValid(): boolean;
  68241. /**
  68242. * Serialize the StateCondition into a JSON compatible object
  68243. * @returns serialization object
  68244. */
  68245. serialize(): any;
  68246. }
  68247. }
  68248. declare module BABYLON {
  68249. /**
  68250. * This defines an action responsible to toggle a boolean once triggered.
  68251. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  68252. */
  68253. export class SwitchBooleanAction extends Action {
  68254. /**
  68255. * The path to the boolean property in the target object
  68256. */
  68257. propertyPath: string;
  68258. private _target;
  68259. private _effectiveTarget;
  68260. private _property;
  68261. /**
  68262. * Instantiate the action
  68263. * @param triggerOptions defines the trigger options
  68264. * @param target defines the object containing the boolean
  68265. * @param propertyPath defines the path to the boolean property in the target object
  68266. * @param condition defines the trigger related conditions
  68267. */
  68268. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  68269. /** @hidden */
  68270. _prepare(): void;
  68271. /**
  68272. * Execute the action toggle the boolean value.
  68273. */
  68274. execute(): void;
  68275. /**
  68276. * Serializes the actions and its related information.
  68277. * @param parent defines the object to serialize in
  68278. * @returns the serialized object
  68279. */
  68280. serialize(parent: any): any;
  68281. }
  68282. /**
  68283. * This defines an action responsible to set a the state field of the target
  68284. * to a desired value once triggered.
  68285. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  68286. */
  68287. export class SetStateAction extends Action {
  68288. /**
  68289. * The value to store in the state field.
  68290. */
  68291. value: string;
  68292. private _target;
  68293. /**
  68294. * Instantiate the action
  68295. * @param triggerOptions defines the trigger options
  68296. * @param target defines the object containing the state property
  68297. * @param value defines the value to store in the state field
  68298. * @param condition defines the trigger related conditions
  68299. */
  68300. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  68301. /**
  68302. * Execute the action and store the value on the target state property.
  68303. */
  68304. execute(): void;
  68305. /**
  68306. * Serializes the actions and its related information.
  68307. * @param parent defines the object to serialize in
  68308. * @returns the serialized object
  68309. */
  68310. serialize(parent: any): any;
  68311. }
  68312. /**
  68313. * This defines an action responsible to set a property of the target
  68314. * to a desired value once triggered.
  68315. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  68316. */
  68317. export class SetValueAction extends Action {
  68318. /**
  68319. * The path of the property to set in the target.
  68320. */
  68321. propertyPath: string;
  68322. /**
  68323. * The value to set in the property
  68324. */
  68325. value: any;
  68326. private _target;
  68327. private _effectiveTarget;
  68328. private _property;
  68329. /**
  68330. * Instantiate the action
  68331. * @param triggerOptions defines the trigger options
  68332. * @param target defines the object containing the property
  68333. * @param propertyPath defines the path of the property to set in the target
  68334. * @param value defines the value to set in the property
  68335. * @param condition defines the trigger related conditions
  68336. */
  68337. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  68338. /** @hidden */
  68339. _prepare(): void;
  68340. /**
  68341. * Execute the action and set the targetted property to the desired value.
  68342. */
  68343. execute(): void;
  68344. /**
  68345. * Serializes the actions and its related information.
  68346. * @param parent defines the object to serialize in
  68347. * @returns the serialized object
  68348. */
  68349. serialize(parent: any): any;
  68350. }
  68351. /**
  68352. * This defines an action responsible to increment the target value
  68353. * to a desired value once triggered.
  68354. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  68355. */
  68356. export class IncrementValueAction extends Action {
  68357. /**
  68358. * The path of the property to increment in the target.
  68359. */
  68360. propertyPath: string;
  68361. /**
  68362. * The value we should increment the property by.
  68363. */
  68364. value: any;
  68365. private _target;
  68366. private _effectiveTarget;
  68367. private _property;
  68368. /**
  68369. * Instantiate the action
  68370. * @param triggerOptions defines the trigger options
  68371. * @param target defines the object containing the property
  68372. * @param propertyPath defines the path of the property to increment in the target
  68373. * @param value defines the value value we should increment the property by
  68374. * @param condition defines the trigger related conditions
  68375. */
  68376. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  68377. /** @hidden */
  68378. _prepare(): void;
  68379. /**
  68380. * Execute the action and increment the target of the value amount.
  68381. */
  68382. execute(): void;
  68383. /**
  68384. * Serializes the actions and its related information.
  68385. * @param parent defines the object to serialize in
  68386. * @returns the serialized object
  68387. */
  68388. serialize(parent: any): any;
  68389. }
  68390. /**
  68391. * This defines an action responsible to start an animation once triggered.
  68392. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  68393. */
  68394. export class PlayAnimationAction extends Action {
  68395. /**
  68396. * Where the animation should start (animation frame)
  68397. */
  68398. from: number;
  68399. /**
  68400. * Where the animation should stop (animation frame)
  68401. */
  68402. to: number;
  68403. /**
  68404. * Define if the animation should loop or stop after the first play.
  68405. */
  68406. loop?: boolean;
  68407. private _target;
  68408. /**
  68409. * Instantiate the action
  68410. * @param triggerOptions defines the trigger options
  68411. * @param target defines the target animation or animation name
  68412. * @param from defines from where the animation should start (animation frame)
  68413. * @param end defines where the animation should stop (animation frame)
  68414. * @param loop defines if the animation should loop or stop after the first play
  68415. * @param condition defines the trigger related conditions
  68416. */
  68417. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  68418. /** @hidden */
  68419. _prepare(): void;
  68420. /**
  68421. * Execute the action and play the animation.
  68422. */
  68423. execute(): void;
  68424. /**
  68425. * Serializes the actions and its related information.
  68426. * @param parent defines the object to serialize in
  68427. * @returns the serialized object
  68428. */
  68429. serialize(parent: any): any;
  68430. }
  68431. /**
  68432. * This defines an action responsible to stop an animation once triggered.
  68433. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  68434. */
  68435. export class StopAnimationAction extends Action {
  68436. private _target;
  68437. /**
  68438. * Instantiate the action
  68439. * @param triggerOptions defines the trigger options
  68440. * @param target defines the target animation or animation name
  68441. * @param condition defines the trigger related conditions
  68442. */
  68443. constructor(triggerOptions: any, target: any, condition?: Condition);
  68444. /** @hidden */
  68445. _prepare(): void;
  68446. /**
  68447. * Execute the action and stop the animation.
  68448. */
  68449. execute(): void;
  68450. /**
  68451. * Serializes the actions and its related information.
  68452. * @param parent defines the object to serialize in
  68453. * @returns the serialized object
  68454. */
  68455. serialize(parent: any): any;
  68456. }
  68457. /**
  68458. * This defines an action responsible that does nothing once triggered.
  68459. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  68460. */
  68461. export class DoNothingAction extends Action {
  68462. /**
  68463. * Instantiate the action
  68464. * @param triggerOptions defines the trigger options
  68465. * @param condition defines the trigger related conditions
  68466. */
  68467. constructor(triggerOptions?: any, condition?: Condition);
  68468. /**
  68469. * Execute the action and do nothing.
  68470. */
  68471. execute(): void;
  68472. /**
  68473. * Serializes the actions and its related information.
  68474. * @param parent defines the object to serialize in
  68475. * @returns the serialized object
  68476. */
  68477. serialize(parent: any): any;
  68478. }
  68479. /**
  68480. * This defines an action responsible to trigger several actions once triggered.
  68481. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  68482. */
  68483. export class CombineAction extends Action {
  68484. /**
  68485. * The list of aggregated animations to run.
  68486. */
  68487. children: Action[];
  68488. /**
  68489. * Instantiate the action
  68490. * @param triggerOptions defines the trigger options
  68491. * @param children defines the list of aggregated animations to run
  68492. * @param condition defines the trigger related conditions
  68493. */
  68494. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  68495. /** @hidden */
  68496. _prepare(): void;
  68497. /**
  68498. * Execute the action and executes all the aggregated actions.
  68499. */
  68500. execute(evt: ActionEvent): void;
  68501. /**
  68502. * Serializes the actions and its related information.
  68503. * @param parent defines the object to serialize in
  68504. * @returns the serialized object
  68505. */
  68506. serialize(parent: any): any;
  68507. }
  68508. /**
  68509. * This defines an action responsible to run code (external event) once triggered.
  68510. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  68511. */
  68512. export class ExecuteCodeAction extends Action {
  68513. /**
  68514. * The callback function to run.
  68515. */
  68516. func: (evt: ActionEvent) => void;
  68517. /**
  68518. * Instantiate the action
  68519. * @param triggerOptions defines the trigger options
  68520. * @param func defines the callback function to run
  68521. * @param condition defines the trigger related conditions
  68522. */
  68523. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  68524. /**
  68525. * Execute the action and run the attached code.
  68526. */
  68527. execute(evt: ActionEvent): void;
  68528. }
  68529. /**
  68530. * This defines an action responsible to set the parent property of the target once triggered.
  68531. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  68532. */
  68533. export class SetParentAction extends Action {
  68534. private _parent;
  68535. private _target;
  68536. /**
  68537. * Instantiate the action
  68538. * @param triggerOptions defines the trigger options
  68539. * @param target defines the target containing the parent property
  68540. * @param parent defines from where the animation should start (animation frame)
  68541. * @param condition defines the trigger related conditions
  68542. */
  68543. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  68544. /** @hidden */
  68545. _prepare(): void;
  68546. /**
  68547. * Execute the action and set the parent property.
  68548. */
  68549. execute(): void;
  68550. /**
  68551. * Serializes the actions and its related information.
  68552. * @param parent defines the object to serialize in
  68553. * @returns the serialized object
  68554. */
  68555. serialize(parent: any): any;
  68556. }
  68557. }
  68558. declare module BABYLON {
  68559. /**
  68560. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  68561. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  68562. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  68563. */
  68564. export class ActionManager extends AbstractActionManager {
  68565. /**
  68566. * Nothing
  68567. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68568. */
  68569. static readonly NothingTrigger: number;
  68570. /**
  68571. * On pick
  68572. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68573. */
  68574. static readonly OnPickTrigger: number;
  68575. /**
  68576. * On left pick
  68577. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68578. */
  68579. static readonly OnLeftPickTrigger: number;
  68580. /**
  68581. * On right pick
  68582. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68583. */
  68584. static readonly OnRightPickTrigger: number;
  68585. /**
  68586. * On center pick
  68587. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68588. */
  68589. static readonly OnCenterPickTrigger: number;
  68590. /**
  68591. * On pick down
  68592. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68593. */
  68594. static readonly OnPickDownTrigger: number;
  68595. /**
  68596. * On double pick
  68597. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68598. */
  68599. static readonly OnDoublePickTrigger: number;
  68600. /**
  68601. * On pick up
  68602. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68603. */
  68604. static readonly OnPickUpTrigger: number;
  68605. /**
  68606. * On pick out.
  68607. * This trigger will only be raised if you also declared a OnPickDown
  68608. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68609. */
  68610. static readonly OnPickOutTrigger: number;
  68611. /**
  68612. * On long press
  68613. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68614. */
  68615. static readonly OnLongPressTrigger: number;
  68616. /**
  68617. * On pointer over
  68618. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68619. */
  68620. static readonly OnPointerOverTrigger: number;
  68621. /**
  68622. * On pointer out
  68623. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68624. */
  68625. static readonly OnPointerOutTrigger: number;
  68626. /**
  68627. * On every frame
  68628. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68629. */
  68630. static readonly OnEveryFrameTrigger: number;
  68631. /**
  68632. * On intersection enter
  68633. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68634. */
  68635. static readonly OnIntersectionEnterTrigger: number;
  68636. /**
  68637. * On intersection exit
  68638. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68639. */
  68640. static readonly OnIntersectionExitTrigger: number;
  68641. /**
  68642. * On key down
  68643. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68644. */
  68645. static readonly OnKeyDownTrigger: number;
  68646. /**
  68647. * On key up
  68648. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68649. */
  68650. static readonly OnKeyUpTrigger: number;
  68651. private _scene;
  68652. /**
  68653. * Creates a new action manager
  68654. * @param scene defines the hosting scene
  68655. */
  68656. constructor(scene: Scene);
  68657. /**
  68658. * Releases all associated resources
  68659. */
  68660. dispose(): void;
  68661. /**
  68662. * Gets hosting scene
  68663. * @returns the hosting scene
  68664. */
  68665. getScene(): Scene;
  68666. /**
  68667. * Does this action manager handles actions of any of the given triggers
  68668. * @param triggers defines the triggers to be tested
  68669. * @return a boolean indicating whether one (or more) of the triggers is handled
  68670. */
  68671. hasSpecificTriggers(triggers: number[]): boolean;
  68672. /**
  68673. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  68674. * speed.
  68675. * @param triggerA defines the trigger to be tested
  68676. * @param triggerB defines the trigger to be tested
  68677. * @return a boolean indicating whether one (or more) of the triggers is handled
  68678. */
  68679. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  68680. /**
  68681. * Does this action manager handles actions of a given trigger
  68682. * @param trigger defines the trigger to be tested
  68683. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  68684. * @return whether the trigger is handled
  68685. */
  68686. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  68687. /**
  68688. * Does this action manager has pointer triggers
  68689. */
  68690. readonly hasPointerTriggers: boolean;
  68691. /**
  68692. * Does this action manager has pick triggers
  68693. */
  68694. readonly hasPickTriggers: boolean;
  68695. /**
  68696. * Registers an action to this action manager
  68697. * @param action defines the action to be registered
  68698. * @return the action amended (prepared) after registration
  68699. */
  68700. registerAction(action: IAction): Nullable<IAction>;
  68701. /**
  68702. * Unregisters an action to this action manager
  68703. * @param action defines the action to be unregistered
  68704. * @return a boolean indicating whether the action has been unregistered
  68705. */
  68706. unregisterAction(action: IAction): Boolean;
  68707. /**
  68708. * Process a specific trigger
  68709. * @param trigger defines the trigger to process
  68710. * @param evt defines the event details to be processed
  68711. */
  68712. processTrigger(trigger: number, evt?: IActionEvent): void;
  68713. /** @hidden */
  68714. _getEffectiveTarget(target: any, propertyPath: string): any;
  68715. /** @hidden */
  68716. _getProperty(propertyPath: string): string;
  68717. /**
  68718. * Serialize this manager to a JSON object
  68719. * @param name defines the property name to store this manager
  68720. * @returns a JSON representation of this manager
  68721. */
  68722. serialize(name: string): any;
  68723. /**
  68724. * Creates a new ActionManager from a JSON data
  68725. * @param parsedActions defines the JSON data to read from
  68726. * @param object defines the hosting mesh
  68727. * @param scene defines the hosting scene
  68728. */
  68729. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  68730. /**
  68731. * Get a trigger name by index
  68732. * @param trigger defines the trigger index
  68733. * @returns a trigger name
  68734. */
  68735. static GetTriggerName(trigger: number): string;
  68736. }
  68737. }
  68738. declare module BABYLON {
  68739. /**
  68740. * Class representing a ray with position and direction
  68741. */
  68742. export class Ray {
  68743. /** origin point */
  68744. origin: Vector3;
  68745. /** direction */
  68746. direction: Vector3;
  68747. /** length of the ray */
  68748. length: number;
  68749. private static readonly TmpVector3;
  68750. private _tmpRay;
  68751. /**
  68752. * Creates a new ray
  68753. * @param origin origin point
  68754. * @param direction direction
  68755. * @param length length of the ray
  68756. */
  68757. constructor(
  68758. /** origin point */
  68759. origin: Vector3,
  68760. /** direction */
  68761. direction: Vector3,
  68762. /** length of the ray */
  68763. length?: number);
  68764. /**
  68765. * Checks if the ray intersects a box
  68766. * @param minimum bound of the box
  68767. * @param maximum bound of the box
  68768. * @param intersectionTreshold extra extend to be added to the box in all direction
  68769. * @returns if the box was hit
  68770. */
  68771. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  68772. /**
  68773. * Checks if the ray intersects a box
  68774. * @param box the bounding box to check
  68775. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  68776. * @returns if the box was hit
  68777. */
  68778. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  68779. /**
  68780. * If the ray hits a sphere
  68781. * @param sphere the bounding sphere to check
  68782. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  68783. * @returns true if it hits the sphere
  68784. */
  68785. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  68786. /**
  68787. * If the ray hits a triange
  68788. * @param vertex0 triangle vertex
  68789. * @param vertex1 triangle vertex
  68790. * @param vertex2 triangle vertex
  68791. * @returns intersection information if hit
  68792. */
  68793. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  68794. /**
  68795. * Checks if ray intersects a plane
  68796. * @param plane the plane to check
  68797. * @returns the distance away it was hit
  68798. */
  68799. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  68800. /**
  68801. * Checks if ray intersects a mesh
  68802. * @param mesh the mesh to check
  68803. * @param fastCheck if only the bounding box should checked
  68804. * @returns picking info of the intersecton
  68805. */
  68806. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  68807. /**
  68808. * Checks if ray intersects a mesh
  68809. * @param meshes the meshes to check
  68810. * @param fastCheck if only the bounding box should checked
  68811. * @param results array to store result in
  68812. * @returns Array of picking infos
  68813. */
  68814. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  68815. private _comparePickingInfo;
  68816. private static smallnum;
  68817. private static rayl;
  68818. /**
  68819. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  68820. * @param sega the first point of the segment to test the intersection against
  68821. * @param segb the second point of the segment to test the intersection against
  68822. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  68823. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  68824. */
  68825. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  68826. /**
  68827. * Update the ray from viewport position
  68828. * @param x position
  68829. * @param y y position
  68830. * @param viewportWidth viewport width
  68831. * @param viewportHeight viewport height
  68832. * @param world world matrix
  68833. * @param view view matrix
  68834. * @param projection projection matrix
  68835. * @returns this ray updated
  68836. */
  68837. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  68838. /**
  68839. * Creates a ray with origin and direction of 0,0,0
  68840. * @returns the new ray
  68841. */
  68842. static Zero(): Ray;
  68843. /**
  68844. * Creates a new ray from screen space and viewport
  68845. * @param x position
  68846. * @param y y position
  68847. * @param viewportWidth viewport width
  68848. * @param viewportHeight viewport height
  68849. * @param world world matrix
  68850. * @param view view matrix
  68851. * @param projection projection matrix
  68852. * @returns new ray
  68853. */
  68854. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  68855. /**
  68856. * 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
  68857. * transformed to the given world matrix.
  68858. * @param origin The origin point
  68859. * @param end The end point
  68860. * @param world a matrix to transform the ray to. Default is the identity matrix.
  68861. * @returns the new ray
  68862. */
  68863. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  68864. /**
  68865. * Transforms a ray by a matrix
  68866. * @param ray ray to transform
  68867. * @param matrix matrix to apply
  68868. * @returns the resulting new ray
  68869. */
  68870. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  68871. /**
  68872. * Transforms a ray by a matrix
  68873. * @param ray ray to transform
  68874. * @param matrix matrix to apply
  68875. * @param result ray to store result in
  68876. */
  68877. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  68878. /**
  68879. * Unproject a ray from screen space to object space
  68880. * @param sourceX defines the screen space x coordinate to use
  68881. * @param sourceY defines the screen space y coordinate to use
  68882. * @param viewportWidth defines the current width of the viewport
  68883. * @param viewportHeight defines the current height of the viewport
  68884. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  68885. * @param view defines the view matrix to use
  68886. * @param projection defines the projection matrix to use
  68887. */
  68888. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  68889. }
  68890. /**
  68891. * Type used to define predicate used to select faces when a mesh intersection is detected
  68892. */
  68893. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  68894. interface Scene {
  68895. /** @hidden */
  68896. _tempPickingRay: Nullable<Ray>;
  68897. /** @hidden */
  68898. _cachedRayForTransform: Ray;
  68899. /** @hidden */
  68900. _pickWithRayInverseMatrix: Matrix;
  68901. /** @hidden */
  68902. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  68903. /** @hidden */
  68904. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  68905. }
  68906. }
  68907. declare module BABYLON {
  68908. /**
  68909. * Groups all the scene component constants in one place to ease maintenance.
  68910. * @hidden
  68911. */
  68912. export class SceneComponentConstants {
  68913. static readonly NAME_EFFECTLAYER: string;
  68914. static readonly NAME_LAYER: string;
  68915. static readonly NAME_LENSFLARESYSTEM: string;
  68916. static readonly NAME_BOUNDINGBOXRENDERER: string;
  68917. static readonly NAME_PARTICLESYSTEM: string;
  68918. static readonly NAME_GAMEPAD: string;
  68919. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  68920. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  68921. static readonly NAME_DEPTHRENDERER: string;
  68922. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  68923. static readonly NAME_SPRITE: string;
  68924. static readonly NAME_OUTLINERENDERER: string;
  68925. static readonly NAME_PROCEDURALTEXTURE: string;
  68926. static readonly NAME_SHADOWGENERATOR: string;
  68927. static readonly NAME_OCTREE: string;
  68928. static readonly NAME_PHYSICSENGINE: string;
  68929. static readonly NAME_AUDIO: string;
  68930. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  68931. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  68932. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  68933. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  68934. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  68935. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  68936. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  68937. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  68938. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  68939. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  68940. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  68941. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  68942. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  68943. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  68944. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  68945. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  68946. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  68947. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  68948. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  68949. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  68950. static readonly STEP_AFTERRENDER_AUDIO: number;
  68951. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  68952. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  68953. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  68954. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  68955. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  68956. static readonly STEP_POINTERMOVE_SPRITE: number;
  68957. static readonly STEP_POINTERDOWN_SPRITE: number;
  68958. static readonly STEP_POINTERUP_SPRITE: number;
  68959. }
  68960. /**
  68961. * This represents a scene component.
  68962. *
  68963. * This is used to decouple the dependency the scene is having on the different workloads like
  68964. * layers, post processes...
  68965. */
  68966. export interface ISceneComponent {
  68967. /**
  68968. * The name of the component. Each component must have a unique name.
  68969. */
  68970. name: string;
  68971. /**
  68972. * The scene the component belongs to.
  68973. */
  68974. scene: Scene;
  68975. /**
  68976. * Register the component to one instance of a scene.
  68977. */
  68978. register(): void;
  68979. /**
  68980. * Rebuilds the elements related to this component in case of
  68981. * context lost for instance.
  68982. */
  68983. rebuild(): void;
  68984. /**
  68985. * Disposes the component and the associated ressources.
  68986. */
  68987. dispose(): void;
  68988. }
  68989. /**
  68990. * This represents a SERIALIZABLE scene component.
  68991. *
  68992. * This extends Scene Component to add Serialization methods on top.
  68993. */
  68994. export interface ISceneSerializableComponent extends ISceneComponent {
  68995. /**
  68996. * Adds all the element from the container to the scene
  68997. * @param container the container holding the elements
  68998. */
  68999. addFromContainer(container: AbstractScene): void;
  69000. /**
  69001. * Removes all the elements in the container from the scene
  69002. * @param container contains the elements to remove
  69003. */
  69004. removeFromContainer(container: AbstractScene): void;
  69005. /**
  69006. * Serializes the component data to the specified json object
  69007. * @param serializationObject The object to serialize to
  69008. */
  69009. serialize(serializationObject: any): void;
  69010. }
  69011. /**
  69012. * Strong typing of a Mesh related stage step action
  69013. */
  69014. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  69015. /**
  69016. * Strong typing of a Evaluate Sub Mesh related stage step action
  69017. */
  69018. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  69019. /**
  69020. * Strong typing of a Active Mesh related stage step action
  69021. */
  69022. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  69023. /**
  69024. * Strong typing of a Camera related stage step action
  69025. */
  69026. export type CameraStageAction = (camera: Camera) => void;
  69027. /**
  69028. * Strong typing of a Render Target related stage step action
  69029. */
  69030. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  69031. /**
  69032. * Strong typing of a RenderingGroup related stage step action
  69033. */
  69034. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  69035. /**
  69036. * Strong typing of a Mesh Render related stage step action
  69037. */
  69038. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  69039. /**
  69040. * Strong typing of a simple stage step action
  69041. */
  69042. export type SimpleStageAction = () => void;
  69043. /**
  69044. * Strong typing of a render target action.
  69045. */
  69046. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  69047. /**
  69048. * Strong typing of a pointer move action.
  69049. */
  69050. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  69051. /**
  69052. * Strong typing of a pointer up/down action.
  69053. */
  69054. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  69055. /**
  69056. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  69057. * @hidden
  69058. */
  69059. export class Stage<T extends Function> extends Array<{
  69060. index: number;
  69061. component: ISceneComponent;
  69062. action: T;
  69063. }> {
  69064. /**
  69065. * Hide ctor from the rest of the world.
  69066. * @param items The items to add.
  69067. */
  69068. private constructor();
  69069. /**
  69070. * Creates a new Stage.
  69071. * @returns A new instance of a Stage
  69072. */
  69073. static Create<T extends Function>(): Stage<T>;
  69074. /**
  69075. * Registers a step in an ordered way in the targeted stage.
  69076. * @param index Defines the position to register the step in
  69077. * @param component Defines the component attached to the step
  69078. * @param action Defines the action to launch during the step
  69079. */
  69080. registerStep(index: number, component: ISceneComponent, action: T): void;
  69081. /**
  69082. * Clears all the steps from the stage.
  69083. */
  69084. clear(): void;
  69085. }
  69086. }
  69087. declare module BABYLON {
  69088. interface Scene {
  69089. /** @hidden */
  69090. _pointerOverSprite: Nullable<Sprite>;
  69091. /** @hidden */
  69092. _pickedDownSprite: Nullable<Sprite>;
  69093. /** @hidden */
  69094. _tempSpritePickingRay: Nullable<Ray>;
  69095. /**
  69096. * All of the sprite managers added to this scene
  69097. * @see http://doc.babylonjs.com/babylon101/sprites
  69098. */
  69099. spriteManagers: Array<ISpriteManager>;
  69100. /**
  69101. * An event triggered when sprites rendering is about to start
  69102. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  69103. */
  69104. onBeforeSpritesRenderingObservable: Observable<Scene>;
  69105. /**
  69106. * An event triggered when sprites rendering is done
  69107. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  69108. */
  69109. onAfterSpritesRenderingObservable: Observable<Scene>;
  69110. /** @hidden */
  69111. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  69112. /** Launch a ray to try to pick a sprite in the scene
  69113. * @param x position on screen
  69114. * @param y position on screen
  69115. * @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
  69116. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  69117. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  69118. * @returns a PickingInfo
  69119. */
  69120. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  69121. /** Use the given ray to pick a sprite in the scene
  69122. * @param ray The ray (in world space) to use to pick meshes
  69123. * @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
  69124. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  69125. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  69126. * @returns a PickingInfo
  69127. */
  69128. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  69129. /**
  69130. * Force the sprite under the pointer
  69131. * @param sprite defines the sprite to use
  69132. */
  69133. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  69134. /**
  69135. * Gets the sprite under the pointer
  69136. * @returns a Sprite or null if no sprite is under the pointer
  69137. */
  69138. getPointerOverSprite(): Nullable<Sprite>;
  69139. }
  69140. /**
  69141. * Defines the sprite scene component responsible to manage sprites
  69142. * in a given scene.
  69143. */
  69144. export class SpriteSceneComponent implements ISceneComponent {
  69145. /**
  69146. * The component name helpfull to identify the component in the list of scene components.
  69147. */
  69148. readonly name: string;
  69149. /**
  69150. * The scene the component belongs to.
  69151. */
  69152. scene: Scene;
  69153. /** @hidden */
  69154. private _spritePredicate;
  69155. /**
  69156. * Creates a new instance of the component for the given scene
  69157. * @param scene Defines the scene to register the component in
  69158. */
  69159. constructor(scene: Scene);
  69160. /**
  69161. * Registers the component in a given scene
  69162. */
  69163. register(): void;
  69164. /**
  69165. * Rebuilds the elements related to this component in case of
  69166. * context lost for instance.
  69167. */
  69168. rebuild(): void;
  69169. /**
  69170. * Disposes the component and the associated ressources.
  69171. */
  69172. dispose(): void;
  69173. private _pickSpriteButKeepRay;
  69174. private _pointerMove;
  69175. private _pointerDown;
  69176. private _pointerUp;
  69177. }
  69178. }
  69179. declare module BABYLON {
  69180. /** @hidden */
  69181. export var fogFragmentDeclaration: {
  69182. name: string;
  69183. shader: string;
  69184. };
  69185. }
  69186. declare module BABYLON {
  69187. /** @hidden */
  69188. export var fogFragment: {
  69189. name: string;
  69190. shader: string;
  69191. };
  69192. }
  69193. declare module BABYLON {
  69194. /** @hidden */
  69195. export var spritesPixelShader: {
  69196. name: string;
  69197. shader: string;
  69198. };
  69199. }
  69200. declare module BABYLON {
  69201. /** @hidden */
  69202. export var fogVertexDeclaration: {
  69203. name: string;
  69204. shader: string;
  69205. };
  69206. }
  69207. declare module BABYLON {
  69208. /** @hidden */
  69209. export var spritesVertexShader: {
  69210. name: string;
  69211. shader: string;
  69212. };
  69213. }
  69214. declare module BABYLON {
  69215. /**
  69216. * Defines the minimum interface to fullfil in order to be a sprite manager.
  69217. */
  69218. export interface ISpriteManager extends IDisposable {
  69219. /**
  69220. * Restricts the camera to viewing objects with the same layerMask.
  69221. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  69222. */
  69223. layerMask: number;
  69224. /**
  69225. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  69226. */
  69227. isPickable: boolean;
  69228. /**
  69229. * Specifies the rendering group id for this mesh (0 by default)
  69230. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  69231. */
  69232. renderingGroupId: number;
  69233. /**
  69234. * Defines the list of sprites managed by the manager.
  69235. */
  69236. sprites: Array<Sprite>;
  69237. /**
  69238. * Tests the intersection of a sprite with a specific ray.
  69239. * @param ray The ray we are sending to test the collision
  69240. * @param camera The camera space we are sending rays in
  69241. * @param predicate A predicate allowing excluding sprites from the list of object to test
  69242. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  69243. * @returns picking info or null.
  69244. */
  69245. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  69246. /**
  69247. * Renders the list of sprites on screen.
  69248. */
  69249. render(): void;
  69250. }
  69251. /**
  69252. * Class used to manage multiple sprites on the same spritesheet
  69253. * @see http://doc.babylonjs.com/babylon101/sprites
  69254. */
  69255. export class SpriteManager implements ISpriteManager {
  69256. /** defines the manager's name */
  69257. name: string;
  69258. /** Gets the list of sprites */
  69259. sprites: Sprite[];
  69260. /** Gets or sets the rendering group id (0 by default) */
  69261. renderingGroupId: number;
  69262. /** Gets or sets camera layer mask */
  69263. layerMask: number;
  69264. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  69265. fogEnabled: boolean;
  69266. /** Gets or sets a boolean indicating if the sprites are pickable */
  69267. isPickable: boolean;
  69268. /** Defines the default width of a cell in the spritesheet */
  69269. cellWidth: number;
  69270. /** Defines the default height of a cell in the spritesheet */
  69271. cellHeight: number;
  69272. /**
  69273. * An event triggered when the manager is disposed.
  69274. */
  69275. onDisposeObservable: Observable<SpriteManager>;
  69276. private _onDisposeObserver;
  69277. /**
  69278. * Callback called when the manager is disposed
  69279. */
  69280. onDispose: () => void;
  69281. private _capacity;
  69282. private _spriteTexture;
  69283. private _epsilon;
  69284. private _scene;
  69285. private _vertexData;
  69286. private _buffer;
  69287. private _vertexBuffers;
  69288. private _indexBuffer;
  69289. private _effectBase;
  69290. private _effectFog;
  69291. /**
  69292. * Gets or sets the spritesheet texture
  69293. */
  69294. texture: Texture;
  69295. /**
  69296. * Creates a new sprite manager
  69297. * @param name defines the manager's name
  69298. * @param imgUrl defines the sprite sheet url
  69299. * @param capacity defines the maximum allowed number of sprites
  69300. * @param cellSize defines the size of a sprite cell
  69301. * @param scene defines the hosting scene
  69302. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  69303. * @param samplingMode defines the smapling mode to use with spritesheet
  69304. */
  69305. constructor(
  69306. /** defines the manager's name */
  69307. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  69308. private _appendSpriteVertex;
  69309. /**
  69310. * Intersects the sprites with a ray
  69311. * @param ray defines the ray to intersect with
  69312. * @param camera defines the current active camera
  69313. * @param predicate defines a predicate used to select candidate sprites
  69314. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  69315. * @returns null if no hit or a PickingInfo
  69316. */
  69317. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  69318. /**
  69319. * Render all child sprites
  69320. */
  69321. render(): void;
  69322. /**
  69323. * Release associated resources
  69324. */
  69325. dispose(): void;
  69326. }
  69327. }
  69328. declare module BABYLON {
  69329. /**
  69330. * Class used to represent a sprite
  69331. * @see http://doc.babylonjs.com/babylon101/sprites
  69332. */
  69333. export class Sprite {
  69334. /** defines the name */
  69335. name: string;
  69336. /** Gets or sets the current world position */
  69337. position: Vector3;
  69338. /** Gets or sets the main color */
  69339. color: Color4;
  69340. /** Gets or sets the width */
  69341. width: number;
  69342. /** Gets or sets the height */
  69343. height: number;
  69344. /** Gets or sets rotation angle */
  69345. angle: number;
  69346. /** Gets or sets the cell index in the sprite sheet */
  69347. cellIndex: number;
  69348. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  69349. invertU: number;
  69350. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  69351. invertV: number;
  69352. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  69353. disposeWhenFinishedAnimating: boolean;
  69354. /** Gets the list of attached animations */
  69355. animations: Animation[];
  69356. /** Gets or sets a boolean indicating if the sprite can be picked */
  69357. isPickable: boolean;
  69358. /**
  69359. * Gets or sets the associated action manager
  69360. */
  69361. actionManager: Nullable<ActionManager>;
  69362. private _animationStarted;
  69363. private _loopAnimation;
  69364. private _fromIndex;
  69365. private _toIndex;
  69366. private _delay;
  69367. private _direction;
  69368. private _manager;
  69369. private _time;
  69370. private _onAnimationEnd;
  69371. /**
  69372. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  69373. */
  69374. isVisible: boolean;
  69375. /**
  69376. * Gets or sets the sprite size
  69377. */
  69378. size: number;
  69379. /**
  69380. * Creates a new Sprite
  69381. * @param name defines the name
  69382. * @param manager defines the manager
  69383. */
  69384. constructor(
  69385. /** defines the name */
  69386. name: string, manager: ISpriteManager);
  69387. /**
  69388. * Starts an animation
  69389. * @param from defines the initial key
  69390. * @param to defines the end key
  69391. * @param loop defines if the animation must loop
  69392. * @param delay defines the start delay (in ms)
  69393. * @param onAnimationEnd defines a callback to call when animation ends
  69394. */
  69395. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  69396. /** Stops current animation (if any) */
  69397. stopAnimation(): void;
  69398. /** @hidden */
  69399. _animate(deltaTime: number): void;
  69400. /** Release associated resources */
  69401. dispose(): void;
  69402. }
  69403. }
  69404. declare module BABYLON {
  69405. /**
  69406. * Information about the result of picking within a scene
  69407. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  69408. */
  69409. export class PickingInfo {
  69410. /** @hidden */
  69411. _pickingUnavailable: boolean;
  69412. /**
  69413. * If the pick collided with an object
  69414. */
  69415. hit: boolean;
  69416. /**
  69417. * Distance away where the pick collided
  69418. */
  69419. distance: number;
  69420. /**
  69421. * The location of pick collision
  69422. */
  69423. pickedPoint: Nullable<Vector3>;
  69424. /**
  69425. * The mesh corresponding the the pick collision
  69426. */
  69427. pickedMesh: Nullable<AbstractMesh>;
  69428. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  69429. bu: number;
  69430. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  69431. bv: number;
  69432. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  69433. faceId: number;
  69434. /** Id of the the submesh that was picked */
  69435. subMeshId: number;
  69436. /** If a sprite was picked, this will be the sprite the pick collided with */
  69437. pickedSprite: Nullable<Sprite>;
  69438. /**
  69439. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  69440. */
  69441. originMesh: Nullable<AbstractMesh>;
  69442. /**
  69443. * The ray that was used to perform the picking.
  69444. */
  69445. ray: Nullable<Ray>;
  69446. /**
  69447. * Gets the normal correspodning to the face the pick collided with
  69448. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  69449. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  69450. * @returns The normal correspodning to the face the pick collided with
  69451. */
  69452. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  69453. /**
  69454. * Gets the texture coordinates of where the pick occured
  69455. * @returns the vector containing the coordnates of the texture
  69456. */
  69457. getTextureCoordinates(): Nullable<Vector2>;
  69458. }
  69459. }
  69460. declare module BABYLON {
  69461. /**
  69462. * Gather the list of pointer event types as constants.
  69463. */
  69464. export class PointerEventTypes {
  69465. /**
  69466. * 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.
  69467. */
  69468. static readonly POINTERDOWN: number;
  69469. /**
  69470. * The pointerup event is fired when a pointer is no longer active.
  69471. */
  69472. static readonly POINTERUP: number;
  69473. /**
  69474. * The pointermove event is fired when a pointer changes coordinates.
  69475. */
  69476. static readonly POINTERMOVE: number;
  69477. /**
  69478. * The pointerwheel event is fired when a mouse wheel has been rotated.
  69479. */
  69480. static readonly POINTERWHEEL: number;
  69481. /**
  69482. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  69483. */
  69484. static readonly POINTERPICK: number;
  69485. /**
  69486. * The pointertap event is fired when a the object has been touched and released without drag.
  69487. */
  69488. static readonly POINTERTAP: number;
  69489. /**
  69490. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  69491. */
  69492. static readonly POINTERDOUBLETAP: number;
  69493. }
  69494. /**
  69495. * Base class of pointer info types.
  69496. */
  69497. export class PointerInfoBase {
  69498. /**
  69499. * Defines the type of event (PointerEventTypes)
  69500. */
  69501. type: number;
  69502. /**
  69503. * Defines the related dom event
  69504. */
  69505. event: PointerEvent | MouseWheelEvent;
  69506. /**
  69507. * Instantiates the base class of pointers info.
  69508. * @param type Defines the type of event (PointerEventTypes)
  69509. * @param event Defines the related dom event
  69510. */
  69511. constructor(
  69512. /**
  69513. * Defines the type of event (PointerEventTypes)
  69514. */
  69515. type: number,
  69516. /**
  69517. * Defines the related dom event
  69518. */
  69519. event: PointerEvent | MouseWheelEvent);
  69520. }
  69521. /**
  69522. * This class is used to store pointer related info for the onPrePointerObservable event.
  69523. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  69524. */
  69525. export class PointerInfoPre extends PointerInfoBase {
  69526. /**
  69527. * Ray from a pointer if availible (eg. 6dof controller)
  69528. */
  69529. ray: Nullable<Ray>;
  69530. /**
  69531. * Defines the local position of the pointer on the canvas.
  69532. */
  69533. localPosition: Vector2;
  69534. /**
  69535. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  69536. */
  69537. skipOnPointerObservable: boolean;
  69538. /**
  69539. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  69540. * @param type Defines the type of event (PointerEventTypes)
  69541. * @param event Defines the related dom event
  69542. * @param localX Defines the local x coordinates of the pointer when the event occured
  69543. * @param localY Defines the local y coordinates of the pointer when the event occured
  69544. */
  69545. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  69546. }
  69547. /**
  69548. * This type contains all the data related to a pointer event in Babylon.js.
  69549. * 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.
  69550. */
  69551. export class PointerInfo extends PointerInfoBase {
  69552. /**
  69553. * Defines the picking info associated to the info (if any)\
  69554. */
  69555. pickInfo: Nullable<PickingInfo>;
  69556. /**
  69557. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  69558. * @param type Defines the type of event (PointerEventTypes)
  69559. * @param event Defines the related dom event
  69560. * @param pickInfo Defines the picking info associated to the info (if any)\
  69561. */
  69562. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  69563. /**
  69564. * Defines the picking info associated to the info (if any)\
  69565. */
  69566. pickInfo: Nullable<PickingInfo>);
  69567. }
  69568. /**
  69569. * Data relating to a touch event on the screen.
  69570. */
  69571. export interface PointerTouch {
  69572. /**
  69573. * X coordinate of touch.
  69574. */
  69575. x: number;
  69576. /**
  69577. * Y coordinate of touch.
  69578. */
  69579. y: number;
  69580. /**
  69581. * Id of touch. Unique for each finger.
  69582. */
  69583. pointerId: number;
  69584. /**
  69585. * Event type passed from DOM.
  69586. */
  69587. type: any;
  69588. }
  69589. }
  69590. declare module BABYLON {
  69591. /**
  69592. * Manage the mouse inputs to control the movement of a free camera.
  69593. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  69594. */
  69595. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  69596. /**
  69597. * Define if touch is enabled in the mouse input
  69598. */
  69599. touchEnabled: boolean;
  69600. /**
  69601. * Defines the camera the input is attached to.
  69602. */
  69603. camera: FreeCamera;
  69604. /**
  69605. * Defines the buttons associated with the input to handle camera move.
  69606. */
  69607. buttons: number[];
  69608. /**
  69609. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  69610. */
  69611. angularSensibility: number;
  69612. private _pointerInput;
  69613. private _onMouseMove;
  69614. private _observer;
  69615. private previousPosition;
  69616. /**
  69617. * Manage the mouse inputs to control the movement of a free camera.
  69618. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  69619. * @param touchEnabled Defines if touch is enabled or not
  69620. */
  69621. constructor(
  69622. /**
  69623. * Define if touch is enabled in the mouse input
  69624. */
  69625. touchEnabled?: boolean);
  69626. /**
  69627. * Attach the input controls to a specific dom element to get the input from.
  69628. * @param element Defines the element the controls should be listened from
  69629. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  69630. */
  69631. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  69632. /**
  69633. * Called on JS contextmenu event.
  69634. * Override this method to provide functionality.
  69635. */
  69636. protected onContextMenu(evt: PointerEvent): void;
  69637. /**
  69638. * Detach the current controls from the specified dom element.
  69639. * @param element Defines the element to stop listening the inputs from
  69640. */
  69641. detachControl(element: Nullable<HTMLElement>): void;
  69642. /**
  69643. * Gets the class name of the current intput.
  69644. * @returns the class name
  69645. */
  69646. getClassName(): string;
  69647. /**
  69648. * Get the friendly name associated with the input class.
  69649. * @returns the input friendly name
  69650. */
  69651. getSimpleName(): string;
  69652. }
  69653. }
  69654. declare module BABYLON {
  69655. /**
  69656. * Manage the touch inputs to control the movement of a free camera.
  69657. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  69658. */
  69659. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  69660. /**
  69661. * Defines the camera the input is attached to.
  69662. */
  69663. camera: FreeCamera;
  69664. /**
  69665. * Defines the touch sensibility for rotation.
  69666. * The higher the faster.
  69667. */
  69668. touchAngularSensibility: number;
  69669. /**
  69670. * Defines the touch sensibility for move.
  69671. * The higher the faster.
  69672. */
  69673. touchMoveSensibility: number;
  69674. private _offsetX;
  69675. private _offsetY;
  69676. private _pointerPressed;
  69677. private _pointerInput;
  69678. private _observer;
  69679. private _onLostFocus;
  69680. /**
  69681. * Attach the input controls to a specific dom element to get the input from.
  69682. * @param element Defines the element the controls should be listened from
  69683. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  69684. */
  69685. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  69686. /**
  69687. * Detach the current controls from the specified dom element.
  69688. * @param element Defines the element to stop listening the inputs from
  69689. */
  69690. detachControl(element: Nullable<HTMLElement>): void;
  69691. /**
  69692. * Update the current camera state depending on the inputs that have been used this frame.
  69693. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  69694. */
  69695. checkInputs(): void;
  69696. /**
  69697. * Gets the class name of the current intput.
  69698. * @returns the class name
  69699. */
  69700. getClassName(): string;
  69701. /**
  69702. * Get the friendly name associated with the input class.
  69703. * @returns the input friendly name
  69704. */
  69705. getSimpleName(): string;
  69706. }
  69707. }
  69708. declare module BABYLON {
  69709. /**
  69710. * Default Inputs manager for the FreeCamera.
  69711. * It groups all the default supported inputs for ease of use.
  69712. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  69713. */
  69714. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  69715. /**
  69716. * Instantiates a new FreeCameraInputsManager.
  69717. * @param camera Defines the camera the inputs belong to
  69718. */
  69719. constructor(camera: FreeCamera);
  69720. /**
  69721. * Add keyboard input support to the input manager.
  69722. * @returns the current input manager
  69723. */
  69724. addKeyboard(): FreeCameraInputsManager;
  69725. /**
  69726. * Add mouse input support to the input manager.
  69727. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  69728. * @returns the current input manager
  69729. */
  69730. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  69731. /**
  69732. * Add touch input support to the input manager.
  69733. * @returns the current input manager
  69734. */
  69735. addTouch(): FreeCameraInputsManager;
  69736. }
  69737. }
  69738. declare module BABYLON {
  69739. /**
  69740. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  69741. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  69742. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  69743. */
  69744. export class FreeCamera extends TargetCamera {
  69745. /**
  69746. * Define the collision ellipsoid of the camera.
  69747. * This is helpful to simulate a camera body like the player body around the camera
  69748. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  69749. */
  69750. ellipsoid: Vector3;
  69751. /**
  69752. * Define an offset for the position of the ellipsoid around the camera.
  69753. * This can be helpful to determine the center of the body near the gravity center of the body
  69754. * instead of its head.
  69755. */
  69756. ellipsoidOffset: Vector3;
  69757. /**
  69758. * Enable or disable collisions of the camera with the rest of the scene objects.
  69759. */
  69760. checkCollisions: boolean;
  69761. /**
  69762. * Enable or disable gravity on the camera.
  69763. */
  69764. applyGravity: boolean;
  69765. /**
  69766. * Define the input manager associated to the camera.
  69767. */
  69768. inputs: FreeCameraInputsManager;
  69769. /**
  69770. * Gets the input sensibility for a mouse input. (default is 2000.0)
  69771. * Higher values reduce sensitivity.
  69772. */
  69773. /**
  69774. * Sets the input sensibility for a mouse input. (default is 2000.0)
  69775. * Higher values reduce sensitivity.
  69776. */
  69777. angularSensibility: number;
  69778. /**
  69779. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  69780. */
  69781. keysUp: number[];
  69782. /**
  69783. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  69784. */
  69785. keysDown: number[];
  69786. /**
  69787. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  69788. */
  69789. keysLeft: number[];
  69790. /**
  69791. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  69792. */
  69793. keysRight: number[];
  69794. /**
  69795. * Event raised when the camera collide with a mesh in the scene.
  69796. */
  69797. onCollide: (collidedMesh: AbstractMesh) => void;
  69798. private _collider;
  69799. private _needMoveForGravity;
  69800. private _oldPosition;
  69801. private _diffPosition;
  69802. private _newPosition;
  69803. /** @hidden */
  69804. _localDirection: Vector3;
  69805. /** @hidden */
  69806. _transformedDirection: Vector3;
  69807. /**
  69808. * Instantiates a Free Camera.
  69809. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  69810. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  69811. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  69812. * @param name Define the name of the camera in the scene
  69813. * @param position Define the start position of the camera in the scene
  69814. * @param scene Define the scene the camera belongs to
  69815. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  69816. */
  69817. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  69818. /**
  69819. * Attached controls to the current camera.
  69820. * @param element Defines the element the controls should be listened from
  69821. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  69822. */
  69823. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  69824. /**
  69825. * Detach the current controls from the camera.
  69826. * The camera will stop reacting to inputs.
  69827. * @param element Defines the element to stop listening the inputs from
  69828. */
  69829. detachControl(element: HTMLElement): void;
  69830. private _collisionMask;
  69831. /**
  69832. * Define a collision mask to limit the list of object the camera can collide with
  69833. */
  69834. collisionMask: number;
  69835. /** @hidden */
  69836. _collideWithWorld(displacement: Vector3): void;
  69837. private _onCollisionPositionChange;
  69838. /** @hidden */
  69839. _checkInputs(): void;
  69840. /** @hidden */
  69841. _decideIfNeedsToMove(): boolean;
  69842. /** @hidden */
  69843. _updatePosition(): void;
  69844. /**
  69845. * Destroy the camera and release the current resources hold by it.
  69846. */
  69847. dispose(): void;
  69848. /**
  69849. * Gets the current object class name.
  69850. * @return the class name
  69851. */
  69852. getClassName(): string;
  69853. }
  69854. }
  69855. declare module BABYLON {
  69856. /**
  69857. * Represents a gamepad control stick position
  69858. */
  69859. export class StickValues {
  69860. /**
  69861. * The x component of the control stick
  69862. */
  69863. x: number;
  69864. /**
  69865. * The y component of the control stick
  69866. */
  69867. y: number;
  69868. /**
  69869. * Initializes the gamepad x and y control stick values
  69870. * @param x The x component of the gamepad control stick value
  69871. * @param y The y component of the gamepad control stick value
  69872. */
  69873. constructor(
  69874. /**
  69875. * The x component of the control stick
  69876. */
  69877. x: number,
  69878. /**
  69879. * The y component of the control stick
  69880. */
  69881. y: number);
  69882. }
  69883. /**
  69884. * An interface which manages callbacks for gamepad button changes
  69885. */
  69886. export interface GamepadButtonChanges {
  69887. /**
  69888. * Called when a gamepad has been changed
  69889. */
  69890. changed: boolean;
  69891. /**
  69892. * Called when a gamepad press event has been triggered
  69893. */
  69894. pressChanged: boolean;
  69895. /**
  69896. * Called when a touch event has been triggered
  69897. */
  69898. touchChanged: boolean;
  69899. /**
  69900. * Called when a value has changed
  69901. */
  69902. valueChanged: boolean;
  69903. }
  69904. /**
  69905. * Represents a gamepad
  69906. */
  69907. export class Gamepad {
  69908. /**
  69909. * The id of the gamepad
  69910. */
  69911. id: string;
  69912. /**
  69913. * The index of the gamepad
  69914. */
  69915. index: number;
  69916. /**
  69917. * The browser gamepad
  69918. */
  69919. browserGamepad: any;
  69920. /**
  69921. * Specifies what type of gamepad this represents
  69922. */
  69923. type: number;
  69924. private _leftStick;
  69925. private _rightStick;
  69926. /** @hidden */
  69927. _isConnected: boolean;
  69928. private _leftStickAxisX;
  69929. private _leftStickAxisY;
  69930. private _rightStickAxisX;
  69931. private _rightStickAxisY;
  69932. /**
  69933. * Triggered when the left control stick has been changed
  69934. */
  69935. private _onleftstickchanged;
  69936. /**
  69937. * Triggered when the right control stick has been changed
  69938. */
  69939. private _onrightstickchanged;
  69940. /**
  69941. * Represents a gamepad controller
  69942. */
  69943. static GAMEPAD: number;
  69944. /**
  69945. * Represents a generic controller
  69946. */
  69947. static GENERIC: number;
  69948. /**
  69949. * Represents an XBox controller
  69950. */
  69951. static XBOX: number;
  69952. /**
  69953. * Represents a pose-enabled controller
  69954. */
  69955. static POSE_ENABLED: number;
  69956. /**
  69957. * Specifies whether the left control stick should be Y-inverted
  69958. */
  69959. protected _invertLeftStickY: boolean;
  69960. /**
  69961. * Specifies if the gamepad has been connected
  69962. */
  69963. readonly isConnected: boolean;
  69964. /**
  69965. * Initializes the gamepad
  69966. * @param id The id of the gamepad
  69967. * @param index The index of the gamepad
  69968. * @param browserGamepad The browser gamepad
  69969. * @param leftStickX The x component of the left joystick
  69970. * @param leftStickY The y component of the left joystick
  69971. * @param rightStickX The x component of the right joystick
  69972. * @param rightStickY The y component of the right joystick
  69973. */
  69974. constructor(
  69975. /**
  69976. * The id of the gamepad
  69977. */
  69978. id: string,
  69979. /**
  69980. * The index of the gamepad
  69981. */
  69982. index: number,
  69983. /**
  69984. * The browser gamepad
  69985. */
  69986. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  69987. /**
  69988. * Callback triggered when the left joystick has changed
  69989. * @param callback
  69990. */
  69991. onleftstickchanged(callback: (values: StickValues) => void): void;
  69992. /**
  69993. * Callback triggered when the right joystick has changed
  69994. * @param callback
  69995. */
  69996. onrightstickchanged(callback: (values: StickValues) => void): void;
  69997. /**
  69998. * Gets the left joystick
  69999. */
  70000. /**
  70001. * Sets the left joystick values
  70002. */
  70003. leftStick: StickValues;
  70004. /**
  70005. * Gets the right joystick
  70006. */
  70007. /**
  70008. * Sets the right joystick value
  70009. */
  70010. rightStick: StickValues;
  70011. /**
  70012. * Updates the gamepad joystick positions
  70013. */
  70014. update(): void;
  70015. /**
  70016. * Disposes the gamepad
  70017. */
  70018. dispose(): void;
  70019. }
  70020. /**
  70021. * Represents a generic gamepad
  70022. */
  70023. export class GenericPad extends Gamepad {
  70024. private _buttons;
  70025. private _onbuttondown;
  70026. private _onbuttonup;
  70027. /**
  70028. * Observable triggered when a button has been pressed
  70029. */
  70030. onButtonDownObservable: Observable<number>;
  70031. /**
  70032. * Observable triggered when a button has been released
  70033. */
  70034. onButtonUpObservable: Observable<number>;
  70035. /**
  70036. * Callback triggered when a button has been pressed
  70037. * @param callback Called when a button has been pressed
  70038. */
  70039. onbuttondown(callback: (buttonPressed: number) => void): void;
  70040. /**
  70041. * Callback triggered when a button has been released
  70042. * @param callback Called when a button has been released
  70043. */
  70044. onbuttonup(callback: (buttonReleased: number) => void): void;
  70045. /**
  70046. * Initializes the generic gamepad
  70047. * @param id The id of the generic gamepad
  70048. * @param index The index of the generic gamepad
  70049. * @param browserGamepad The browser gamepad
  70050. */
  70051. constructor(id: string, index: number, browserGamepad: any);
  70052. private _setButtonValue;
  70053. /**
  70054. * Updates the generic gamepad
  70055. */
  70056. update(): void;
  70057. /**
  70058. * Disposes the generic gamepad
  70059. */
  70060. dispose(): void;
  70061. }
  70062. }
  70063. declare module BABYLON {
  70064. /**
  70065. * Defines the types of pose enabled controllers that are supported
  70066. */
  70067. export enum PoseEnabledControllerType {
  70068. /**
  70069. * HTC Vive
  70070. */
  70071. VIVE = 0,
  70072. /**
  70073. * Oculus Rift
  70074. */
  70075. OCULUS = 1,
  70076. /**
  70077. * Windows mixed reality
  70078. */
  70079. WINDOWS = 2,
  70080. /**
  70081. * Samsung gear VR
  70082. */
  70083. GEAR_VR = 3,
  70084. /**
  70085. * Google Daydream
  70086. */
  70087. DAYDREAM = 4,
  70088. /**
  70089. * Generic
  70090. */
  70091. GENERIC = 5
  70092. }
  70093. /**
  70094. * Defines the MutableGamepadButton interface for the state of a gamepad button
  70095. */
  70096. export interface MutableGamepadButton {
  70097. /**
  70098. * Value of the button/trigger
  70099. */
  70100. value: number;
  70101. /**
  70102. * If the button/trigger is currently touched
  70103. */
  70104. touched: boolean;
  70105. /**
  70106. * If the button/trigger is currently pressed
  70107. */
  70108. pressed: boolean;
  70109. }
  70110. /**
  70111. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  70112. * @hidden
  70113. */
  70114. export interface ExtendedGamepadButton extends GamepadButton {
  70115. /**
  70116. * If the button/trigger is currently pressed
  70117. */
  70118. readonly pressed: boolean;
  70119. /**
  70120. * If the button/trigger is currently touched
  70121. */
  70122. readonly touched: boolean;
  70123. /**
  70124. * Value of the button/trigger
  70125. */
  70126. readonly value: number;
  70127. }
  70128. /** @hidden */
  70129. export interface _GamePadFactory {
  70130. /**
  70131. * Returns wether or not the current gamepad can be created for this type of controller.
  70132. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  70133. * @returns true if it can be created, otherwise false
  70134. */
  70135. canCreate(gamepadInfo: any): boolean;
  70136. /**
  70137. * Creates a new instance of the Gamepad.
  70138. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  70139. * @returns the new gamepad instance
  70140. */
  70141. create(gamepadInfo: any): Gamepad;
  70142. }
  70143. /**
  70144. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  70145. */
  70146. export class PoseEnabledControllerHelper {
  70147. /** @hidden */
  70148. static _ControllerFactories: _GamePadFactory[];
  70149. /** @hidden */
  70150. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  70151. /**
  70152. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  70153. * @param vrGamepad the gamepad to initialized
  70154. * @returns a vr controller of the type the gamepad identified as
  70155. */
  70156. static InitiateController(vrGamepad: any): Gamepad;
  70157. }
  70158. /**
  70159. * Defines the PoseEnabledController object that contains state of a vr capable controller
  70160. */
  70161. export class PoseEnabledController extends Gamepad implements PoseControlled {
  70162. private _deviceRoomPosition;
  70163. private _deviceRoomRotationQuaternion;
  70164. /**
  70165. * The device position in babylon space
  70166. */
  70167. devicePosition: Vector3;
  70168. /**
  70169. * The device rotation in babylon space
  70170. */
  70171. deviceRotationQuaternion: Quaternion;
  70172. /**
  70173. * The scale factor of the device in babylon space
  70174. */
  70175. deviceScaleFactor: number;
  70176. /**
  70177. * (Likely devicePosition should be used instead) The device position in its room space
  70178. */
  70179. position: Vector3;
  70180. /**
  70181. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  70182. */
  70183. rotationQuaternion: Quaternion;
  70184. /**
  70185. * The type of controller (Eg. Windows mixed reality)
  70186. */
  70187. controllerType: PoseEnabledControllerType;
  70188. protected _calculatedPosition: Vector3;
  70189. private _calculatedRotation;
  70190. /**
  70191. * The raw pose from the device
  70192. */
  70193. rawPose: DevicePose;
  70194. private _trackPosition;
  70195. private _maxRotationDistFromHeadset;
  70196. private _draggedRoomRotation;
  70197. /**
  70198. * @hidden
  70199. */
  70200. _disableTrackPosition(fixedPosition: Vector3): void;
  70201. /**
  70202. * Internal, the mesh attached to the controller
  70203. * @hidden
  70204. */
  70205. _mesh: Nullable<AbstractMesh>;
  70206. private _poseControlledCamera;
  70207. private _leftHandSystemQuaternion;
  70208. /**
  70209. * Internal, matrix used to convert room space to babylon space
  70210. * @hidden
  70211. */
  70212. _deviceToWorld: Matrix;
  70213. /**
  70214. * Node to be used when casting a ray from the controller
  70215. * @hidden
  70216. */
  70217. _pointingPoseNode: Nullable<TransformNode>;
  70218. /**
  70219. * Name of the child mesh that can be used to cast a ray from the controller
  70220. */
  70221. static readonly POINTING_POSE: string;
  70222. /**
  70223. * Creates a new PoseEnabledController from a gamepad
  70224. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  70225. */
  70226. constructor(browserGamepad: any);
  70227. private _workingMatrix;
  70228. /**
  70229. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  70230. */
  70231. update(): void;
  70232. /**
  70233. * Updates only the pose device and mesh without doing any button event checking
  70234. */
  70235. protected _updatePoseAndMesh(): void;
  70236. /**
  70237. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  70238. * @param poseData raw pose fromthe device
  70239. */
  70240. updateFromDevice(poseData: DevicePose): void;
  70241. /**
  70242. * @hidden
  70243. */
  70244. _meshAttachedObservable: Observable<AbstractMesh>;
  70245. /**
  70246. * Attaches a mesh to the controller
  70247. * @param mesh the mesh to be attached
  70248. */
  70249. attachToMesh(mesh: AbstractMesh): void;
  70250. /**
  70251. * Attaches the controllers mesh to a camera
  70252. * @param camera the camera the mesh should be attached to
  70253. */
  70254. attachToPoseControlledCamera(camera: TargetCamera): void;
  70255. /**
  70256. * Disposes of the controller
  70257. */
  70258. dispose(): void;
  70259. /**
  70260. * The mesh that is attached to the controller
  70261. */
  70262. readonly mesh: Nullable<AbstractMesh>;
  70263. /**
  70264. * Gets the ray of the controller in the direction the controller is pointing
  70265. * @param length the length the resulting ray should be
  70266. * @returns a ray in the direction the controller is pointing
  70267. */
  70268. getForwardRay(length?: number): Ray;
  70269. }
  70270. }
  70271. declare module BABYLON {
  70272. /**
  70273. * Defines the WebVRController object that represents controllers tracked in 3D space
  70274. */
  70275. export abstract class WebVRController extends PoseEnabledController {
  70276. /**
  70277. * Internal, the default controller model for the controller
  70278. */
  70279. protected _defaultModel: AbstractMesh;
  70280. /**
  70281. * Fired when the trigger state has changed
  70282. */
  70283. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  70284. /**
  70285. * Fired when the main button state has changed
  70286. */
  70287. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  70288. /**
  70289. * Fired when the secondary button state has changed
  70290. */
  70291. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  70292. /**
  70293. * Fired when the pad state has changed
  70294. */
  70295. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  70296. /**
  70297. * Fired when controllers stick values have changed
  70298. */
  70299. onPadValuesChangedObservable: Observable<StickValues>;
  70300. /**
  70301. * Array of button availible on the controller
  70302. */
  70303. protected _buttons: Array<MutableGamepadButton>;
  70304. private _onButtonStateChange;
  70305. /**
  70306. * Fired when a controller button's state has changed
  70307. * @param callback the callback containing the button that was modified
  70308. */
  70309. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  70310. /**
  70311. * X and Y axis corrisponding to the controllers joystick
  70312. */
  70313. pad: StickValues;
  70314. /**
  70315. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  70316. */
  70317. hand: string;
  70318. /**
  70319. * The default controller model for the controller
  70320. */
  70321. readonly defaultModel: AbstractMesh;
  70322. /**
  70323. * Creates a new WebVRController from a gamepad
  70324. * @param vrGamepad the gamepad that the WebVRController should be created from
  70325. */
  70326. constructor(vrGamepad: any);
  70327. /**
  70328. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  70329. */
  70330. update(): void;
  70331. /**
  70332. * Function to be called when a button is modified
  70333. */
  70334. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  70335. /**
  70336. * Loads a mesh and attaches it to the controller
  70337. * @param scene the scene the mesh should be added to
  70338. * @param meshLoaded callback for when the mesh has been loaded
  70339. */
  70340. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  70341. private _setButtonValue;
  70342. private _changes;
  70343. private _checkChanges;
  70344. /**
  70345. * Disposes of th webVRCOntroller
  70346. */
  70347. dispose(): void;
  70348. }
  70349. }
  70350. declare module BABYLON {
  70351. /**
  70352. * The HemisphericLight simulates the ambient environment light,
  70353. * so the passed direction is the light reflection direction, not the incoming direction.
  70354. */
  70355. export class HemisphericLight extends Light {
  70356. /**
  70357. * The groundColor is the light in the opposite direction to the one specified during creation.
  70358. * 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.
  70359. */
  70360. groundColor: Color3;
  70361. /**
  70362. * The light reflection direction, not the incoming direction.
  70363. */
  70364. direction: Vector3;
  70365. /**
  70366. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  70367. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  70368. * The HemisphericLight can't cast shadows.
  70369. * Documentation : https://doc.babylonjs.com/babylon101/lights
  70370. * @param name The friendly name of the light
  70371. * @param direction The direction of the light reflection
  70372. * @param scene The scene the light belongs to
  70373. */
  70374. constructor(name: string, direction: Vector3, scene: Scene);
  70375. protected _buildUniformLayout(): void;
  70376. /**
  70377. * Returns the string "HemisphericLight".
  70378. * @return The class name
  70379. */
  70380. getClassName(): string;
  70381. /**
  70382. * Sets the HemisphericLight direction towards the passed target (Vector3).
  70383. * Returns the updated direction.
  70384. * @param target The target the direction should point to
  70385. * @return The computed direction
  70386. */
  70387. setDirectionToTarget(target: Vector3): Vector3;
  70388. /**
  70389. * Returns the shadow generator associated to the light.
  70390. * @returns Always null for hemispheric lights because it does not support shadows.
  70391. */
  70392. getShadowGenerator(): Nullable<IShadowGenerator>;
  70393. /**
  70394. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  70395. * @param effect The effect to update
  70396. * @param lightIndex The index of the light in the effect to update
  70397. * @returns The hemispheric light
  70398. */
  70399. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  70400. /**
  70401. * Computes the world matrix of the node
  70402. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  70403. * @param useWasUpdatedFlag defines a reserved property
  70404. * @returns the world matrix
  70405. */
  70406. computeWorldMatrix(): Matrix;
  70407. /**
  70408. * Returns the integer 3.
  70409. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  70410. */
  70411. getTypeID(): number;
  70412. /**
  70413. * Prepares the list of defines specific to the light type.
  70414. * @param defines the list of defines
  70415. * @param lightIndex defines the index of the light for the effect
  70416. */
  70417. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  70418. }
  70419. }
  70420. declare module BABYLON {
  70421. /**
  70422. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  70423. * IMPORTANT!! The data is right-hand data.
  70424. * @export
  70425. * @interface DevicePose
  70426. */
  70427. export interface DevicePose {
  70428. /**
  70429. * The position of the device, values in array are [x,y,z].
  70430. */
  70431. readonly position: Nullable<Float32Array>;
  70432. /**
  70433. * The linearVelocity of the device, values in array are [x,y,z].
  70434. */
  70435. readonly linearVelocity: Nullable<Float32Array>;
  70436. /**
  70437. * The linearAcceleration of the device, values in array are [x,y,z].
  70438. */
  70439. readonly linearAcceleration: Nullable<Float32Array>;
  70440. /**
  70441. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  70442. */
  70443. readonly orientation: Nullable<Float32Array>;
  70444. /**
  70445. * The angularVelocity of the device, values in array are [x,y,z].
  70446. */
  70447. readonly angularVelocity: Nullable<Float32Array>;
  70448. /**
  70449. * The angularAcceleration of the device, values in array are [x,y,z].
  70450. */
  70451. readonly angularAcceleration: Nullable<Float32Array>;
  70452. }
  70453. /**
  70454. * Interface representing a pose controlled object in Babylon.
  70455. * A pose controlled object has both regular pose values as well as pose values
  70456. * from an external device such as a VR head mounted display
  70457. */
  70458. export interface PoseControlled {
  70459. /**
  70460. * The position of the object in babylon space.
  70461. */
  70462. position: Vector3;
  70463. /**
  70464. * The rotation quaternion of the object in babylon space.
  70465. */
  70466. rotationQuaternion: Quaternion;
  70467. /**
  70468. * The position of the device in babylon space.
  70469. */
  70470. devicePosition?: Vector3;
  70471. /**
  70472. * The rotation quaternion of the device in babylon space.
  70473. */
  70474. deviceRotationQuaternion: Quaternion;
  70475. /**
  70476. * The raw pose coming from the device.
  70477. */
  70478. rawPose: Nullable<DevicePose>;
  70479. /**
  70480. * The scale of the device to be used when translating from device space to babylon space.
  70481. */
  70482. deviceScaleFactor: number;
  70483. /**
  70484. * Updates the poseControlled values based on the input device pose.
  70485. * @param poseData the pose data to update the object with
  70486. */
  70487. updateFromDevice(poseData: DevicePose): void;
  70488. }
  70489. /**
  70490. * Set of options to customize the webVRCamera
  70491. */
  70492. export interface WebVROptions {
  70493. /**
  70494. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  70495. */
  70496. trackPosition?: boolean;
  70497. /**
  70498. * Sets the scale of the vrDevice in babylon space. (default: 1)
  70499. */
  70500. positionScale?: number;
  70501. /**
  70502. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  70503. */
  70504. displayName?: string;
  70505. /**
  70506. * Should the native controller meshes be initialized. (default: true)
  70507. */
  70508. controllerMeshes?: boolean;
  70509. /**
  70510. * Creating a default HemiLight only on controllers. (default: true)
  70511. */
  70512. defaultLightingOnControllers?: boolean;
  70513. /**
  70514. * If you don't want to use the default VR button of the helper. (default: false)
  70515. */
  70516. useCustomVRButton?: boolean;
  70517. /**
  70518. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  70519. */
  70520. customVRButton?: HTMLButtonElement;
  70521. /**
  70522. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  70523. */
  70524. rayLength?: number;
  70525. /**
  70526. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  70527. */
  70528. defaultHeight?: number;
  70529. }
  70530. /**
  70531. * This represents a WebVR camera.
  70532. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  70533. * @example http://doc.babylonjs.com/how_to/webvr_camera
  70534. */
  70535. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  70536. private webVROptions;
  70537. /**
  70538. * @hidden
  70539. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  70540. */
  70541. _vrDevice: any;
  70542. /**
  70543. * The rawPose of the vrDevice.
  70544. */
  70545. rawPose: Nullable<DevicePose>;
  70546. private _onVREnabled;
  70547. private _specsVersion;
  70548. private _attached;
  70549. private _frameData;
  70550. protected _descendants: Array<Node>;
  70551. private _deviceRoomPosition;
  70552. /** @hidden */
  70553. _deviceRoomRotationQuaternion: Quaternion;
  70554. private _standingMatrix;
  70555. /**
  70556. * Represents device position in babylon space.
  70557. */
  70558. devicePosition: Vector3;
  70559. /**
  70560. * Represents device rotation in babylon space.
  70561. */
  70562. deviceRotationQuaternion: Quaternion;
  70563. /**
  70564. * The scale of the device to be used when translating from device space to babylon space.
  70565. */
  70566. deviceScaleFactor: number;
  70567. private _deviceToWorld;
  70568. private _worldToDevice;
  70569. /**
  70570. * References to the webVR controllers for the vrDevice.
  70571. */
  70572. controllers: Array<WebVRController>;
  70573. /**
  70574. * Emits an event when a controller is attached.
  70575. */
  70576. onControllersAttachedObservable: Observable<WebVRController[]>;
  70577. /**
  70578. * Emits an event when a controller's mesh has been loaded;
  70579. */
  70580. onControllerMeshLoadedObservable: Observable<WebVRController>;
  70581. /**
  70582. * Emits an event when the HMD's pose has been updated.
  70583. */
  70584. onPoseUpdatedFromDeviceObservable: Observable<any>;
  70585. private _poseSet;
  70586. /**
  70587. * If the rig cameras be used as parent instead of this camera.
  70588. */
  70589. rigParenting: boolean;
  70590. private _lightOnControllers;
  70591. private _defaultHeight?;
  70592. /**
  70593. * Instantiates a WebVRFreeCamera.
  70594. * @param name The name of the WebVRFreeCamera
  70595. * @param position The starting anchor position for the camera
  70596. * @param scene The scene the camera belongs to
  70597. * @param webVROptions a set of customizable options for the webVRCamera
  70598. */
  70599. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  70600. /**
  70601. * Gets the device distance from the ground in meters.
  70602. * @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.
  70603. */
  70604. deviceDistanceToRoomGround(): number;
  70605. /**
  70606. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  70607. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  70608. */
  70609. useStandingMatrix(callback?: (bool: boolean) => void): void;
  70610. /**
  70611. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  70612. * @returns A promise with a boolean set to if the standing matrix is supported.
  70613. */
  70614. useStandingMatrixAsync(): Promise<boolean>;
  70615. /**
  70616. * Disposes the camera
  70617. */
  70618. dispose(): void;
  70619. /**
  70620. * Gets a vrController by name.
  70621. * @param name The name of the controller to retreive
  70622. * @returns the controller matching the name specified or null if not found
  70623. */
  70624. getControllerByName(name: string): Nullable<WebVRController>;
  70625. private _leftController;
  70626. /**
  70627. * The controller corrisponding to the users left hand.
  70628. */
  70629. readonly leftController: Nullable<WebVRController>;
  70630. private _rightController;
  70631. /**
  70632. * The controller corrisponding to the users right hand.
  70633. */
  70634. readonly rightController: Nullable<WebVRController>;
  70635. /**
  70636. * Casts a ray forward from the vrCamera's gaze.
  70637. * @param length Length of the ray (default: 100)
  70638. * @returns the ray corrisponding to the gaze
  70639. */
  70640. getForwardRay(length?: number): Ray;
  70641. /**
  70642. * @hidden
  70643. * Updates the camera based on device's frame data
  70644. */
  70645. _checkInputs(): void;
  70646. /**
  70647. * Updates the poseControlled values based on the input device pose.
  70648. * @param poseData Pose coming from the device
  70649. */
  70650. updateFromDevice(poseData: DevicePose): void;
  70651. private _htmlElementAttached;
  70652. private _detachIfAttached;
  70653. /**
  70654. * WebVR's attach control will start broadcasting frames to the device.
  70655. * Note that in certain browsers (chrome for example) this function must be called
  70656. * within a user-interaction callback. Example:
  70657. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  70658. *
  70659. * @param element html element to attach the vrDevice to
  70660. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  70661. */
  70662. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  70663. /**
  70664. * Detaches the camera from the html element and disables VR
  70665. *
  70666. * @param element html element to detach from
  70667. */
  70668. detachControl(element: HTMLElement): void;
  70669. /**
  70670. * @returns the name of this class
  70671. */
  70672. getClassName(): string;
  70673. /**
  70674. * Calls resetPose on the vrDisplay
  70675. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  70676. */
  70677. resetToCurrentRotation(): void;
  70678. /**
  70679. * @hidden
  70680. * Updates the rig cameras (left and right eye)
  70681. */
  70682. _updateRigCameras(): void;
  70683. private _workingVector;
  70684. private _oneVector;
  70685. private _workingMatrix;
  70686. private updateCacheCalled;
  70687. private _correctPositionIfNotTrackPosition;
  70688. /**
  70689. * @hidden
  70690. * Updates the cached values of the camera
  70691. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  70692. */
  70693. _updateCache(ignoreParentClass?: boolean): void;
  70694. /**
  70695. * @hidden
  70696. * Get current device position in babylon world
  70697. */
  70698. _computeDevicePosition(): void;
  70699. /**
  70700. * Updates the current device position and rotation in the babylon world
  70701. */
  70702. update(): void;
  70703. /**
  70704. * @hidden
  70705. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  70706. * @returns an identity matrix
  70707. */
  70708. _getViewMatrix(): Matrix;
  70709. private _tmpMatrix;
  70710. /**
  70711. * This function is called by the two RIG cameras.
  70712. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  70713. * @hidden
  70714. */
  70715. _getWebVRViewMatrix(): Matrix;
  70716. /** @hidden */
  70717. _getWebVRProjectionMatrix(): Matrix;
  70718. private _onGamepadConnectedObserver;
  70719. private _onGamepadDisconnectedObserver;
  70720. private _updateCacheWhenTrackingDisabledObserver;
  70721. /**
  70722. * Initializes the controllers and their meshes
  70723. */
  70724. initControllers(): void;
  70725. }
  70726. }
  70727. declare module BABYLON {
  70728. /**
  70729. * Size options for a post process
  70730. */
  70731. export type PostProcessOptions = {
  70732. width: number;
  70733. height: number;
  70734. };
  70735. /**
  70736. * PostProcess can be used to apply a shader to a texture after it has been rendered
  70737. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  70738. */
  70739. export class PostProcess {
  70740. /** Name of the PostProcess. */
  70741. name: string;
  70742. /**
  70743. * Gets or sets the unique id of the post process
  70744. */
  70745. uniqueId: number;
  70746. /**
  70747. * Width of the texture to apply the post process on
  70748. */
  70749. width: number;
  70750. /**
  70751. * Height of the texture to apply the post process on
  70752. */
  70753. height: number;
  70754. /**
  70755. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  70756. * @hidden
  70757. */
  70758. _outputTexture: Nullable<InternalTexture>;
  70759. /**
  70760. * Sampling mode used by the shader
  70761. * See https://doc.babylonjs.com/classes/3.1/texture
  70762. */
  70763. renderTargetSamplingMode: number;
  70764. /**
  70765. * Clear color to use when screen clearing
  70766. */
  70767. clearColor: Color4;
  70768. /**
  70769. * If the buffer needs to be cleared before applying the post process. (default: true)
  70770. * Should be set to false if shader will overwrite all previous pixels.
  70771. */
  70772. autoClear: boolean;
  70773. /**
  70774. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  70775. */
  70776. alphaMode: number;
  70777. /**
  70778. * Sets the setAlphaBlendConstants of the babylon engine
  70779. */
  70780. alphaConstants: Color4;
  70781. /**
  70782. * Animations to be used for the post processing
  70783. */
  70784. animations: Animation[];
  70785. /**
  70786. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  70787. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  70788. */
  70789. enablePixelPerfectMode: boolean;
  70790. /**
  70791. * Force the postprocess to be applied without taking in account viewport
  70792. */
  70793. forceFullscreenViewport: boolean;
  70794. /**
  70795. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  70796. *
  70797. * | Value | Type | Description |
  70798. * | ----- | ----------------------------------- | ----------- |
  70799. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  70800. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  70801. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  70802. *
  70803. */
  70804. scaleMode: number;
  70805. /**
  70806. * Force textures to be a power of two (default: false)
  70807. */
  70808. alwaysForcePOT: boolean;
  70809. private _samples;
  70810. /**
  70811. * Number of sample textures (default: 1)
  70812. */
  70813. samples: number;
  70814. /**
  70815. * Modify the scale of the post process to be the same as the viewport (default: false)
  70816. */
  70817. adaptScaleToCurrentViewport: boolean;
  70818. private _camera;
  70819. private _scene;
  70820. private _engine;
  70821. private _options;
  70822. private _reusable;
  70823. private _textureType;
  70824. /**
  70825. * Smart array of input and output textures for the post process.
  70826. * @hidden
  70827. */
  70828. _textures: SmartArray<InternalTexture>;
  70829. /**
  70830. * The index in _textures that corresponds to the output texture.
  70831. * @hidden
  70832. */
  70833. _currentRenderTextureInd: number;
  70834. private _effect;
  70835. private _samplers;
  70836. private _fragmentUrl;
  70837. private _vertexUrl;
  70838. private _parameters;
  70839. private _scaleRatio;
  70840. protected _indexParameters: any;
  70841. private _shareOutputWithPostProcess;
  70842. private _texelSize;
  70843. private _forcedOutputTexture;
  70844. /**
  70845. * Returns the fragment url or shader name used in the post process.
  70846. * @returns the fragment url or name in the shader store.
  70847. */
  70848. getEffectName(): string;
  70849. /**
  70850. * An event triggered when the postprocess is activated.
  70851. */
  70852. onActivateObservable: Observable<Camera>;
  70853. private _onActivateObserver;
  70854. /**
  70855. * A function that is added to the onActivateObservable
  70856. */
  70857. onActivate: Nullable<(camera: Camera) => void>;
  70858. /**
  70859. * An event triggered when the postprocess changes its size.
  70860. */
  70861. onSizeChangedObservable: Observable<PostProcess>;
  70862. private _onSizeChangedObserver;
  70863. /**
  70864. * A function that is added to the onSizeChangedObservable
  70865. */
  70866. onSizeChanged: (postProcess: PostProcess) => void;
  70867. /**
  70868. * An event triggered when the postprocess applies its effect.
  70869. */
  70870. onApplyObservable: Observable<Effect>;
  70871. private _onApplyObserver;
  70872. /**
  70873. * A function that is added to the onApplyObservable
  70874. */
  70875. onApply: (effect: Effect) => void;
  70876. /**
  70877. * An event triggered before rendering the postprocess
  70878. */
  70879. onBeforeRenderObservable: Observable<Effect>;
  70880. private _onBeforeRenderObserver;
  70881. /**
  70882. * A function that is added to the onBeforeRenderObservable
  70883. */
  70884. onBeforeRender: (effect: Effect) => void;
  70885. /**
  70886. * An event triggered after rendering the postprocess
  70887. */
  70888. onAfterRenderObservable: Observable<Effect>;
  70889. private _onAfterRenderObserver;
  70890. /**
  70891. * A function that is added to the onAfterRenderObservable
  70892. */
  70893. onAfterRender: (efect: Effect) => void;
  70894. /**
  70895. * 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
  70896. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  70897. */
  70898. inputTexture: InternalTexture;
  70899. /**
  70900. * Gets the camera which post process is applied to.
  70901. * @returns The camera the post process is applied to.
  70902. */
  70903. getCamera(): Camera;
  70904. /**
  70905. * Gets the texel size of the postprocess.
  70906. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  70907. */
  70908. readonly texelSize: Vector2;
  70909. /**
  70910. * Creates a new instance PostProcess
  70911. * @param name The name of the PostProcess.
  70912. * @param fragmentUrl The url of the fragment shader to be used.
  70913. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  70914. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  70915. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  70916. * @param camera The camera to apply the render pass to.
  70917. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70918. * @param engine The engine which the post process will be applied. (default: current engine)
  70919. * @param reusable If the post process can be reused on the same frame. (default: false)
  70920. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  70921. * @param textureType Type of textures used when performing the post process. (default: 0)
  70922. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  70923. * @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
  70924. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  70925. */
  70926. constructor(
  70927. /** Name of the PostProcess. */
  70928. 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);
  70929. /**
  70930. * Gets a string idenfifying the name of the class
  70931. * @returns "PostProcess" string
  70932. */
  70933. getClassName(): string;
  70934. /**
  70935. * Gets the engine which this post process belongs to.
  70936. * @returns The engine the post process was enabled with.
  70937. */
  70938. getEngine(): Engine;
  70939. /**
  70940. * The effect that is created when initializing the post process.
  70941. * @returns The created effect corrisponding the the postprocess.
  70942. */
  70943. getEffect(): Effect;
  70944. /**
  70945. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  70946. * @param postProcess The post process to share the output with.
  70947. * @returns This post process.
  70948. */
  70949. shareOutputWith(postProcess: PostProcess): PostProcess;
  70950. /**
  70951. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  70952. * This should be called if the post process that shares output with this post process is disabled/disposed.
  70953. */
  70954. useOwnOutput(): void;
  70955. /**
  70956. * Updates the effect with the current post process compile time values and recompiles the shader.
  70957. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  70958. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  70959. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  70960. * @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
  70961. * @param onCompiled Called when the shader has been compiled.
  70962. * @param onError Called if there is an error when compiling a shader.
  70963. */
  70964. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  70965. /**
  70966. * The post process is reusable if it can be used multiple times within one frame.
  70967. * @returns If the post process is reusable
  70968. */
  70969. isReusable(): boolean;
  70970. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  70971. markTextureDirty(): void;
  70972. /**
  70973. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  70974. * 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.
  70975. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  70976. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  70977. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  70978. * @returns The target texture that was bound to be written to.
  70979. */
  70980. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  70981. /**
  70982. * If the post process is supported.
  70983. */
  70984. readonly isSupported: boolean;
  70985. /**
  70986. * The aspect ratio of the output texture.
  70987. */
  70988. readonly aspectRatio: number;
  70989. /**
  70990. * Get a value indicating if the post-process is ready to be used
  70991. * @returns true if the post-process is ready (shader is compiled)
  70992. */
  70993. isReady(): boolean;
  70994. /**
  70995. * Binds all textures and uniforms to the shader, this will be run on every pass.
  70996. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  70997. */
  70998. apply(): Nullable<Effect>;
  70999. private _disposeTextures;
  71000. /**
  71001. * Disposes the post process.
  71002. * @param camera The camera to dispose the post process on.
  71003. */
  71004. dispose(camera?: Camera): void;
  71005. }
  71006. }
  71007. declare module BABYLON {
  71008. /**
  71009. * PostProcessManager is used to manage one or more post processes or post process pipelines
  71010. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  71011. */
  71012. export class PostProcessManager {
  71013. private _scene;
  71014. private _indexBuffer;
  71015. private _vertexBuffers;
  71016. /**
  71017. * Creates a new instance PostProcess
  71018. * @param scene The scene that the post process is associated with.
  71019. */
  71020. constructor(scene: Scene);
  71021. private _prepareBuffers;
  71022. private _buildIndexBuffer;
  71023. /**
  71024. * Rebuilds the vertex buffers of the manager.
  71025. * @hidden
  71026. */
  71027. _rebuild(): void;
  71028. /**
  71029. * Prepares a frame to be run through a post process.
  71030. * @param sourceTexture The input texture to the post procesess. (default: null)
  71031. * @param postProcesses An array of post processes to be run. (default: null)
  71032. * @returns True if the post processes were able to be run.
  71033. * @hidden
  71034. */
  71035. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  71036. /**
  71037. * Manually render a set of post processes to a texture.
  71038. * @param postProcesses An array of post processes to be run.
  71039. * @param targetTexture The target texture to render to.
  71040. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  71041. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  71042. * @param lodLevel defines which lod of the texture to render to
  71043. */
  71044. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  71045. /**
  71046. * Finalize the result of the output of the postprocesses.
  71047. * @param doNotPresent If true the result will not be displayed to the screen.
  71048. * @param targetTexture The target texture to render to.
  71049. * @param faceIndex The index of the face to bind the target texture to.
  71050. * @param postProcesses The array of post processes to render.
  71051. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  71052. * @hidden
  71053. */
  71054. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  71055. /**
  71056. * Disposes of the post process manager.
  71057. */
  71058. dispose(): void;
  71059. }
  71060. }
  71061. declare module BABYLON {
  71062. interface AbstractScene {
  71063. /**
  71064. * The list of layers (background and foreground) of the scene
  71065. */
  71066. layers: Array<Layer>;
  71067. }
  71068. /**
  71069. * Defines the layer scene component responsible to manage any layers
  71070. * in a given scene.
  71071. */
  71072. export class LayerSceneComponent implements ISceneComponent {
  71073. /**
  71074. * The component name helpfull to identify the component in the list of scene components.
  71075. */
  71076. readonly name: string;
  71077. /**
  71078. * The scene the component belongs to.
  71079. */
  71080. scene: Scene;
  71081. private _engine;
  71082. /**
  71083. * Creates a new instance of the component for the given scene
  71084. * @param scene Defines the scene to register the component in
  71085. */
  71086. constructor(scene: Scene);
  71087. /**
  71088. * Registers the component in a given scene
  71089. */
  71090. register(): void;
  71091. /**
  71092. * Rebuilds the elements related to this component in case of
  71093. * context lost for instance.
  71094. */
  71095. rebuild(): void;
  71096. /**
  71097. * Disposes the component and the associated ressources.
  71098. */
  71099. dispose(): void;
  71100. private _draw;
  71101. private _drawCameraPredicate;
  71102. private _drawCameraBackground;
  71103. private _drawCameraForeground;
  71104. private _drawRenderTargetPredicate;
  71105. private _drawRenderTargetBackground;
  71106. private _drawRenderTargetForeground;
  71107. }
  71108. }
  71109. declare module BABYLON {
  71110. /** @hidden */
  71111. export var layerPixelShader: {
  71112. name: string;
  71113. shader: string;
  71114. };
  71115. }
  71116. declare module BABYLON {
  71117. /** @hidden */
  71118. export var layerVertexShader: {
  71119. name: string;
  71120. shader: string;
  71121. };
  71122. }
  71123. declare module BABYLON {
  71124. /**
  71125. * This represents a full screen 2d layer.
  71126. * This can be useful to display a picture in the background of your scene for instance.
  71127. * @see https://www.babylonjs-playground.com/#08A2BS#1
  71128. */
  71129. export class Layer {
  71130. /**
  71131. * Define the name of the layer.
  71132. */
  71133. name: string;
  71134. /**
  71135. * Define the texture the layer should display.
  71136. */
  71137. texture: Nullable<Texture>;
  71138. /**
  71139. * Is the layer in background or foreground.
  71140. */
  71141. isBackground: boolean;
  71142. /**
  71143. * Define the color of the layer (instead of texture).
  71144. */
  71145. color: Color4;
  71146. /**
  71147. * Define the scale of the layer in order to zoom in out of the texture.
  71148. */
  71149. scale: Vector2;
  71150. /**
  71151. * Define an offset for the layer in order to shift the texture.
  71152. */
  71153. offset: Vector2;
  71154. /**
  71155. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  71156. */
  71157. alphaBlendingMode: number;
  71158. /**
  71159. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  71160. * Alpha test will not mix with the background color in case of transparency.
  71161. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  71162. */
  71163. alphaTest: boolean;
  71164. /**
  71165. * Define a mask to restrict the layer to only some of the scene cameras.
  71166. */
  71167. layerMask: number;
  71168. /**
  71169. * Define the list of render target the layer is visible into.
  71170. */
  71171. renderTargetTextures: RenderTargetTexture[];
  71172. /**
  71173. * Define if the layer is only used in renderTarget or if it also
  71174. * renders in the main frame buffer of the canvas.
  71175. */
  71176. renderOnlyInRenderTargetTextures: boolean;
  71177. private _scene;
  71178. private _vertexBuffers;
  71179. private _indexBuffer;
  71180. private _effect;
  71181. private _alphaTestEffect;
  71182. /**
  71183. * An event triggered when the layer is disposed.
  71184. */
  71185. onDisposeObservable: Observable<Layer>;
  71186. private _onDisposeObserver;
  71187. /**
  71188. * Back compatibility with callback before the onDisposeObservable existed.
  71189. * The set callback will be triggered when the layer has been disposed.
  71190. */
  71191. onDispose: () => void;
  71192. /**
  71193. * An event triggered before rendering the scene
  71194. */
  71195. onBeforeRenderObservable: Observable<Layer>;
  71196. private _onBeforeRenderObserver;
  71197. /**
  71198. * Back compatibility with callback before the onBeforeRenderObservable existed.
  71199. * The set callback will be triggered just before rendering the layer.
  71200. */
  71201. onBeforeRender: () => void;
  71202. /**
  71203. * An event triggered after rendering the scene
  71204. */
  71205. onAfterRenderObservable: Observable<Layer>;
  71206. private _onAfterRenderObserver;
  71207. /**
  71208. * Back compatibility with callback before the onAfterRenderObservable existed.
  71209. * The set callback will be triggered just after rendering the layer.
  71210. */
  71211. onAfterRender: () => void;
  71212. /**
  71213. * Instantiates a new layer.
  71214. * This represents a full screen 2d layer.
  71215. * This can be useful to display a picture in the background of your scene for instance.
  71216. * @see https://www.babylonjs-playground.com/#08A2BS#1
  71217. * @param name Define the name of the layer in the scene
  71218. * @param imgUrl Define the url of the texture to display in the layer
  71219. * @param scene Define the scene the layer belongs to
  71220. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  71221. * @param color Defines a color for the layer
  71222. */
  71223. constructor(
  71224. /**
  71225. * Define the name of the layer.
  71226. */
  71227. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  71228. private _createIndexBuffer;
  71229. /** @hidden */
  71230. _rebuild(): void;
  71231. /**
  71232. * Renders the layer in the scene.
  71233. */
  71234. render(): void;
  71235. /**
  71236. * Disposes and releases the associated ressources.
  71237. */
  71238. dispose(): void;
  71239. }
  71240. }
  71241. declare module BABYLON {
  71242. interface AbstractScene {
  71243. /**
  71244. * The list of procedural textures added to the scene
  71245. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  71246. */
  71247. proceduralTextures: Array<ProceduralTexture>;
  71248. }
  71249. /**
  71250. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  71251. * in a given scene.
  71252. */
  71253. export class ProceduralTextureSceneComponent implements ISceneComponent {
  71254. /**
  71255. * The component name helpfull to identify the component in the list of scene components.
  71256. */
  71257. readonly name: string;
  71258. /**
  71259. * The scene the component belongs to.
  71260. */
  71261. scene: Scene;
  71262. /**
  71263. * Creates a new instance of the component for the given scene
  71264. * @param scene Defines the scene to register the component in
  71265. */
  71266. constructor(scene: Scene);
  71267. /**
  71268. * Registers the component in a given scene
  71269. */
  71270. register(): void;
  71271. /**
  71272. * Rebuilds the elements related to this component in case of
  71273. * context lost for instance.
  71274. */
  71275. rebuild(): void;
  71276. /**
  71277. * Disposes the component and the associated ressources.
  71278. */
  71279. dispose(): void;
  71280. private _beforeClear;
  71281. }
  71282. }
  71283. declare module BABYLON {
  71284. /** @hidden */
  71285. export var proceduralVertexShader: {
  71286. name: string;
  71287. shader: string;
  71288. };
  71289. }
  71290. declare module BABYLON {
  71291. /**
  71292. * 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.
  71293. * This is the base class of any Procedural texture and contains most of the shareable code.
  71294. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  71295. */
  71296. export class ProceduralTexture extends Texture {
  71297. isCube: boolean;
  71298. /**
  71299. * Define if the texture is enabled or not (disabled texture will not render)
  71300. */
  71301. isEnabled: boolean;
  71302. /**
  71303. * Define if the texture must be cleared before rendering (default is true)
  71304. */
  71305. autoClear: boolean;
  71306. /**
  71307. * Callback called when the texture is generated
  71308. */
  71309. onGenerated: () => void;
  71310. /**
  71311. * Event raised when the texture is generated
  71312. */
  71313. onGeneratedObservable: Observable<ProceduralTexture>;
  71314. /** @hidden */
  71315. _generateMipMaps: boolean;
  71316. /** @hidden **/
  71317. _effect: Effect;
  71318. /** @hidden */
  71319. _textures: {
  71320. [key: string]: Texture;
  71321. };
  71322. private _size;
  71323. private _currentRefreshId;
  71324. private _refreshRate;
  71325. private _vertexBuffers;
  71326. private _indexBuffer;
  71327. private _uniforms;
  71328. private _samplers;
  71329. private _fragment;
  71330. private _floats;
  71331. private _ints;
  71332. private _floatsArrays;
  71333. private _colors3;
  71334. private _colors4;
  71335. private _vectors2;
  71336. private _vectors3;
  71337. private _matrices;
  71338. private _fallbackTexture;
  71339. private _fallbackTextureUsed;
  71340. private _engine;
  71341. private _cachedDefines;
  71342. private _contentUpdateId;
  71343. private _contentData;
  71344. /**
  71345. * Instantiates a new procedural texture.
  71346. * 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.
  71347. * This is the base class of any Procedural texture and contains most of the shareable code.
  71348. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  71349. * @param name Define the name of the texture
  71350. * @param size Define the size of the texture to create
  71351. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  71352. * @param scene Define the scene the texture belongs to
  71353. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  71354. * @param generateMipMaps Define if the texture should creates mip maps or not
  71355. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  71356. */
  71357. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  71358. /**
  71359. * The effect that is created when initializing the post process.
  71360. * @returns The created effect corrisponding the the postprocess.
  71361. */
  71362. getEffect(): Effect;
  71363. /**
  71364. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  71365. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  71366. */
  71367. getContent(): Nullable<ArrayBufferView>;
  71368. private _createIndexBuffer;
  71369. /** @hidden */
  71370. _rebuild(): void;
  71371. /**
  71372. * Resets the texture in order to recreate its associated resources.
  71373. * This can be called in case of context loss
  71374. */
  71375. reset(): void;
  71376. protected _getDefines(): string;
  71377. /**
  71378. * Is the texture ready to be used ? (rendered at least once)
  71379. * @returns true if ready, otherwise, false.
  71380. */
  71381. isReady(): boolean;
  71382. /**
  71383. * Resets the refresh counter of the texture and start bak from scratch.
  71384. * Could be useful to regenerate the texture if it is setup to render only once.
  71385. */
  71386. resetRefreshCounter(): void;
  71387. /**
  71388. * Set the fragment shader to use in order to render the texture.
  71389. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  71390. */
  71391. setFragment(fragment: any): void;
  71392. /**
  71393. * Define the refresh rate of the texture or the rendering frequency.
  71394. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  71395. */
  71396. refreshRate: number;
  71397. /** @hidden */
  71398. _shouldRender(): boolean;
  71399. /**
  71400. * Get the size the texture is rendering at.
  71401. * @returns the size (texture is always squared)
  71402. */
  71403. getRenderSize(): number;
  71404. /**
  71405. * Resize the texture to new value.
  71406. * @param size Define the new size the texture should have
  71407. * @param generateMipMaps Define whether the new texture should create mip maps
  71408. */
  71409. resize(size: number, generateMipMaps: boolean): void;
  71410. private _checkUniform;
  71411. /**
  71412. * Set a texture in the shader program used to render.
  71413. * @param name Define the name of the uniform samplers as defined in the shader
  71414. * @param texture Define the texture to bind to this sampler
  71415. * @return the texture itself allowing "fluent" like uniform updates
  71416. */
  71417. setTexture(name: string, texture: Texture): ProceduralTexture;
  71418. /**
  71419. * Set a float in the shader.
  71420. * @param name Define the name of the uniform as defined in the shader
  71421. * @param value Define the value to give to the uniform
  71422. * @return the texture itself allowing "fluent" like uniform updates
  71423. */
  71424. setFloat(name: string, value: number): ProceduralTexture;
  71425. /**
  71426. * Set a int in the shader.
  71427. * @param name Define the name of the uniform as defined in the shader
  71428. * @param value Define the value to give to the uniform
  71429. * @return the texture itself allowing "fluent" like uniform updates
  71430. */
  71431. setInt(name: string, value: number): ProceduralTexture;
  71432. /**
  71433. * Set an array of floats in the shader.
  71434. * @param name Define the name of the uniform as defined in the shader
  71435. * @param value Define the value to give to the uniform
  71436. * @return the texture itself allowing "fluent" like uniform updates
  71437. */
  71438. setFloats(name: string, value: number[]): ProceduralTexture;
  71439. /**
  71440. * Set a vec3 in the shader from a Color3.
  71441. * @param name Define the name of the uniform as defined in the shader
  71442. * @param value Define the value to give to the uniform
  71443. * @return the texture itself allowing "fluent" like uniform updates
  71444. */
  71445. setColor3(name: string, value: Color3): ProceduralTexture;
  71446. /**
  71447. * Set a vec4 in the shader from a Color4.
  71448. * @param name Define the name of the uniform as defined in the shader
  71449. * @param value Define the value to give to the uniform
  71450. * @return the texture itself allowing "fluent" like uniform updates
  71451. */
  71452. setColor4(name: string, value: Color4): ProceduralTexture;
  71453. /**
  71454. * Set a vec2 in the shader from a Vector2.
  71455. * @param name Define the name of the uniform as defined in the shader
  71456. * @param value Define the value to give to the uniform
  71457. * @return the texture itself allowing "fluent" like uniform updates
  71458. */
  71459. setVector2(name: string, value: Vector2): ProceduralTexture;
  71460. /**
  71461. * Set a vec3 in the shader from a Vector3.
  71462. * @param name Define the name of the uniform as defined in the shader
  71463. * @param value Define the value to give to the uniform
  71464. * @return the texture itself allowing "fluent" like uniform updates
  71465. */
  71466. setVector3(name: string, value: Vector3): ProceduralTexture;
  71467. /**
  71468. * Set a mat4 in the shader from a MAtrix.
  71469. * @param name Define the name of the uniform as defined in the shader
  71470. * @param value Define the value to give to the uniform
  71471. * @return the texture itself allowing "fluent" like uniform updates
  71472. */
  71473. setMatrix(name: string, value: Matrix): ProceduralTexture;
  71474. /**
  71475. * Render the texture to its associated render target.
  71476. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  71477. */
  71478. render(useCameraPostProcess?: boolean): void;
  71479. /**
  71480. * Clone the texture.
  71481. * @returns the cloned texture
  71482. */
  71483. clone(): ProceduralTexture;
  71484. /**
  71485. * Dispose the texture and release its asoociated resources.
  71486. */
  71487. dispose(): void;
  71488. }
  71489. }
  71490. declare module BABYLON {
  71491. /**
  71492. * This represents the base class for particle system in Babylon.
  71493. * 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.
  71494. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  71495. * @example https://doc.babylonjs.com/babylon101/particles
  71496. */
  71497. export class BaseParticleSystem {
  71498. /**
  71499. * Source color is added to the destination color without alpha affecting the result
  71500. */
  71501. static BLENDMODE_ONEONE: number;
  71502. /**
  71503. * Blend current color and particle color using particle’s alpha
  71504. */
  71505. static BLENDMODE_STANDARD: number;
  71506. /**
  71507. * Add current color and particle color multiplied by particle’s alpha
  71508. */
  71509. static BLENDMODE_ADD: number;
  71510. /**
  71511. * Multiply current color with particle color
  71512. */
  71513. static BLENDMODE_MULTIPLY: number;
  71514. /**
  71515. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  71516. */
  71517. static BLENDMODE_MULTIPLYADD: number;
  71518. /**
  71519. * List of animations used by the particle system.
  71520. */
  71521. animations: Animation[];
  71522. /**
  71523. * The id of the Particle system.
  71524. */
  71525. id: string;
  71526. /**
  71527. * The friendly name of the Particle system.
  71528. */
  71529. name: string;
  71530. /**
  71531. * The rendering group used by the Particle system to chose when to render.
  71532. */
  71533. renderingGroupId: number;
  71534. /**
  71535. * The emitter represents the Mesh or position we are attaching the particle system to.
  71536. */
  71537. emitter: Nullable<AbstractMesh | Vector3>;
  71538. /**
  71539. * The maximum number of particles to emit per frame
  71540. */
  71541. emitRate: number;
  71542. /**
  71543. * If you want to launch only a few particles at once, that can be done, as well.
  71544. */
  71545. manualEmitCount: number;
  71546. /**
  71547. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  71548. */
  71549. updateSpeed: number;
  71550. /**
  71551. * The amount of time the particle system is running (depends of the overall update speed).
  71552. */
  71553. targetStopDuration: number;
  71554. /**
  71555. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  71556. */
  71557. disposeOnStop: boolean;
  71558. /**
  71559. * Minimum power of emitting particles.
  71560. */
  71561. minEmitPower: number;
  71562. /**
  71563. * Maximum power of emitting particles.
  71564. */
  71565. maxEmitPower: number;
  71566. /**
  71567. * Minimum life time of emitting particles.
  71568. */
  71569. minLifeTime: number;
  71570. /**
  71571. * Maximum life time of emitting particles.
  71572. */
  71573. maxLifeTime: number;
  71574. /**
  71575. * Minimum Size of emitting particles.
  71576. */
  71577. minSize: number;
  71578. /**
  71579. * Maximum Size of emitting particles.
  71580. */
  71581. maxSize: number;
  71582. /**
  71583. * Minimum scale of emitting particles on X axis.
  71584. */
  71585. minScaleX: number;
  71586. /**
  71587. * Maximum scale of emitting particles on X axis.
  71588. */
  71589. maxScaleX: number;
  71590. /**
  71591. * Minimum scale of emitting particles on Y axis.
  71592. */
  71593. minScaleY: number;
  71594. /**
  71595. * Maximum scale of emitting particles on Y axis.
  71596. */
  71597. maxScaleY: number;
  71598. /**
  71599. * Gets or sets the minimal initial rotation in radians.
  71600. */
  71601. minInitialRotation: number;
  71602. /**
  71603. * Gets or sets the maximal initial rotation in radians.
  71604. */
  71605. maxInitialRotation: number;
  71606. /**
  71607. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  71608. */
  71609. minAngularSpeed: number;
  71610. /**
  71611. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  71612. */
  71613. maxAngularSpeed: number;
  71614. /**
  71615. * The texture used to render each particle. (this can be a spritesheet)
  71616. */
  71617. particleTexture: Nullable<Texture>;
  71618. /**
  71619. * The layer mask we are rendering the particles through.
  71620. */
  71621. layerMask: number;
  71622. /**
  71623. * This can help using your own shader to render the particle system.
  71624. * The according effect will be created
  71625. */
  71626. customShader: any;
  71627. /**
  71628. * By default particle system starts as soon as they are created. This prevents the
  71629. * automatic start to happen and let you decide when to start emitting particles.
  71630. */
  71631. preventAutoStart: boolean;
  71632. private _noiseTexture;
  71633. /**
  71634. * Gets or sets a texture used to add random noise to particle positions
  71635. */
  71636. noiseTexture: Nullable<ProceduralTexture>;
  71637. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  71638. noiseStrength: Vector3;
  71639. /**
  71640. * Callback triggered when the particle animation is ending.
  71641. */
  71642. onAnimationEnd: Nullable<() => void>;
  71643. /**
  71644. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  71645. */
  71646. blendMode: number;
  71647. /**
  71648. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  71649. * to override the particles.
  71650. */
  71651. forceDepthWrite: boolean;
  71652. /** 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 */
  71653. preWarmCycles: number;
  71654. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  71655. preWarmStepOffset: number;
  71656. /**
  71657. * 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)
  71658. */
  71659. spriteCellChangeSpeed: number;
  71660. /**
  71661. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  71662. */
  71663. startSpriteCellID: number;
  71664. /**
  71665. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  71666. */
  71667. endSpriteCellID: number;
  71668. /**
  71669. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  71670. */
  71671. spriteCellWidth: number;
  71672. /**
  71673. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  71674. */
  71675. spriteCellHeight: number;
  71676. /**
  71677. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  71678. */
  71679. spriteRandomStartCell: boolean;
  71680. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  71681. translationPivot: Vector2;
  71682. /** @hidden */
  71683. protected _isAnimationSheetEnabled: boolean;
  71684. /**
  71685. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  71686. */
  71687. beginAnimationOnStart: boolean;
  71688. /**
  71689. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  71690. */
  71691. beginAnimationFrom: number;
  71692. /**
  71693. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  71694. */
  71695. beginAnimationTo: number;
  71696. /**
  71697. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  71698. */
  71699. beginAnimationLoop: boolean;
  71700. /**
  71701. * Gets or sets a world offset applied to all particles
  71702. */
  71703. worldOffset: Vector3;
  71704. /**
  71705. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  71706. */
  71707. isAnimationSheetEnabled: boolean;
  71708. /**
  71709. * Get hosting scene
  71710. * @returns the scene
  71711. */
  71712. getScene(): Scene;
  71713. /**
  71714. * You can use gravity if you want to give an orientation to your particles.
  71715. */
  71716. gravity: Vector3;
  71717. protected _colorGradients: Nullable<Array<ColorGradient>>;
  71718. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  71719. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  71720. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  71721. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  71722. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  71723. protected _dragGradients: Nullable<Array<FactorGradient>>;
  71724. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  71725. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  71726. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  71727. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  71728. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  71729. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  71730. /**
  71731. * Defines the delay in milliseconds before starting the system (0 by default)
  71732. */
  71733. startDelay: number;
  71734. /**
  71735. * Gets the current list of drag gradients.
  71736. * You must use addDragGradient and removeDragGradient to udpate this list
  71737. * @returns the list of drag gradients
  71738. */
  71739. getDragGradients(): Nullable<Array<FactorGradient>>;
  71740. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  71741. limitVelocityDamping: number;
  71742. /**
  71743. * Gets the current list of limit velocity gradients.
  71744. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  71745. * @returns the list of limit velocity gradients
  71746. */
  71747. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  71748. /**
  71749. * Gets the current list of color gradients.
  71750. * You must use addColorGradient and removeColorGradient to udpate this list
  71751. * @returns the list of color gradients
  71752. */
  71753. getColorGradients(): Nullable<Array<ColorGradient>>;
  71754. /**
  71755. * Gets the current list of size gradients.
  71756. * You must use addSizeGradient and removeSizeGradient to udpate this list
  71757. * @returns the list of size gradients
  71758. */
  71759. getSizeGradients(): Nullable<Array<FactorGradient>>;
  71760. /**
  71761. * Gets the current list of color remap gradients.
  71762. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  71763. * @returns the list of color remap gradients
  71764. */
  71765. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  71766. /**
  71767. * Gets the current list of alpha remap gradients.
  71768. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  71769. * @returns the list of alpha remap gradients
  71770. */
  71771. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  71772. /**
  71773. * Gets the current list of life time gradients.
  71774. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  71775. * @returns the list of life time gradients
  71776. */
  71777. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  71778. /**
  71779. * Gets the current list of angular speed gradients.
  71780. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  71781. * @returns the list of angular speed gradients
  71782. */
  71783. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  71784. /**
  71785. * Gets the current list of velocity gradients.
  71786. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  71787. * @returns the list of velocity gradients
  71788. */
  71789. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  71790. /**
  71791. * Gets the current list of start size gradients.
  71792. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  71793. * @returns the list of start size gradients
  71794. */
  71795. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  71796. /**
  71797. * Gets the current list of emit rate gradients.
  71798. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  71799. * @returns the list of emit rate gradients
  71800. */
  71801. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  71802. /**
  71803. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  71804. * This only works when particleEmitterTyps is a BoxParticleEmitter
  71805. */
  71806. direction1: Vector3;
  71807. /**
  71808. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  71809. * This only works when particleEmitterTyps is a BoxParticleEmitter
  71810. */
  71811. direction2: Vector3;
  71812. /**
  71813. * 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.
  71814. * This only works when particleEmitterTyps is a BoxParticleEmitter
  71815. */
  71816. minEmitBox: Vector3;
  71817. /**
  71818. * 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.
  71819. * This only works when particleEmitterTyps is a BoxParticleEmitter
  71820. */
  71821. maxEmitBox: Vector3;
  71822. /**
  71823. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  71824. */
  71825. color1: Color4;
  71826. /**
  71827. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  71828. */
  71829. color2: Color4;
  71830. /**
  71831. * Color the particle will have at the end of its lifetime
  71832. */
  71833. colorDead: Color4;
  71834. /**
  71835. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  71836. */
  71837. textureMask: Color4;
  71838. /**
  71839. * The particle emitter type defines the emitter used by the particle system.
  71840. * It can be for example box, sphere, or cone...
  71841. */
  71842. particleEmitterType: IParticleEmitterType;
  71843. /** @hidden */
  71844. _isSubEmitter: boolean;
  71845. /**
  71846. * Gets or sets the billboard mode to use when isBillboardBased = true.
  71847. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  71848. */
  71849. billboardMode: number;
  71850. protected _isBillboardBased: boolean;
  71851. /**
  71852. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  71853. */
  71854. isBillboardBased: boolean;
  71855. /**
  71856. * The scene the particle system belongs to.
  71857. */
  71858. protected _scene: Scene;
  71859. /**
  71860. * Local cache of defines for image processing.
  71861. */
  71862. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  71863. /**
  71864. * Default configuration related to image processing available in the standard Material.
  71865. */
  71866. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  71867. /**
  71868. * Gets the image processing configuration used either in this material.
  71869. */
  71870. /**
  71871. * Sets the Default image processing configuration used either in the this material.
  71872. *
  71873. * If sets to null, the scene one is in use.
  71874. */
  71875. imageProcessingConfiguration: ImageProcessingConfiguration;
  71876. /**
  71877. * Attaches a new image processing configuration to the Standard Material.
  71878. * @param configuration
  71879. */
  71880. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  71881. /** @hidden */
  71882. protected _reset(): void;
  71883. /** @hidden */
  71884. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  71885. /**
  71886. * Instantiates a particle system.
  71887. * 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.
  71888. * @param name The name of the particle system
  71889. */
  71890. constructor(name: string);
  71891. /**
  71892. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  71893. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  71894. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  71895. * @returns the emitter
  71896. */
  71897. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  71898. /**
  71899. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  71900. * @param radius The radius of the hemisphere to emit from
  71901. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  71902. * @returns the emitter
  71903. */
  71904. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  71905. /**
  71906. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  71907. * @param radius The radius of the sphere to emit from
  71908. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  71909. * @returns the emitter
  71910. */
  71911. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  71912. /**
  71913. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  71914. * @param radius The radius of the sphere to emit from
  71915. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  71916. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  71917. * @returns the emitter
  71918. */
  71919. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  71920. /**
  71921. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  71922. * @param radius The radius of the emission cylinder
  71923. * @param height The height of the emission cylinder
  71924. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  71925. * @param directionRandomizer How much to randomize the particle direction [0-1]
  71926. * @returns the emitter
  71927. */
  71928. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  71929. /**
  71930. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  71931. * @param radius The radius of the cylinder to emit from
  71932. * @param height The height of the emission cylinder
  71933. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  71934. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  71935. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  71936. * @returns the emitter
  71937. */
  71938. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  71939. /**
  71940. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  71941. * @param radius The radius of the cone to emit from
  71942. * @param angle The base angle of the cone
  71943. * @returns the emitter
  71944. */
  71945. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  71946. /**
  71947. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  71948. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  71949. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  71950. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  71951. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  71952. * @returns the emitter
  71953. */
  71954. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  71955. }
  71956. }
  71957. declare module BABYLON {
  71958. /**
  71959. * Type of sub emitter
  71960. */
  71961. export enum SubEmitterType {
  71962. /**
  71963. * Attached to the particle over it's lifetime
  71964. */
  71965. ATTACHED = 0,
  71966. /**
  71967. * Created when the particle dies
  71968. */
  71969. END = 1
  71970. }
  71971. /**
  71972. * Sub emitter class used to emit particles from an existing particle
  71973. */
  71974. export class SubEmitter {
  71975. /**
  71976. * the particle system to be used by the sub emitter
  71977. */
  71978. particleSystem: ParticleSystem;
  71979. /**
  71980. * Type of the submitter (Default: END)
  71981. */
  71982. type: SubEmitterType;
  71983. /**
  71984. * 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)
  71985. * Note: This only is supported when using an emitter of type Mesh
  71986. */
  71987. inheritDirection: boolean;
  71988. /**
  71989. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  71990. */
  71991. inheritedVelocityAmount: number;
  71992. /**
  71993. * Creates a sub emitter
  71994. * @param particleSystem the particle system to be used by the sub emitter
  71995. */
  71996. constructor(
  71997. /**
  71998. * the particle system to be used by the sub emitter
  71999. */
  72000. particleSystem: ParticleSystem);
  72001. /**
  72002. * Clones the sub emitter
  72003. * @returns the cloned sub emitter
  72004. */
  72005. clone(): SubEmitter;
  72006. /**
  72007. * Serialize current object to a JSON object
  72008. * @returns the serialized object
  72009. */
  72010. serialize(): any;
  72011. /** @hidden */
  72012. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  72013. /**
  72014. * Creates a new SubEmitter from a serialized JSON version
  72015. * @param serializationObject defines the JSON object to read from
  72016. * @param scene defines the hosting scene
  72017. * @param rootUrl defines the rootUrl for data loading
  72018. * @returns a new SubEmitter
  72019. */
  72020. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  72021. /** Release associated resources */
  72022. dispose(): void;
  72023. }
  72024. }
  72025. declare module BABYLON {
  72026. /** @hidden */
  72027. export var clipPlaneFragmentDeclaration: {
  72028. name: string;
  72029. shader: string;
  72030. };
  72031. }
  72032. declare module BABYLON {
  72033. /** @hidden */
  72034. export var imageProcessingDeclaration: {
  72035. name: string;
  72036. shader: string;
  72037. };
  72038. }
  72039. declare module BABYLON {
  72040. /** @hidden */
  72041. export var imageProcessingFunctions: {
  72042. name: string;
  72043. shader: string;
  72044. };
  72045. }
  72046. declare module BABYLON {
  72047. /** @hidden */
  72048. export var clipPlaneFragment: {
  72049. name: string;
  72050. shader: string;
  72051. };
  72052. }
  72053. declare module BABYLON {
  72054. /** @hidden */
  72055. export var particlesPixelShader: {
  72056. name: string;
  72057. shader: string;
  72058. };
  72059. }
  72060. declare module BABYLON {
  72061. /** @hidden */
  72062. export var clipPlaneVertexDeclaration: {
  72063. name: string;
  72064. shader: string;
  72065. };
  72066. }
  72067. declare module BABYLON {
  72068. /** @hidden */
  72069. export var clipPlaneVertex: {
  72070. name: string;
  72071. shader: string;
  72072. };
  72073. }
  72074. declare module BABYLON {
  72075. /** @hidden */
  72076. export var particlesVertexShader: {
  72077. name: string;
  72078. shader: string;
  72079. };
  72080. }
  72081. declare module BABYLON {
  72082. /**
  72083. * This represents a particle system in Babylon.
  72084. * 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.
  72085. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  72086. * @example https://doc.babylonjs.com/babylon101/particles
  72087. */
  72088. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  72089. /**
  72090. * Billboard mode will only apply to Y axis
  72091. */
  72092. static readonly BILLBOARDMODE_Y: number;
  72093. /**
  72094. * Billboard mode will apply to all axes
  72095. */
  72096. static readonly BILLBOARDMODE_ALL: number;
  72097. /**
  72098. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  72099. */
  72100. static readonly BILLBOARDMODE_STRETCHED: number;
  72101. /**
  72102. * This function can be defined to provide custom update for active particles.
  72103. * This function will be called instead of regular update (age, position, color, etc.).
  72104. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  72105. */
  72106. updateFunction: (particles: Particle[]) => void;
  72107. private _emitterWorldMatrix;
  72108. /**
  72109. * This function can be defined to specify initial direction for every new particle.
  72110. * It by default use the emitterType defined function
  72111. */
  72112. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  72113. /**
  72114. * This function can be defined to specify initial position for every new particle.
  72115. * It by default use the emitterType defined function
  72116. */
  72117. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  72118. /**
  72119. * @hidden
  72120. */
  72121. _inheritedVelocityOffset: Vector3;
  72122. /**
  72123. * An event triggered when the system is disposed
  72124. */
  72125. onDisposeObservable: Observable<ParticleSystem>;
  72126. private _onDisposeObserver;
  72127. /**
  72128. * Sets a callback that will be triggered when the system is disposed
  72129. */
  72130. onDispose: () => void;
  72131. private _particles;
  72132. private _epsilon;
  72133. private _capacity;
  72134. private _stockParticles;
  72135. private _newPartsExcess;
  72136. private _vertexData;
  72137. private _vertexBuffer;
  72138. private _vertexBuffers;
  72139. private _spriteBuffer;
  72140. private _indexBuffer;
  72141. private _effect;
  72142. private _customEffect;
  72143. private _cachedDefines;
  72144. private _scaledColorStep;
  72145. private _colorDiff;
  72146. private _scaledDirection;
  72147. private _scaledGravity;
  72148. private _currentRenderId;
  72149. private _alive;
  72150. private _useInstancing;
  72151. private _started;
  72152. private _stopped;
  72153. private _actualFrame;
  72154. private _scaledUpdateSpeed;
  72155. private _vertexBufferSize;
  72156. /** @hidden */
  72157. _currentEmitRateGradient: Nullable<FactorGradient>;
  72158. /** @hidden */
  72159. _currentEmitRate1: number;
  72160. /** @hidden */
  72161. _currentEmitRate2: number;
  72162. /** @hidden */
  72163. _currentStartSizeGradient: Nullable<FactorGradient>;
  72164. /** @hidden */
  72165. _currentStartSize1: number;
  72166. /** @hidden */
  72167. _currentStartSize2: number;
  72168. private readonly _rawTextureWidth;
  72169. private _rampGradientsTexture;
  72170. private _useRampGradients;
  72171. /** Gets or sets a boolean indicating that ramp gradients must be used
  72172. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  72173. */
  72174. useRampGradients: boolean;
  72175. /**
  72176. * 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.
  72177. * 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: [])
  72178. */
  72179. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  72180. private _subEmitters;
  72181. /**
  72182. * @hidden
  72183. * If the particle systems emitter should be disposed when the particle system is disposed
  72184. */
  72185. _disposeEmitterOnDispose: boolean;
  72186. /**
  72187. * The current active Sub-systems, this property is used by the root particle system only.
  72188. */
  72189. activeSubSystems: Array<ParticleSystem>;
  72190. private _rootParticleSystem;
  72191. /**
  72192. * Gets the current list of active particles
  72193. */
  72194. readonly particles: Particle[];
  72195. /**
  72196. * Returns the string "ParticleSystem"
  72197. * @returns a string containing the class name
  72198. */
  72199. getClassName(): string;
  72200. /**
  72201. * Instantiates a particle system.
  72202. * 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.
  72203. * @param name The name of the particle system
  72204. * @param capacity The max number of particles alive at the same time
  72205. * @param scene The scene the particle system belongs to
  72206. * @param customEffect a custom effect used to change the way particles are rendered by default
  72207. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  72208. * @param epsilon Offset used to render the particles
  72209. */
  72210. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  72211. private _addFactorGradient;
  72212. private _removeFactorGradient;
  72213. /**
  72214. * Adds a new life time gradient
  72215. * @param gradient defines the gradient to use (between 0 and 1)
  72216. * @param factor defines the life time factor to affect to the specified gradient
  72217. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72218. * @returns the current particle system
  72219. */
  72220. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72221. /**
  72222. * Remove a specific life time gradient
  72223. * @param gradient defines the gradient to remove
  72224. * @returns the current particle system
  72225. */
  72226. removeLifeTimeGradient(gradient: number): IParticleSystem;
  72227. /**
  72228. * Adds a new size gradient
  72229. * @param gradient defines the gradient to use (between 0 and 1)
  72230. * @param factor defines the size factor to affect to the specified gradient
  72231. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72232. * @returns the current particle system
  72233. */
  72234. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72235. /**
  72236. * Remove a specific size gradient
  72237. * @param gradient defines the gradient to remove
  72238. * @returns the current particle system
  72239. */
  72240. removeSizeGradient(gradient: number): IParticleSystem;
  72241. /**
  72242. * Adds a new color remap gradient
  72243. * @param gradient defines the gradient to use (between 0 and 1)
  72244. * @param min defines the color remap minimal range
  72245. * @param max defines the color remap maximal range
  72246. * @returns the current particle system
  72247. */
  72248. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  72249. /**
  72250. * Remove a specific color remap gradient
  72251. * @param gradient defines the gradient to remove
  72252. * @returns the current particle system
  72253. */
  72254. removeColorRemapGradient(gradient: number): IParticleSystem;
  72255. /**
  72256. * Adds a new alpha remap gradient
  72257. * @param gradient defines the gradient to use (between 0 and 1)
  72258. * @param min defines the alpha remap minimal range
  72259. * @param max defines the alpha remap maximal range
  72260. * @returns the current particle system
  72261. */
  72262. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  72263. /**
  72264. * Remove a specific alpha remap gradient
  72265. * @param gradient defines the gradient to remove
  72266. * @returns the current particle system
  72267. */
  72268. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  72269. /**
  72270. * Adds a new angular speed gradient
  72271. * @param gradient defines the gradient to use (between 0 and 1)
  72272. * @param factor defines the angular speed to affect to the specified gradient
  72273. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72274. * @returns the current particle system
  72275. */
  72276. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72277. /**
  72278. * Remove a specific angular speed gradient
  72279. * @param gradient defines the gradient to remove
  72280. * @returns the current particle system
  72281. */
  72282. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  72283. /**
  72284. * Adds a new velocity gradient
  72285. * @param gradient defines the gradient to use (between 0 and 1)
  72286. * @param factor defines the velocity to affect to the specified gradient
  72287. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72288. * @returns the current particle system
  72289. */
  72290. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72291. /**
  72292. * Remove a specific velocity gradient
  72293. * @param gradient defines the gradient to remove
  72294. * @returns the current particle system
  72295. */
  72296. removeVelocityGradient(gradient: number): IParticleSystem;
  72297. /**
  72298. * Adds a new limit velocity gradient
  72299. * @param gradient defines the gradient to use (between 0 and 1)
  72300. * @param factor defines the limit velocity value to affect to the specified gradient
  72301. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72302. * @returns the current particle system
  72303. */
  72304. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72305. /**
  72306. * Remove a specific limit velocity gradient
  72307. * @param gradient defines the gradient to remove
  72308. * @returns the current particle system
  72309. */
  72310. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  72311. /**
  72312. * Adds a new drag gradient
  72313. * @param gradient defines the gradient to use (between 0 and 1)
  72314. * @param factor defines the drag value to affect to the specified gradient
  72315. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72316. * @returns the current particle system
  72317. */
  72318. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72319. /**
  72320. * Remove a specific drag gradient
  72321. * @param gradient defines the gradient to remove
  72322. * @returns the current particle system
  72323. */
  72324. removeDragGradient(gradient: number): IParticleSystem;
  72325. /**
  72326. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  72327. * @param gradient defines the gradient to use (between 0 and 1)
  72328. * @param factor defines the emit rate value to affect to the specified gradient
  72329. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72330. * @returns the current particle system
  72331. */
  72332. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72333. /**
  72334. * Remove a specific emit rate gradient
  72335. * @param gradient defines the gradient to remove
  72336. * @returns the current particle system
  72337. */
  72338. removeEmitRateGradient(gradient: number): IParticleSystem;
  72339. /**
  72340. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  72341. * @param gradient defines the gradient to use (between 0 and 1)
  72342. * @param factor defines the start size value to affect to the specified gradient
  72343. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72344. * @returns the current particle system
  72345. */
  72346. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72347. /**
  72348. * Remove a specific start size gradient
  72349. * @param gradient defines the gradient to remove
  72350. * @returns the current particle system
  72351. */
  72352. removeStartSizeGradient(gradient: number): IParticleSystem;
  72353. private _createRampGradientTexture;
  72354. /**
  72355. * Gets the current list of ramp gradients.
  72356. * You must use addRampGradient and removeRampGradient to udpate this list
  72357. * @returns the list of ramp gradients
  72358. */
  72359. getRampGradients(): Nullable<Array<Color3Gradient>>;
  72360. /**
  72361. * Adds a new ramp gradient used to remap particle colors
  72362. * @param gradient defines the gradient to use (between 0 and 1)
  72363. * @param color defines the color to affect to the specified gradient
  72364. * @returns the current particle system
  72365. */
  72366. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  72367. /**
  72368. * Remove a specific ramp gradient
  72369. * @param gradient defines the gradient to remove
  72370. * @returns the current particle system
  72371. */
  72372. removeRampGradient(gradient: number): ParticleSystem;
  72373. /**
  72374. * Adds a new color gradient
  72375. * @param gradient defines the gradient to use (between 0 and 1)
  72376. * @param color1 defines the color to affect to the specified gradient
  72377. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  72378. * @returns this particle system
  72379. */
  72380. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  72381. /**
  72382. * Remove a specific color gradient
  72383. * @param gradient defines the gradient to remove
  72384. * @returns this particle system
  72385. */
  72386. removeColorGradient(gradient: number): IParticleSystem;
  72387. private _fetchR;
  72388. protected _reset(): void;
  72389. private _resetEffect;
  72390. private _createVertexBuffers;
  72391. private _createIndexBuffer;
  72392. /**
  72393. * Gets the maximum number of particles active at the same time.
  72394. * @returns The max number of active particles.
  72395. */
  72396. getCapacity(): number;
  72397. /**
  72398. * Gets whether there are still active particles in the system.
  72399. * @returns True if it is alive, otherwise false.
  72400. */
  72401. isAlive(): boolean;
  72402. /**
  72403. * Gets if the system has been started. (Note: this will still be true after stop is called)
  72404. * @returns True if it has been started, otherwise false.
  72405. */
  72406. isStarted(): boolean;
  72407. private _prepareSubEmitterInternalArray;
  72408. /**
  72409. * Starts the particle system and begins to emit
  72410. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  72411. */
  72412. start(delay?: number): void;
  72413. /**
  72414. * Stops the particle system.
  72415. * @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.
  72416. */
  72417. stop(stopSubEmitters?: boolean): void;
  72418. /**
  72419. * Remove all active particles
  72420. */
  72421. reset(): void;
  72422. /**
  72423. * @hidden (for internal use only)
  72424. */
  72425. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  72426. /**
  72427. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  72428. * Its lifetime will start back at 0.
  72429. */
  72430. recycleParticle: (particle: Particle) => void;
  72431. private _stopSubEmitters;
  72432. private _createParticle;
  72433. private _removeFromRoot;
  72434. private _emitFromParticle;
  72435. private _update;
  72436. /** @hidden */
  72437. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  72438. /** @hidden */
  72439. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  72440. /** @hidden */
  72441. private _getEffect;
  72442. /**
  72443. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  72444. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  72445. */
  72446. animate(preWarmOnly?: boolean): void;
  72447. private _appendParticleVertices;
  72448. /**
  72449. * Rebuilds the particle system.
  72450. */
  72451. rebuild(): void;
  72452. /**
  72453. * Is this system ready to be used/rendered
  72454. * @return true if the system is ready
  72455. */
  72456. isReady(): boolean;
  72457. private _render;
  72458. /**
  72459. * Renders the particle system in its current state.
  72460. * @returns the current number of particles
  72461. */
  72462. render(): number;
  72463. /**
  72464. * Disposes the particle system and free the associated resources
  72465. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  72466. */
  72467. dispose(disposeTexture?: boolean): void;
  72468. /**
  72469. * Clones the particle system.
  72470. * @param name The name of the cloned object
  72471. * @param newEmitter The new emitter to use
  72472. * @returns the cloned particle system
  72473. */
  72474. clone(name: string, newEmitter: any): ParticleSystem;
  72475. /**
  72476. * Serializes the particle system to a JSON object.
  72477. * @returns the JSON object
  72478. */
  72479. serialize(): any;
  72480. /** @hidden */
  72481. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  72482. /** @hidden */
  72483. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  72484. /**
  72485. * Parses a JSON object to create a particle system.
  72486. * @param parsedParticleSystem The JSON object to parse
  72487. * @param scene The scene to create the particle system in
  72488. * @param rootUrl The root url to use to load external dependencies like texture
  72489. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  72490. * @returns the Parsed particle system
  72491. */
  72492. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  72493. }
  72494. }
  72495. declare module BABYLON {
  72496. /**
  72497. * A particle represents one of the element emitted by a particle system.
  72498. * This is mainly define by its coordinates, direction, velocity and age.
  72499. */
  72500. export class Particle {
  72501. /**
  72502. * The particle system the particle belongs to.
  72503. */
  72504. particleSystem: ParticleSystem;
  72505. private static _Count;
  72506. /**
  72507. * Unique ID of the particle
  72508. */
  72509. id: number;
  72510. /**
  72511. * The world position of the particle in the scene.
  72512. */
  72513. position: Vector3;
  72514. /**
  72515. * The world direction of the particle in the scene.
  72516. */
  72517. direction: Vector3;
  72518. /**
  72519. * The color of the particle.
  72520. */
  72521. color: Color4;
  72522. /**
  72523. * The color change of the particle per step.
  72524. */
  72525. colorStep: Color4;
  72526. /**
  72527. * Defines how long will the life of the particle be.
  72528. */
  72529. lifeTime: number;
  72530. /**
  72531. * The current age of the particle.
  72532. */
  72533. age: number;
  72534. /**
  72535. * The current size of the particle.
  72536. */
  72537. size: number;
  72538. /**
  72539. * The current scale of the particle.
  72540. */
  72541. scale: Vector2;
  72542. /**
  72543. * The current angle of the particle.
  72544. */
  72545. angle: number;
  72546. /**
  72547. * Defines how fast is the angle changing.
  72548. */
  72549. angularSpeed: number;
  72550. /**
  72551. * Defines the cell index used by the particle to be rendered from a sprite.
  72552. */
  72553. cellIndex: number;
  72554. /**
  72555. * The information required to support color remapping
  72556. */
  72557. remapData: Vector4;
  72558. /** @hidden */
  72559. _randomCellOffset?: number;
  72560. /** @hidden */
  72561. _initialDirection: Nullable<Vector3>;
  72562. /** @hidden */
  72563. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  72564. /** @hidden */
  72565. _initialStartSpriteCellID: number;
  72566. /** @hidden */
  72567. _initialEndSpriteCellID: number;
  72568. /** @hidden */
  72569. _currentColorGradient: Nullable<ColorGradient>;
  72570. /** @hidden */
  72571. _currentColor1: Color4;
  72572. /** @hidden */
  72573. _currentColor2: Color4;
  72574. /** @hidden */
  72575. _currentSizeGradient: Nullable<FactorGradient>;
  72576. /** @hidden */
  72577. _currentSize1: number;
  72578. /** @hidden */
  72579. _currentSize2: number;
  72580. /** @hidden */
  72581. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  72582. /** @hidden */
  72583. _currentAngularSpeed1: number;
  72584. /** @hidden */
  72585. _currentAngularSpeed2: number;
  72586. /** @hidden */
  72587. _currentVelocityGradient: Nullable<FactorGradient>;
  72588. /** @hidden */
  72589. _currentVelocity1: number;
  72590. /** @hidden */
  72591. _currentVelocity2: number;
  72592. /** @hidden */
  72593. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  72594. /** @hidden */
  72595. _currentLimitVelocity1: number;
  72596. /** @hidden */
  72597. _currentLimitVelocity2: number;
  72598. /** @hidden */
  72599. _currentDragGradient: Nullable<FactorGradient>;
  72600. /** @hidden */
  72601. _currentDrag1: number;
  72602. /** @hidden */
  72603. _currentDrag2: number;
  72604. /** @hidden */
  72605. _randomNoiseCoordinates1: Vector3;
  72606. /** @hidden */
  72607. _randomNoiseCoordinates2: Vector3;
  72608. /**
  72609. * Creates a new instance Particle
  72610. * @param particleSystem the particle system the particle belongs to
  72611. */
  72612. constructor(
  72613. /**
  72614. * The particle system the particle belongs to.
  72615. */
  72616. particleSystem: ParticleSystem);
  72617. private updateCellInfoFromSystem;
  72618. /**
  72619. * Defines how the sprite cell index is updated for the particle
  72620. */
  72621. updateCellIndex(): void;
  72622. /** @hidden */
  72623. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  72624. /** @hidden */
  72625. _inheritParticleInfoToSubEmitters(): void;
  72626. /** @hidden */
  72627. _reset(): void;
  72628. /**
  72629. * Copy the properties of particle to another one.
  72630. * @param other the particle to copy the information to.
  72631. */
  72632. copyTo(other: Particle): void;
  72633. }
  72634. }
  72635. declare module BABYLON {
  72636. /**
  72637. * Particle emitter represents a volume emitting particles.
  72638. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  72639. */
  72640. export interface IParticleEmitterType {
  72641. /**
  72642. * Called by the particle System when the direction is computed for the created particle.
  72643. * @param worldMatrix is the world matrix of the particle system
  72644. * @param directionToUpdate is the direction vector to update with the result
  72645. * @param particle is the particle we are computed the direction for
  72646. */
  72647. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  72648. /**
  72649. * Called by the particle System when the position is computed for the created particle.
  72650. * @param worldMatrix is the world matrix of the particle system
  72651. * @param positionToUpdate is the position vector to update with the result
  72652. * @param particle is the particle we are computed the position for
  72653. */
  72654. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  72655. /**
  72656. * Clones the current emitter and returns a copy of it
  72657. * @returns the new emitter
  72658. */
  72659. clone(): IParticleEmitterType;
  72660. /**
  72661. * Called by the GPUParticleSystem to setup the update shader
  72662. * @param effect defines the update shader
  72663. */
  72664. applyToShader(effect: Effect): void;
  72665. /**
  72666. * Returns a string to use to update the GPU particles update shader
  72667. * @returns the effect defines string
  72668. */
  72669. getEffectDefines(): string;
  72670. /**
  72671. * Returns a string representing the class name
  72672. * @returns a string containing the class name
  72673. */
  72674. getClassName(): string;
  72675. /**
  72676. * Serializes the particle system to a JSON object.
  72677. * @returns the JSON object
  72678. */
  72679. serialize(): any;
  72680. /**
  72681. * Parse properties from a JSON object
  72682. * @param serializationObject defines the JSON object
  72683. */
  72684. parse(serializationObject: any): void;
  72685. }
  72686. }
  72687. declare module BABYLON {
  72688. /**
  72689. * Particle emitter emitting particles from the inside of a box.
  72690. * It emits the particles randomly between 2 given directions.
  72691. */
  72692. export class BoxParticleEmitter implements IParticleEmitterType {
  72693. /**
  72694. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  72695. */
  72696. direction1: Vector3;
  72697. /**
  72698. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  72699. */
  72700. direction2: Vector3;
  72701. /**
  72702. * 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.
  72703. */
  72704. minEmitBox: Vector3;
  72705. /**
  72706. * 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.
  72707. */
  72708. maxEmitBox: Vector3;
  72709. /**
  72710. * Creates a new instance BoxParticleEmitter
  72711. */
  72712. constructor();
  72713. /**
  72714. * Called by the particle System when the direction is computed for the created particle.
  72715. * @param worldMatrix is the world matrix of the particle system
  72716. * @param directionToUpdate is the direction vector to update with the result
  72717. * @param particle is the particle we are computed the direction for
  72718. */
  72719. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  72720. /**
  72721. * Called by the particle System when the position is computed for the created particle.
  72722. * @param worldMatrix is the world matrix of the particle system
  72723. * @param positionToUpdate is the position vector to update with the result
  72724. * @param particle is the particle we are computed the position for
  72725. */
  72726. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  72727. /**
  72728. * Clones the current emitter and returns a copy of it
  72729. * @returns the new emitter
  72730. */
  72731. clone(): BoxParticleEmitter;
  72732. /**
  72733. * Called by the GPUParticleSystem to setup the update shader
  72734. * @param effect defines the update shader
  72735. */
  72736. applyToShader(effect: Effect): void;
  72737. /**
  72738. * Returns a string to use to update the GPU particles update shader
  72739. * @returns a string containng the defines string
  72740. */
  72741. getEffectDefines(): string;
  72742. /**
  72743. * Returns the string "BoxParticleEmitter"
  72744. * @returns a string containing the class name
  72745. */
  72746. getClassName(): string;
  72747. /**
  72748. * Serializes the particle system to a JSON object.
  72749. * @returns the JSON object
  72750. */
  72751. serialize(): any;
  72752. /**
  72753. * Parse properties from a JSON object
  72754. * @param serializationObject defines the JSON object
  72755. */
  72756. parse(serializationObject: any): void;
  72757. }
  72758. }
  72759. declare module BABYLON {
  72760. /**
  72761. * Particle emitter emitting particles from the inside of a cone.
  72762. * It emits the particles alongside the cone volume from the base to the particle.
  72763. * The emission direction might be randomized.
  72764. */
  72765. export class ConeParticleEmitter implements IParticleEmitterType {
  72766. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  72767. directionRandomizer: number;
  72768. private _radius;
  72769. private _angle;
  72770. private _height;
  72771. /**
  72772. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  72773. */
  72774. radiusRange: number;
  72775. /**
  72776. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  72777. */
  72778. heightRange: number;
  72779. /**
  72780. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  72781. */
  72782. emitFromSpawnPointOnly: boolean;
  72783. /**
  72784. * Gets or sets the radius of the emission cone
  72785. */
  72786. radius: number;
  72787. /**
  72788. * Gets or sets the angle of the emission cone
  72789. */
  72790. angle: number;
  72791. private _buildHeight;
  72792. /**
  72793. * Creates a new instance ConeParticleEmitter
  72794. * @param radius the radius of the emission cone (1 by default)
  72795. * @param angle the cone base angle (PI by default)
  72796. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  72797. */
  72798. constructor(radius?: number, angle?: number,
  72799. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  72800. directionRandomizer?: number);
  72801. /**
  72802. * Called by the particle System when the direction is computed for the created particle.
  72803. * @param worldMatrix is the world matrix of the particle system
  72804. * @param directionToUpdate is the direction vector to update with the result
  72805. * @param particle is the particle we are computed the direction for
  72806. */
  72807. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  72808. /**
  72809. * Called by the particle System when the position is computed for the created particle.
  72810. * @param worldMatrix is the world matrix of the particle system
  72811. * @param positionToUpdate is the position vector to update with the result
  72812. * @param particle is the particle we are computed the position for
  72813. */
  72814. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  72815. /**
  72816. * Clones the current emitter and returns a copy of it
  72817. * @returns the new emitter
  72818. */
  72819. clone(): ConeParticleEmitter;
  72820. /**
  72821. * Called by the GPUParticleSystem to setup the update shader
  72822. * @param effect defines the update shader
  72823. */
  72824. applyToShader(effect: Effect): void;
  72825. /**
  72826. * Returns a string to use to update the GPU particles update shader
  72827. * @returns a string containng the defines string
  72828. */
  72829. getEffectDefines(): string;
  72830. /**
  72831. * Returns the string "ConeParticleEmitter"
  72832. * @returns a string containing the class name
  72833. */
  72834. getClassName(): string;
  72835. /**
  72836. * Serializes the particle system to a JSON object.
  72837. * @returns the JSON object
  72838. */
  72839. serialize(): any;
  72840. /**
  72841. * Parse properties from a JSON object
  72842. * @param serializationObject defines the JSON object
  72843. */
  72844. parse(serializationObject: any): void;
  72845. }
  72846. }
  72847. declare module BABYLON {
  72848. /**
  72849. * Particle emitter emitting particles from the inside of a cylinder.
  72850. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  72851. */
  72852. export class CylinderParticleEmitter implements IParticleEmitterType {
  72853. /**
  72854. * The radius of the emission cylinder.
  72855. */
  72856. radius: number;
  72857. /**
  72858. * The height of the emission cylinder.
  72859. */
  72860. height: number;
  72861. /**
  72862. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  72863. */
  72864. radiusRange: number;
  72865. /**
  72866. * How much to randomize the particle direction [0-1].
  72867. */
  72868. directionRandomizer: number;
  72869. /**
  72870. * Creates a new instance CylinderParticleEmitter
  72871. * @param radius the radius of the emission cylinder (1 by default)
  72872. * @param height the height of the emission cylinder (1 by default)
  72873. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  72874. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  72875. */
  72876. constructor(
  72877. /**
  72878. * The radius of the emission cylinder.
  72879. */
  72880. radius?: number,
  72881. /**
  72882. * The height of the emission cylinder.
  72883. */
  72884. height?: number,
  72885. /**
  72886. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  72887. */
  72888. radiusRange?: number,
  72889. /**
  72890. * How much to randomize the particle direction [0-1].
  72891. */
  72892. directionRandomizer?: number);
  72893. /**
  72894. * Called by the particle System when the direction is computed for the created particle.
  72895. * @param worldMatrix is the world matrix of the particle system
  72896. * @param directionToUpdate is the direction vector to update with the result
  72897. * @param particle is the particle we are computed the direction for
  72898. */
  72899. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  72900. /**
  72901. * Called by the particle System when the position is computed for the created particle.
  72902. * @param worldMatrix is the world matrix of the particle system
  72903. * @param positionToUpdate is the position vector to update with the result
  72904. * @param particle is the particle we are computed the position for
  72905. */
  72906. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  72907. /**
  72908. * Clones the current emitter and returns a copy of it
  72909. * @returns the new emitter
  72910. */
  72911. clone(): CylinderParticleEmitter;
  72912. /**
  72913. * Called by the GPUParticleSystem to setup the update shader
  72914. * @param effect defines the update shader
  72915. */
  72916. applyToShader(effect: Effect): void;
  72917. /**
  72918. * Returns a string to use to update the GPU particles update shader
  72919. * @returns a string containng the defines string
  72920. */
  72921. getEffectDefines(): string;
  72922. /**
  72923. * Returns the string "CylinderParticleEmitter"
  72924. * @returns a string containing the class name
  72925. */
  72926. getClassName(): string;
  72927. /**
  72928. * Serializes the particle system to a JSON object.
  72929. * @returns the JSON object
  72930. */
  72931. serialize(): any;
  72932. /**
  72933. * Parse properties from a JSON object
  72934. * @param serializationObject defines the JSON object
  72935. */
  72936. parse(serializationObject: any): void;
  72937. }
  72938. /**
  72939. * Particle emitter emitting particles from the inside of a cylinder.
  72940. * It emits the particles randomly between two vectors.
  72941. */
  72942. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  72943. /**
  72944. * The min limit of the emission direction.
  72945. */
  72946. direction1: Vector3;
  72947. /**
  72948. * The max limit of the emission direction.
  72949. */
  72950. direction2: Vector3;
  72951. /**
  72952. * Creates a new instance CylinderDirectedParticleEmitter
  72953. * @param radius the radius of the emission cylinder (1 by default)
  72954. * @param height the height of the emission cylinder (1 by default)
  72955. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  72956. * @param direction1 the min limit of the emission direction (up vector by default)
  72957. * @param direction2 the max limit of the emission direction (up vector by default)
  72958. */
  72959. constructor(radius?: number, height?: number, radiusRange?: number,
  72960. /**
  72961. * The min limit of the emission direction.
  72962. */
  72963. direction1?: Vector3,
  72964. /**
  72965. * The max limit of the emission direction.
  72966. */
  72967. direction2?: Vector3);
  72968. /**
  72969. * Called by the particle System when the direction is computed for the created particle.
  72970. * @param worldMatrix is the world matrix of the particle system
  72971. * @param directionToUpdate is the direction vector to update with the result
  72972. * @param particle is the particle we are computed the direction for
  72973. */
  72974. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  72975. /**
  72976. * Clones the current emitter and returns a copy of it
  72977. * @returns the new emitter
  72978. */
  72979. clone(): CylinderDirectedParticleEmitter;
  72980. /**
  72981. * Called by the GPUParticleSystem to setup the update shader
  72982. * @param effect defines the update shader
  72983. */
  72984. applyToShader(effect: Effect): void;
  72985. /**
  72986. * Returns a string to use to update the GPU particles update shader
  72987. * @returns a string containng the defines string
  72988. */
  72989. getEffectDefines(): string;
  72990. /**
  72991. * Returns the string "CylinderDirectedParticleEmitter"
  72992. * @returns a string containing the class name
  72993. */
  72994. getClassName(): string;
  72995. /**
  72996. * Serializes the particle system to a JSON object.
  72997. * @returns the JSON object
  72998. */
  72999. serialize(): any;
  73000. /**
  73001. * Parse properties from a JSON object
  73002. * @param serializationObject defines the JSON object
  73003. */
  73004. parse(serializationObject: any): void;
  73005. }
  73006. }
  73007. declare module BABYLON {
  73008. /**
  73009. * Particle emitter emitting particles from the inside of a hemisphere.
  73010. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  73011. */
  73012. export class HemisphericParticleEmitter implements IParticleEmitterType {
  73013. /**
  73014. * The radius of the emission hemisphere.
  73015. */
  73016. radius: number;
  73017. /**
  73018. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  73019. */
  73020. radiusRange: number;
  73021. /**
  73022. * How much to randomize the particle direction [0-1].
  73023. */
  73024. directionRandomizer: number;
  73025. /**
  73026. * Creates a new instance HemisphericParticleEmitter
  73027. * @param radius the radius of the emission hemisphere (1 by default)
  73028. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  73029. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  73030. */
  73031. constructor(
  73032. /**
  73033. * The radius of the emission hemisphere.
  73034. */
  73035. radius?: number,
  73036. /**
  73037. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  73038. */
  73039. radiusRange?: number,
  73040. /**
  73041. * How much to randomize the particle direction [0-1].
  73042. */
  73043. directionRandomizer?: number);
  73044. /**
  73045. * Called by the particle System when the direction is computed for the created particle.
  73046. * @param worldMatrix is the world matrix of the particle system
  73047. * @param directionToUpdate is the direction vector to update with the result
  73048. * @param particle is the particle we are computed the direction for
  73049. */
  73050. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  73051. /**
  73052. * Called by the particle System when the position is computed for the created particle.
  73053. * @param worldMatrix is the world matrix of the particle system
  73054. * @param positionToUpdate is the position vector to update with the result
  73055. * @param particle is the particle we are computed the position for
  73056. */
  73057. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  73058. /**
  73059. * Clones the current emitter and returns a copy of it
  73060. * @returns the new emitter
  73061. */
  73062. clone(): HemisphericParticleEmitter;
  73063. /**
  73064. * Called by the GPUParticleSystem to setup the update shader
  73065. * @param effect defines the update shader
  73066. */
  73067. applyToShader(effect: Effect): void;
  73068. /**
  73069. * Returns a string to use to update the GPU particles update shader
  73070. * @returns a string containng the defines string
  73071. */
  73072. getEffectDefines(): string;
  73073. /**
  73074. * Returns the string "HemisphericParticleEmitter"
  73075. * @returns a string containing the class name
  73076. */
  73077. getClassName(): string;
  73078. /**
  73079. * Serializes the particle system to a JSON object.
  73080. * @returns the JSON object
  73081. */
  73082. serialize(): any;
  73083. /**
  73084. * Parse properties from a JSON object
  73085. * @param serializationObject defines the JSON object
  73086. */
  73087. parse(serializationObject: any): void;
  73088. }
  73089. }
  73090. declare module BABYLON {
  73091. /**
  73092. * Particle emitter emitting particles from a point.
  73093. * It emits the particles randomly between 2 given directions.
  73094. */
  73095. export class PointParticleEmitter implements IParticleEmitterType {
  73096. /**
  73097. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  73098. */
  73099. direction1: Vector3;
  73100. /**
  73101. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  73102. */
  73103. direction2: Vector3;
  73104. /**
  73105. * Creates a new instance PointParticleEmitter
  73106. */
  73107. constructor();
  73108. /**
  73109. * Called by the particle System when the direction is computed for the created particle.
  73110. * @param worldMatrix is the world matrix of the particle system
  73111. * @param directionToUpdate is the direction vector to update with the result
  73112. * @param particle is the particle we are computed the direction for
  73113. */
  73114. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  73115. /**
  73116. * Called by the particle System when the position is computed for the created particle.
  73117. * @param worldMatrix is the world matrix of the particle system
  73118. * @param positionToUpdate is the position vector to update with the result
  73119. * @param particle is the particle we are computed the position for
  73120. */
  73121. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  73122. /**
  73123. * Clones the current emitter and returns a copy of it
  73124. * @returns the new emitter
  73125. */
  73126. clone(): PointParticleEmitter;
  73127. /**
  73128. * Called by the GPUParticleSystem to setup the update shader
  73129. * @param effect defines the update shader
  73130. */
  73131. applyToShader(effect: Effect): void;
  73132. /**
  73133. * Returns a string to use to update the GPU particles update shader
  73134. * @returns a string containng the defines string
  73135. */
  73136. getEffectDefines(): string;
  73137. /**
  73138. * Returns the string "PointParticleEmitter"
  73139. * @returns a string containing the class name
  73140. */
  73141. getClassName(): string;
  73142. /**
  73143. * Serializes the particle system to a JSON object.
  73144. * @returns the JSON object
  73145. */
  73146. serialize(): any;
  73147. /**
  73148. * Parse properties from a JSON object
  73149. * @param serializationObject defines the JSON object
  73150. */
  73151. parse(serializationObject: any): void;
  73152. }
  73153. }
  73154. declare module BABYLON {
  73155. /**
  73156. * Particle emitter emitting particles from the inside of a sphere.
  73157. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  73158. */
  73159. export class SphereParticleEmitter implements IParticleEmitterType {
  73160. /**
  73161. * The radius of the emission sphere.
  73162. */
  73163. radius: number;
  73164. /**
  73165. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  73166. */
  73167. radiusRange: number;
  73168. /**
  73169. * How much to randomize the particle direction [0-1].
  73170. */
  73171. directionRandomizer: number;
  73172. /**
  73173. * Creates a new instance SphereParticleEmitter
  73174. * @param radius the radius of the emission sphere (1 by default)
  73175. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  73176. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  73177. */
  73178. constructor(
  73179. /**
  73180. * The radius of the emission sphere.
  73181. */
  73182. radius?: number,
  73183. /**
  73184. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  73185. */
  73186. radiusRange?: number,
  73187. /**
  73188. * How much to randomize the particle direction [0-1].
  73189. */
  73190. directionRandomizer?: number);
  73191. /**
  73192. * Called by the particle System when the direction is computed for the created particle.
  73193. * @param worldMatrix is the world matrix of the particle system
  73194. * @param directionToUpdate is the direction vector to update with the result
  73195. * @param particle is the particle we are computed the direction for
  73196. */
  73197. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  73198. /**
  73199. * Called by the particle System when the position is computed for the created particle.
  73200. * @param worldMatrix is the world matrix of the particle system
  73201. * @param positionToUpdate is the position vector to update with the result
  73202. * @param particle is the particle we are computed the position for
  73203. */
  73204. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  73205. /**
  73206. * Clones the current emitter and returns a copy of it
  73207. * @returns the new emitter
  73208. */
  73209. clone(): SphereParticleEmitter;
  73210. /**
  73211. * Called by the GPUParticleSystem to setup the update shader
  73212. * @param effect defines the update shader
  73213. */
  73214. applyToShader(effect: Effect): void;
  73215. /**
  73216. * Returns a string to use to update the GPU particles update shader
  73217. * @returns a string containng the defines string
  73218. */
  73219. getEffectDefines(): string;
  73220. /**
  73221. * Returns the string "SphereParticleEmitter"
  73222. * @returns a string containing the class name
  73223. */
  73224. getClassName(): string;
  73225. /**
  73226. * Serializes the particle system to a JSON object.
  73227. * @returns the JSON object
  73228. */
  73229. serialize(): any;
  73230. /**
  73231. * Parse properties from a JSON object
  73232. * @param serializationObject defines the JSON object
  73233. */
  73234. parse(serializationObject: any): void;
  73235. }
  73236. /**
  73237. * Particle emitter emitting particles from the inside of a sphere.
  73238. * It emits the particles randomly between two vectors.
  73239. */
  73240. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  73241. /**
  73242. * The min limit of the emission direction.
  73243. */
  73244. direction1: Vector3;
  73245. /**
  73246. * The max limit of the emission direction.
  73247. */
  73248. direction2: Vector3;
  73249. /**
  73250. * Creates a new instance SphereDirectedParticleEmitter
  73251. * @param radius the radius of the emission sphere (1 by default)
  73252. * @param direction1 the min limit of the emission direction (up vector by default)
  73253. * @param direction2 the max limit of the emission direction (up vector by default)
  73254. */
  73255. constructor(radius?: number,
  73256. /**
  73257. * The min limit of the emission direction.
  73258. */
  73259. direction1?: Vector3,
  73260. /**
  73261. * The max limit of the emission direction.
  73262. */
  73263. direction2?: Vector3);
  73264. /**
  73265. * Called by the particle System when the direction is computed for the created particle.
  73266. * @param worldMatrix is the world matrix of the particle system
  73267. * @param directionToUpdate is the direction vector to update with the result
  73268. * @param particle is the particle we are computed the direction for
  73269. */
  73270. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  73271. /**
  73272. * Clones the current emitter and returns a copy of it
  73273. * @returns the new emitter
  73274. */
  73275. clone(): SphereDirectedParticleEmitter;
  73276. /**
  73277. * Called by the GPUParticleSystem to setup the update shader
  73278. * @param effect defines the update shader
  73279. */
  73280. applyToShader(effect: Effect): void;
  73281. /**
  73282. * Returns a string to use to update the GPU particles update shader
  73283. * @returns a string containng the defines string
  73284. */
  73285. getEffectDefines(): string;
  73286. /**
  73287. * Returns the string "SphereDirectedParticleEmitter"
  73288. * @returns a string containing the class name
  73289. */
  73290. getClassName(): string;
  73291. /**
  73292. * Serializes the particle system to a JSON object.
  73293. * @returns the JSON object
  73294. */
  73295. serialize(): any;
  73296. /**
  73297. * Parse properties from a JSON object
  73298. * @param serializationObject defines the JSON object
  73299. */
  73300. parse(serializationObject: any): void;
  73301. }
  73302. }
  73303. declare module BABYLON {
  73304. /**
  73305. * Interface representing a particle system in Babylon.js.
  73306. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  73307. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  73308. */
  73309. export interface IParticleSystem {
  73310. /**
  73311. * List of animations used by the particle system.
  73312. */
  73313. animations: Animation[];
  73314. /**
  73315. * The id of the Particle system.
  73316. */
  73317. id: string;
  73318. /**
  73319. * The name of the Particle system.
  73320. */
  73321. name: string;
  73322. /**
  73323. * The emitter represents the Mesh or position we are attaching the particle system to.
  73324. */
  73325. emitter: Nullable<AbstractMesh | Vector3>;
  73326. /**
  73327. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  73328. */
  73329. isBillboardBased: boolean;
  73330. /**
  73331. * The rendering group used by the Particle system to chose when to render.
  73332. */
  73333. renderingGroupId: number;
  73334. /**
  73335. * The layer mask we are rendering the particles through.
  73336. */
  73337. layerMask: number;
  73338. /**
  73339. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  73340. */
  73341. updateSpeed: number;
  73342. /**
  73343. * The amount of time the particle system is running (depends of the overall update speed).
  73344. */
  73345. targetStopDuration: number;
  73346. /**
  73347. * The texture used to render each particle. (this can be a spritesheet)
  73348. */
  73349. particleTexture: Nullable<Texture>;
  73350. /**
  73351. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  73352. */
  73353. blendMode: number;
  73354. /**
  73355. * Minimum life time of emitting particles.
  73356. */
  73357. minLifeTime: number;
  73358. /**
  73359. * Maximum life time of emitting particles.
  73360. */
  73361. maxLifeTime: number;
  73362. /**
  73363. * Minimum Size of emitting particles.
  73364. */
  73365. minSize: number;
  73366. /**
  73367. * Maximum Size of emitting particles.
  73368. */
  73369. maxSize: number;
  73370. /**
  73371. * Minimum scale of emitting particles on X axis.
  73372. */
  73373. minScaleX: number;
  73374. /**
  73375. * Maximum scale of emitting particles on X axis.
  73376. */
  73377. maxScaleX: number;
  73378. /**
  73379. * Minimum scale of emitting particles on Y axis.
  73380. */
  73381. minScaleY: number;
  73382. /**
  73383. * Maximum scale of emitting particles on Y axis.
  73384. */
  73385. maxScaleY: number;
  73386. /**
  73387. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  73388. */
  73389. color1: Color4;
  73390. /**
  73391. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  73392. */
  73393. color2: Color4;
  73394. /**
  73395. * Color the particle will have at the end of its lifetime.
  73396. */
  73397. colorDead: Color4;
  73398. /**
  73399. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  73400. */
  73401. emitRate: number;
  73402. /**
  73403. * You can use gravity if you want to give an orientation to your particles.
  73404. */
  73405. gravity: Vector3;
  73406. /**
  73407. * Minimum power of emitting particles.
  73408. */
  73409. minEmitPower: number;
  73410. /**
  73411. * Maximum power of emitting particles.
  73412. */
  73413. maxEmitPower: number;
  73414. /**
  73415. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  73416. */
  73417. minAngularSpeed: number;
  73418. /**
  73419. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  73420. */
  73421. maxAngularSpeed: number;
  73422. /**
  73423. * Gets or sets the minimal initial rotation in radians.
  73424. */
  73425. minInitialRotation: number;
  73426. /**
  73427. * Gets or sets the maximal initial rotation in radians.
  73428. */
  73429. maxInitialRotation: number;
  73430. /**
  73431. * The particle emitter type defines the emitter used by the particle system.
  73432. * It can be for example box, sphere, or cone...
  73433. */
  73434. particleEmitterType: Nullable<IParticleEmitterType>;
  73435. /**
  73436. * Defines the delay in milliseconds before starting the system (0 by default)
  73437. */
  73438. startDelay: number;
  73439. /**
  73440. * 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
  73441. */
  73442. preWarmCycles: number;
  73443. /**
  73444. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  73445. */
  73446. preWarmStepOffset: number;
  73447. /**
  73448. * 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)
  73449. */
  73450. spriteCellChangeSpeed: number;
  73451. /**
  73452. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  73453. */
  73454. startSpriteCellID: number;
  73455. /**
  73456. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  73457. */
  73458. endSpriteCellID: number;
  73459. /**
  73460. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  73461. */
  73462. spriteCellWidth: number;
  73463. /**
  73464. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  73465. */
  73466. spriteCellHeight: number;
  73467. /**
  73468. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  73469. */
  73470. spriteRandomStartCell: boolean;
  73471. /**
  73472. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  73473. */
  73474. isAnimationSheetEnabled: boolean;
  73475. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  73476. translationPivot: Vector2;
  73477. /**
  73478. * Gets or sets a texture used to add random noise to particle positions
  73479. */
  73480. noiseTexture: Nullable<BaseTexture>;
  73481. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  73482. noiseStrength: Vector3;
  73483. /**
  73484. * Gets or sets the billboard mode to use when isBillboardBased = true.
  73485. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  73486. */
  73487. billboardMode: number;
  73488. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  73489. limitVelocityDamping: number;
  73490. /**
  73491. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  73492. */
  73493. beginAnimationOnStart: boolean;
  73494. /**
  73495. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  73496. */
  73497. beginAnimationFrom: number;
  73498. /**
  73499. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  73500. */
  73501. beginAnimationTo: number;
  73502. /**
  73503. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  73504. */
  73505. beginAnimationLoop: boolean;
  73506. /**
  73507. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  73508. */
  73509. disposeOnStop: boolean;
  73510. /**
  73511. * Gets the maximum number of particles active at the same time.
  73512. * @returns The max number of active particles.
  73513. */
  73514. getCapacity(): number;
  73515. /**
  73516. * Gets if the system has been started. (Note: this will still be true after stop is called)
  73517. * @returns True if it has been started, otherwise false.
  73518. */
  73519. isStarted(): boolean;
  73520. /**
  73521. * Animates the particle system for this frame.
  73522. */
  73523. animate(): void;
  73524. /**
  73525. * Renders the particle system in its current state.
  73526. * @returns the current number of particles
  73527. */
  73528. render(): number;
  73529. /**
  73530. * Dispose the particle system and frees its associated resources.
  73531. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  73532. */
  73533. dispose(disposeTexture?: boolean): void;
  73534. /**
  73535. * Clones the particle system.
  73536. * @param name The name of the cloned object
  73537. * @param newEmitter The new emitter to use
  73538. * @returns the cloned particle system
  73539. */
  73540. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  73541. /**
  73542. * Serializes the particle system to a JSON object.
  73543. * @returns the JSON object
  73544. */
  73545. serialize(): any;
  73546. /**
  73547. * Rebuild the particle system
  73548. */
  73549. rebuild(): void;
  73550. /**
  73551. * Starts the particle system and begins to emit
  73552. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  73553. */
  73554. start(delay?: number): void;
  73555. /**
  73556. * Stops the particle system.
  73557. */
  73558. stop(): void;
  73559. /**
  73560. * Remove all active particles
  73561. */
  73562. reset(): void;
  73563. /**
  73564. * Is this system ready to be used/rendered
  73565. * @return true if the system is ready
  73566. */
  73567. isReady(): boolean;
  73568. /**
  73569. * Adds a new color gradient
  73570. * @param gradient defines the gradient to use (between 0 and 1)
  73571. * @param color1 defines the color to affect to the specified gradient
  73572. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  73573. * @returns the current particle system
  73574. */
  73575. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  73576. /**
  73577. * Remove a specific color gradient
  73578. * @param gradient defines the gradient to remove
  73579. * @returns the current particle system
  73580. */
  73581. removeColorGradient(gradient: number): IParticleSystem;
  73582. /**
  73583. * Adds a new size gradient
  73584. * @param gradient defines the gradient to use (between 0 and 1)
  73585. * @param factor defines the size factor to affect to the specified gradient
  73586. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73587. * @returns the current particle system
  73588. */
  73589. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73590. /**
  73591. * Remove a specific size gradient
  73592. * @param gradient defines the gradient to remove
  73593. * @returns the current particle system
  73594. */
  73595. removeSizeGradient(gradient: number): IParticleSystem;
  73596. /**
  73597. * Gets the current list of color gradients.
  73598. * You must use addColorGradient and removeColorGradient to udpate this list
  73599. * @returns the list of color gradients
  73600. */
  73601. getColorGradients(): Nullable<Array<ColorGradient>>;
  73602. /**
  73603. * Gets the current list of size gradients.
  73604. * You must use addSizeGradient and removeSizeGradient to udpate this list
  73605. * @returns the list of size gradients
  73606. */
  73607. getSizeGradients(): Nullable<Array<FactorGradient>>;
  73608. /**
  73609. * Gets the current list of angular speed gradients.
  73610. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  73611. * @returns the list of angular speed gradients
  73612. */
  73613. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  73614. /**
  73615. * Adds a new angular speed gradient
  73616. * @param gradient defines the gradient to use (between 0 and 1)
  73617. * @param factor defines the angular speed to affect to the specified gradient
  73618. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73619. * @returns the current particle system
  73620. */
  73621. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73622. /**
  73623. * Remove a specific angular speed gradient
  73624. * @param gradient defines the gradient to remove
  73625. * @returns the current particle system
  73626. */
  73627. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  73628. /**
  73629. * Gets the current list of velocity gradients.
  73630. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  73631. * @returns the list of velocity gradients
  73632. */
  73633. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  73634. /**
  73635. * Adds a new velocity gradient
  73636. * @param gradient defines the gradient to use (between 0 and 1)
  73637. * @param factor defines the velocity to affect to the specified gradient
  73638. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73639. * @returns the current particle system
  73640. */
  73641. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73642. /**
  73643. * Remove a specific velocity gradient
  73644. * @param gradient defines the gradient to remove
  73645. * @returns the current particle system
  73646. */
  73647. removeVelocityGradient(gradient: number): IParticleSystem;
  73648. /**
  73649. * Gets the current list of limit velocity gradients.
  73650. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  73651. * @returns the list of limit velocity gradients
  73652. */
  73653. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  73654. /**
  73655. * Adds a new limit velocity gradient
  73656. * @param gradient defines the gradient to use (between 0 and 1)
  73657. * @param factor defines the limit velocity to affect to the specified gradient
  73658. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73659. * @returns the current particle system
  73660. */
  73661. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73662. /**
  73663. * Remove a specific limit velocity gradient
  73664. * @param gradient defines the gradient to remove
  73665. * @returns the current particle system
  73666. */
  73667. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  73668. /**
  73669. * Adds a new drag gradient
  73670. * @param gradient defines the gradient to use (between 0 and 1)
  73671. * @param factor defines the drag to affect to the specified gradient
  73672. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73673. * @returns the current particle system
  73674. */
  73675. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73676. /**
  73677. * Remove a specific drag gradient
  73678. * @param gradient defines the gradient to remove
  73679. * @returns the current particle system
  73680. */
  73681. removeDragGradient(gradient: number): IParticleSystem;
  73682. /**
  73683. * Gets the current list of drag gradients.
  73684. * You must use addDragGradient and removeDragGradient to udpate this list
  73685. * @returns the list of drag gradients
  73686. */
  73687. getDragGradients(): Nullable<Array<FactorGradient>>;
  73688. /**
  73689. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  73690. * @param gradient defines the gradient to use (between 0 and 1)
  73691. * @param factor defines the emit rate to affect to the specified gradient
  73692. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73693. * @returns the current particle system
  73694. */
  73695. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73696. /**
  73697. * Remove a specific emit rate gradient
  73698. * @param gradient defines the gradient to remove
  73699. * @returns the current particle system
  73700. */
  73701. removeEmitRateGradient(gradient: number): IParticleSystem;
  73702. /**
  73703. * Gets the current list of emit rate gradients.
  73704. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  73705. * @returns the list of emit rate gradients
  73706. */
  73707. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  73708. /**
  73709. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  73710. * @param gradient defines the gradient to use (between 0 and 1)
  73711. * @param factor defines the start size to affect to the specified gradient
  73712. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73713. * @returns the current particle system
  73714. */
  73715. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73716. /**
  73717. * Remove a specific start size gradient
  73718. * @param gradient defines the gradient to remove
  73719. * @returns the current particle system
  73720. */
  73721. removeStartSizeGradient(gradient: number): IParticleSystem;
  73722. /**
  73723. * Gets the current list of start size gradients.
  73724. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  73725. * @returns the list of start size gradients
  73726. */
  73727. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  73728. /**
  73729. * Adds a new life time gradient
  73730. * @param gradient defines the gradient to use (between 0 and 1)
  73731. * @param factor defines the life time factor to affect to the specified gradient
  73732. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73733. * @returns the current particle system
  73734. */
  73735. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73736. /**
  73737. * Remove a specific life time gradient
  73738. * @param gradient defines the gradient to remove
  73739. * @returns the current particle system
  73740. */
  73741. removeLifeTimeGradient(gradient: number): IParticleSystem;
  73742. /**
  73743. * Gets the current list of life time gradients.
  73744. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  73745. * @returns the list of life time gradients
  73746. */
  73747. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  73748. /**
  73749. * Gets the current list of color gradients.
  73750. * You must use addColorGradient and removeColorGradient to udpate this list
  73751. * @returns the list of color gradients
  73752. */
  73753. getColorGradients(): Nullable<Array<ColorGradient>>;
  73754. /**
  73755. * Adds a new ramp gradient used to remap particle colors
  73756. * @param gradient defines the gradient to use (between 0 and 1)
  73757. * @param color defines the color to affect to the specified gradient
  73758. * @returns the current particle system
  73759. */
  73760. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  73761. /**
  73762. * Gets the current list of ramp gradients.
  73763. * You must use addRampGradient and removeRampGradient to udpate this list
  73764. * @returns the list of ramp gradients
  73765. */
  73766. getRampGradients(): Nullable<Array<Color3Gradient>>;
  73767. /** Gets or sets a boolean indicating that ramp gradients must be used
  73768. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  73769. */
  73770. useRampGradients: boolean;
  73771. /**
  73772. * Adds a new color remap gradient
  73773. * @param gradient defines the gradient to use (between 0 and 1)
  73774. * @param min defines the color remap minimal range
  73775. * @param max defines the color remap maximal range
  73776. * @returns the current particle system
  73777. */
  73778. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  73779. /**
  73780. * Gets the current list of color remap gradients.
  73781. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  73782. * @returns the list of color remap gradients
  73783. */
  73784. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  73785. /**
  73786. * Adds a new alpha remap gradient
  73787. * @param gradient defines the gradient to use (between 0 and 1)
  73788. * @param min defines the alpha remap minimal range
  73789. * @param max defines the alpha remap maximal range
  73790. * @returns the current particle system
  73791. */
  73792. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  73793. /**
  73794. * Gets the current list of alpha remap gradients.
  73795. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  73796. * @returns the list of alpha remap gradients
  73797. */
  73798. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  73799. /**
  73800. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  73801. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  73802. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  73803. * @returns the emitter
  73804. */
  73805. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  73806. /**
  73807. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  73808. * @param radius The radius of the hemisphere to emit from
  73809. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  73810. * @returns the emitter
  73811. */
  73812. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  73813. /**
  73814. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  73815. * @param radius The radius of the sphere to emit from
  73816. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  73817. * @returns the emitter
  73818. */
  73819. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  73820. /**
  73821. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  73822. * @param radius The radius of the sphere to emit from
  73823. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  73824. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  73825. * @returns the emitter
  73826. */
  73827. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  73828. /**
  73829. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  73830. * @param radius The radius of the emission cylinder
  73831. * @param height The height of the emission cylinder
  73832. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  73833. * @param directionRandomizer How much to randomize the particle direction [0-1]
  73834. * @returns the emitter
  73835. */
  73836. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  73837. /**
  73838. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  73839. * @param radius The radius of the cylinder to emit from
  73840. * @param height The height of the emission cylinder
  73841. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  73842. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  73843. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  73844. * @returns the emitter
  73845. */
  73846. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  73847. /**
  73848. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  73849. * @param radius The radius of the cone to emit from
  73850. * @param angle The base angle of the cone
  73851. * @returns the emitter
  73852. */
  73853. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  73854. /**
  73855. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  73856. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  73857. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  73858. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  73859. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  73860. * @returns the emitter
  73861. */
  73862. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  73863. /**
  73864. * Get hosting scene
  73865. * @returns the scene
  73866. */
  73867. getScene(): Scene;
  73868. }
  73869. }
  73870. declare module BABYLON {
  73871. /**
  73872. * Creates an instance based on a source mesh.
  73873. */
  73874. export class InstancedMesh extends AbstractMesh {
  73875. private _sourceMesh;
  73876. private _currentLOD;
  73877. /** @hidden */
  73878. _indexInSourceMeshInstanceArray: number;
  73879. constructor(name: string, source: Mesh);
  73880. /**
  73881. * Returns the string "InstancedMesh".
  73882. */
  73883. getClassName(): string;
  73884. /**
  73885. * If the source mesh receives shadows
  73886. */
  73887. readonly receiveShadows: boolean;
  73888. /**
  73889. * The material of the source mesh
  73890. */
  73891. readonly material: Nullable<Material>;
  73892. /**
  73893. * Visibility of the source mesh
  73894. */
  73895. readonly visibility: number;
  73896. /**
  73897. * Skeleton of the source mesh
  73898. */
  73899. readonly skeleton: Nullable<Skeleton>;
  73900. /**
  73901. * Rendering ground id of the source mesh
  73902. */
  73903. renderingGroupId: number;
  73904. /**
  73905. * Returns the total number of vertices (integer).
  73906. */
  73907. getTotalVertices(): number;
  73908. /**
  73909. * Returns a positive integer : the total number of indices in this mesh geometry.
  73910. * @returns the numner of indices or zero if the mesh has no geometry.
  73911. */
  73912. getTotalIndices(): number;
  73913. /**
  73914. * The source mesh of the instance
  73915. */
  73916. readonly sourceMesh: Mesh;
  73917. /**
  73918. * Is this node ready to be used/rendered
  73919. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  73920. * @return {boolean} is it ready
  73921. */
  73922. isReady(completeCheck?: boolean): boolean;
  73923. /**
  73924. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  73925. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  73926. * @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.
  73927. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  73928. */
  73929. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  73930. /**
  73931. * Sets the vertex data of the mesh geometry for the requested `kind`.
  73932. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  73933. * The `data` are either a numeric array either a Float32Array.
  73934. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  73935. * 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).
  73936. * Note that a new underlying VertexBuffer object is created each call.
  73937. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  73938. *
  73939. * Possible `kind` values :
  73940. * - VertexBuffer.PositionKind
  73941. * - VertexBuffer.UVKind
  73942. * - VertexBuffer.UV2Kind
  73943. * - VertexBuffer.UV3Kind
  73944. * - VertexBuffer.UV4Kind
  73945. * - VertexBuffer.UV5Kind
  73946. * - VertexBuffer.UV6Kind
  73947. * - VertexBuffer.ColorKind
  73948. * - VertexBuffer.MatricesIndicesKind
  73949. * - VertexBuffer.MatricesIndicesExtraKind
  73950. * - VertexBuffer.MatricesWeightsKind
  73951. * - VertexBuffer.MatricesWeightsExtraKind
  73952. *
  73953. * Returns the Mesh.
  73954. */
  73955. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  73956. /**
  73957. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  73958. * If the mesh has no geometry, it is simply returned as it is.
  73959. * The `data` are either a numeric array either a Float32Array.
  73960. * No new underlying VertexBuffer object is created.
  73961. * 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.
  73962. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  73963. *
  73964. * Possible `kind` values :
  73965. * - VertexBuffer.PositionKind
  73966. * - VertexBuffer.UVKind
  73967. * - VertexBuffer.UV2Kind
  73968. * - VertexBuffer.UV3Kind
  73969. * - VertexBuffer.UV4Kind
  73970. * - VertexBuffer.UV5Kind
  73971. * - VertexBuffer.UV6Kind
  73972. * - VertexBuffer.ColorKind
  73973. * - VertexBuffer.MatricesIndicesKind
  73974. * - VertexBuffer.MatricesIndicesExtraKind
  73975. * - VertexBuffer.MatricesWeightsKind
  73976. * - VertexBuffer.MatricesWeightsExtraKind
  73977. *
  73978. * Returns the Mesh.
  73979. */
  73980. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  73981. /**
  73982. * Sets the mesh indices.
  73983. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  73984. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  73985. * This method creates a new index buffer each call.
  73986. * Returns the Mesh.
  73987. */
  73988. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  73989. /**
  73990. * Boolean : True if the mesh owns the requested kind of data.
  73991. */
  73992. isVerticesDataPresent(kind: string): boolean;
  73993. /**
  73994. * Returns an array of indices (IndicesArray).
  73995. */
  73996. getIndices(): Nullable<IndicesArray>;
  73997. readonly _positions: Nullable<Vector3[]>;
  73998. /**
  73999. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  74000. * This means the mesh underlying bounding box and sphere are recomputed.
  74001. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  74002. * @returns the current mesh
  74003. */
  74004. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  74005. /** @hidden */
  74006. _preActivate(): InstancedMesh;
  74007. /** @hidden */
  74008. _activate(renderId: number): InstancedMesh;
  74009. /**
  74010. * Returns the current associated LOD AbstractMesh.
  74011. */
  74012. getLOD(camera: Camera): AbstractMesh;
  74013. /** @hidden */
  74014. _syncSubMeshes(): InstancedMesh;
  74015. /** @hidden */
  74016. _generatePointsArray(): boolean;
  74017. /**
  74018. * Creates a new InstancedMesh from the current mesh.
  74019. * - name (string) : the cloned mesh name
  74020. * - newParent (optional Node) : the optional Node to parent the clone to.
  74021. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  74022. *
  74023. * Returns the clone.
  74024. */
  74025. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  74026. /**
  74027. * Disposes the InstancedMesh.
  74028. * Returns nothing.
  74029. */
  74030. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  74031. }
  74032. }
  74033. declare module BABYLON {
  74034. /**
  74035. * Defines the options associated with the creation of a shader material.
  74036. */
  74037. export interface IShaderMaterialOptions {
  74038. /**
  74039. * Does the material work in alpha blend mode
  74040. */
  74041. needAlphaBlending: boolean;
  74042. /**
  74043. * Does the material work in alpha test mode
  74044. */
  74045. needAlphaTesting: boolean;
  74046. /**
  74047. * The list of attribute names used in the shader
  74048. */
  74049. attributes: string[];
  74050. /**
  74051. * The list of unifrom names used in the shader
  74052. */
  74053. uniforms: string[];
  74054. /**
  74055. * The list of UBO names used in the shader
  74056. */
  74057. uniformBuffers: string[];
  74058. /**
  74059. * The list of sampler names used in the shader
  74060. */
  74061. samplers: string[];
  74062. /**
  74063. * The list of defines used in the shader
  74064. */
  74065. defines: string[];
  74066. }
  74067. /**
  74068. * 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.
  74069. *
  74070. * This returned material effects how the mesh will look based on the code in the shaders.
  74071. *
  74072. * @see http://doc.babylonjs.com/how_to/shader_material
  74073. */
  74074. export class ShaderMaterial extends Material {
  74075. private _shaderPath;
  74076. private _options;
  74077. private _textures;
  74078. private _textureArrays;
  74079. private _floats;
  74080. private _ints;
  74081. private _floatsArrays;
  74082. private _colors3;
  74083. private _colors3Arrays;
  74084. private _colors4;
  74085. private _vectors2;
  74086. private _vectors3;
  74087. private _vectors4;
  74088. private _matrices;
  74089. private _matrices3x3;
  74090. private _matrices2x2;
  74091. private _vectors2Arrays;
  74092. private _vectors3Arrays;
  74093. private _cachedWorldViewMatrix;
  74094. private _renderId;
  74095. /**
  74096. * Instantiate a new shader material.
  74097. * 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.
  74098. * This returned material effects how the mesh will look based on the code in the shaders.
  74099. * @see http://doc.babylonjs.com/how_to/shader_material
  74100. * @param name Define the name of the material in the scene
  74101. * @param scene Define the scene the material belongs to
  74102. * @param shaderPath Defines the route to the shader code in one of three ways:
  74103. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  74104. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  74105. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  74106. * @param options Define the options used to create the shader
  74107. */
  74108. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  74109. /**
  74110. * Gets the options used to compile the shader.
  74111. * They can be modified to trigger a new compilation
  74112. */
  74113. readonly options: IShaderMaterialOptions;
  74114. /**
  74115. * Gets the current class name of the material e.g. "ShaderMaterial"
  74116. * Mainly use in serialization.
  74117. * @returns the class name
  74118. */
  74119. getClassName(): string;
  74120. /**
  74121. * Specifies if the material will require alpha blending
  74122. * @returns a boolean specifying if alpha blending is needed
  74123. */
  74124. needAlphaBlending(): boolean;
  74125. /**
  74126. * Specifies if this material should be rendered in alpha test mode
  74127. * @returns a boolean specifying if an alpha test is needed.
  74128. */
  74129. needAlphaTesting(): boolean;
  74130. private _checkUniform;
  74131. /**
  74132. * Set a texture in the shader.
  74133. * @param name Define the name of the uniform samplers as defined in the shader
  74134. * @param texture Define the texture to bind to this sampler
  74135. * @return the material itself allowing "fluent" like uniform updates
  74136. */
  74137. setTexture(name: string, texture: Texture): ShaderMaterial;
  74138. /**
  74139. * Set a texture array in the shader.
  74140. * @param name Define the name of the uniform sampler array as defined in the shader
  74141. * @param textures Define the list of textures to bind to this sampler
  74142. * @return the material itself allowing "fluent" like uniform updates
  74143. */
  74144. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  74145. /**
  74146. * Set a float in the shader.
  74147. * @param name Define the name of the uniform as defined in the shader
  74148. * @param value Define the value to give to the uniform
  74149. * @return the material itself allowing "fluent" like uniform updates
  74150. */
  74151. setFloat(name: string, value: number): ShaderMaterial;
  74152. /**
  74153. * Set a int in the shader.
  74154. * @param name Define the name of the uniform as defined in the shader
  74155. * @param value Define the value to give to the uniform
  74156. * @return the material itself allowing "fluent" like uniform updates
  74157. */
  74158. setInt(name: string, value: number): ShaderMaterial;
  74159. /**
  74160. * Set an array of floats in the shader.
  74161. * @param name Define the name of the uniform as defined in the shader
  74162. * @param value Define the value to give to the uniform
  74163. * @return the material itself allowing "fluent" like uniform updates
  74164. */
  74165. setFloats(name: string, value: number[]): ShaderMaterial;
  74166. /**
  74167. * Set a vec3 in the shader from a Color3.
  74168. * @param name Define the name of the uniform as defined in the shader
  74169. * @param value Define the value to give to the uniform
  74170. * @return the material itself allowing "fluent" like uniform updates
  74171. */
  74172. setColor3(name: string, value: Color3): ShaderMaterial;
  74173. /**
  74174. * Set a vec3 array in the shader from a Color3 array.
  74175. * @param name Define the name of the uniform as defined in the shader
  74176. * @param value Define the value to give to the uniform
  74177. * @return the material itself allowing "fluent" like uniform updates
  74178. */
  74179. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  74180. /**
  74181. * Set a vec4 in the shader from a Color4.
  74182. * @param name Define the name of the uniform as defined in the shader
  74183. * @param value Define the value to give to the uniform
  74184. * @return the material itself allowing "fluent" like uniform updates
  74185. */
  74186. setColor4(name: string, value: Color4): ShaderMaterial;
  74187. /**
  74188. * Set a vec2 in the shader from a Vector2.
  74189. * @param name Define the name of the uniform as defined in the shader
  74190. * @param value Define the value to give to the uniform
  74191. * @return the material itself allowing "fluent" like uniform updates
  74192. */
  74193. setVector2(name: string, value: Vector2): ShaderMaterial;
  74194. /**
  74195. * Set a vec3 in the shader from a Vector3.
  74196. * @param name Define the name of the uniform as defined in the shader
  74197. * @param value Define the value to give to the uniform
  74198. * @return the material itself allowing "fluent" like uniform updates
  74199. */
  74200. setVector3(name: string, value: Vector3): ShaderMaterial;
  74201. /**
  74202. * Set a vec4 in the shader from a Vector4.
  74203. * @param name Define the name of the uniform as defined in the shader
  74204. * @param value Define the value to give to the uniform
  74205. * @return the material itself allowing "fluent" like uniform updates
  74206. */
  74207. setVector4(name: string, value: Vector4): ShaderMaterial;
  74208. /**
  74209. * Set a mat4 in the shader from a Matrix.
  74210. * @param name Define the name of the uniform as defined in the shader
  74211. * @param value Define the value to give to the uniform
  74212. * @return the material itself allowing "fluent" like uniform updates
  74213. */
  74214. setMatrix(name: string, value: Matrix): ShaderMaterial;
  74215. /**
  74216. * Set a mat3 in the shader from a Float32Array.
  74217. * @param name Define the name of the uniform as defined in the shader
  74218. * @param value Define the value to give to the uniform
  74219. * @return the material itself allowing "fluent" like uniform updates
  74220. */
  74221. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  74222. /**
  74223. * Set a mat2 in the shader from a Float32Array.
  74224. * @param name Define the name of the uniform as defined in the shader
  74225. * @param value Define the value to give to the uniform
  74226. * @return the material itself allowing "fluent" like uniform updates
  74227. */
  74228. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  74229. /**
  74230. * Set a vec2 array in the shader from a number array.
  74231. * @param name Define the name of the uniform as defined in the shader
  74232. * @param value Define the value to give to the uniform
  74233. * @return the material itself allowing "fluent" like uniform updates
  74234. */
  74235. setArray2(name: string, value: number[]): ShaderMaterial;
  74236. /**
  74237. * Set a vec3 array in the shader from a number array.
  74238. * @param name Define the name of the uniform as defined in the shader
  74239. * @param value Define the value to give to the uniform
  74240. * @return the material itself allowing "fluent" like uniform updates
  74241. */
  74242. setArray3(name: string, value: number[]): ShaderMaterial;
  74243. private _checkCache;
  74244. /**
  74245. * Checks if the material is ready to render the requested mesh
  74246. * @param mesh Define the mesh to render
  74247. * @param useInstances Define whether or not the material is used with instances
  74248. * @returns true if ready, otherwise false
  74249. */
  74250. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  74251. /**
  74252. * Binds the world matrix to the material
  74253. * @param world defines the world transformation matrix
  74254. */
  74255. bindOnlyWorldMatrix(world: Matrix): void;
  74256. /**
  74257. * Binds the material to the mesh
  74258. * @param world defines the world transformation matrix
  74259. * @param mesh defines the mesh to bind the material to
  74260. */
  74261. bind(world: Matrix, mesh?: Mesh): void;
  74262. /**
  74263. * Gets the active textures from the material
  74264. * @returns an array of textures
  74265. */
  74266. getActiveTextures(): BaseTexture[];
  74267. /**
  74268. * Specifies if the material uses a texture
  74269. * @param texture defines the texture to check against the material
  74270. * @returns a boolean specifying if the material uses the texture
  74271. */
  74272. hasTexture(texture: BaseTexture): boolean;
  74273. /**
  74274. * Makes a duplicate of the material, and gives it a new name
  74275. * @param name defines the new name for the duplicated material
  74276. * @returns the cloned material
  74277. */
  74278. clone(name: string): ShaderMaterial;
  74279. /**
  74280. * Disposes the material
  74281. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  74282. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  74283. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  74284. */
  74285. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  74286. /**
  74287. * Serializes this material in a JSON representation
  74288. * @returns the serialized material object
  74289. */
  74290. serialize(): any;
  74291. /**
  74292. * Creates a shader material from parsed shader material data
  74293. * @param source defines the JSON represnetation of the material
  74294. * @param scene defines the hosting scene
  74295. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  74296. * @returns a new material
  74297. */
  74298. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  74299. }
  74300. }
  74301. declare module BABYLON {
  74302. /** @hidden */
  74303. export var colorPixelShader: {
  74304. name: string;
  74305. shader: string;
  74306. };
  74307. }
  74308. declare module BABYLON {
  74309. /** @hidden */
  74310. export var colorVertexShader: {
  74311. name: string;
  74312. shader: string;
  74313. };
  74314. }
  74315. declare module BABYLON {
  74316. /**
  74317. * Line mesh
  74318. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  74319. */
  74320. export class LinesMesh extends Mesh {
  74321. /**
  74322. * If vertex color should be applied to the mesh
  74323. */
  74324. useVertexColor?: boolean | undefined;
  74325. /**
  74326. * If vertex alpha should be applied to the mesh
  74327. */
  74328. useVertexAlpha?: boolean | undefined;
  74329. /**
  74330. * Color of the line (Default: White)
  74331. */
  74332. color: Color3;
  74333. /**
  74334. * Alpha of the line (Default: 1)
  74335. */
  74336. alpha: number;
  74337. /**
  74338. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  74339. * This margin is expressed in world space coordinates, so its value may vary.
  74340. * Default value is 0.1
  74341. */
  74342. intersectionThreshold: number;
  74343. private _colorShader;
  74344. /**
  74345. * Creates a new LinesMesh
  74346. * @param name defines the name
  74347. * @param scene defines the hosting scene
  74348. * @param parent defines the parent mesh if any
  74349. * @param source defines the optional source LinesMesh used to clone data from
  74350. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  74351. * When false, achieved by calling a clone(), also passing False.
  74352. * This will make creation of children, recursive.
  74353. * @param useVertexColor defines if this LinesMesh supports vertex color
  74354. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  74355. */
  74356. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  74357. /**
  74358. * If vertex color should be applied to the mesh
  74359. */
  74360. useVertexColor?: boolean | undefined,
  74361. /**
  74362. * If vertex alpha should be applied to the mesh
  74363. */
  74364. useVertexAlpha?: boolean | undefined);
  74365. private _addClipPlaneDefine;
  74366. private _removeClipPlaneDefine;
  74367. isReady(): boolean;
  74368. /**
  74369. * Returns the string "LineMesh"
  74370. */
  74371. getClassName(): string;
  74372. /**
  74373. * @hidden
  74374. */
  74375. /**
  74376. * @hidden
  74377. */
  74378. material: Material;
  74379. /**
  74380. * @hidden
  74381. */
  74382. readonly checkCollisions: boolean;
  74383. /** @hidden */
  74384. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  74385. /** @hidden */
  74386. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  74387. /**
  74388. * Disposes of the line mesh
  74389. * @param doNotRecurse If children should be disposed
  74390. */
  74391. dispose(doNotRecurse?: boolean): void;
  74392. /**
  74393. * Returns a new LineMesh object cloned from the current one.
  74394. */
  74395. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  74396. /**
  74397. * Creates a new InstancedLinesMesh object from the mesh model.
  74398. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  74399. * @param name defines the name of the new instance
  74400. * @returns a new InstancedLinesMesh
  74401. */
  74402. createInstance(name: string): InstancedLinesMesh;
  74403. }
  74404. /**
  74405. * Creates an instance based on a source LinesMesh
  74406. */
  74407. export class InstancedLinesMesh extends InstancedMesh {
  74408. /**
  74409. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  74410. * This margin is expressed in world space coordinates, so its value may vary.
  74411. * Initilized with the intersectionThreshold value of the source LinesMesh
  74412. */
  74413. intersectionThreshold: number;
  74414. constructor(name: string, source: LinesMesh);
  74415. /**
  74416. * Returns the string "InstancedLinesMesh".
  74417. */
  74418. getClassName(): string;
  74419. }
  74420. }
  74421. declare module BABYLON {
  74422. /** @hidden */
  74423. export var linePixelShader: {
  74424. name: string;
  74425. shader: string;
  74426. };
  74427. }
  74428. declare module BABYLON {
  74429. /** @hidden */
  74430. export var lineVertexShader: {
  74431. name: string;
  74432. shader: string;
  74433. };
  74434. }
  74435. declare module BABYLON {
  74436. interface AbstractMesh {
  74437. /**
  74438. * Disables the mesh edge rendering mode
  74439. * @returns the currentAbstractMesh
  74440. */
  74441. disableEdgesRendering(): AbstractMesh;
  74442. /**
  74443. * Enables the edge rendering mode on the mesh.
  74444. * This mode makes the mesh edges visible
  74445. * @param epsilon defines the maximal distance between two angles to detect a face
  74446. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  74447. * @returns the currentAbstractMesh
  74448. * @see https://www.babylonjs-playground.com/#19O9TU#0
  74449. */
  74450. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  74451. /**
  74452. * Gets the edgesRenderer associated with the mesh
  74453. */
  74454. edgesRenderer: Nullable<EdgesRenderer>;
  74455. }
  74456. interface LinesMesh {
  74457. /**
  74458. * Enables the edge rendering mode on the mesh.
  74459. * This mode makes the mesh edges visible
  74460. * @param epsilon defines the maximal distance between two angles to detect a face
  74461. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  74462. * @returns the currentAbstractMesh
  74463. * @see https://www.babylonjs-playground.com/#19O9TU#0
  74464. */
  74465. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  74466. }
  74467. interface InstancedLinesMesh {
  74468. /**
  74469. * Enables the edge rendering mode on the mesh.
  74470. * This mode makes the mesh edges visible
  74471. * @param epsilon defines the maximal distance between two angles to detect a face
  74472. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  74473. * @returns the current InstancedLinesMesh
  74474. * @see https://www.babylonjs-playground.com/#19O9TU#0
  74475. */
  74476. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  74477. }
  74478. /**
  74479. * Defines the minimum contract an Edges renderer should follow.
  74480. */
  74481. export interface IEdgesRenderer extends IDisposable {
  74482. /**
  74483. * Gets or sets a boolean indicating if the edgesRenderer is active
  74484. */
  74485. isEnabled: boolean;
  74486. /**
  74487. * Renders the edges of the attached mesh,
  74488. */
  74489. render(): void;
  74490. /**
  74491. * Checks wether or not the edges renderer is ready to render.
  74492. * @return true if ready, otherwise false.
  74493. */
  74494. isReady(): boolean;
  74495. }
  74496. /**
  74497. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  74498. */
  74499. export class EdgesRenderer implements IEdgesRenderer {
  74500. /**
  74501. * Define the size of the edges with an orthographic camera
  74502. */
  74503. edgesWidthScalerForOrthographic: number;
  74504. /**
  74505. * Define the size of the edges with a perspective camera
  74506. */
  74507. edgesWidthScalerForPerspective: number;
  74508. protected _source: AbstractMesh;
  74509. protected _linesPositions: number[];
  74510. protected _linesNormals: number[];
  74511. protected _linesIndices: number[];
  74512. protected _epsilon: number;
  74513. protected _indicesCount: number;
  74514. protected _lineShader: ShaderMaterial;
  74515. protected _ib: WebGLBuffer;
  74516. protected _buffers: {
  74517. [key: string]: Nullable<VertexBuffer>;
  74518. };
  74519. protected _checkVerticesInsteadOfIndices: boolean;
  74520. private _meshRebuildObserver;
  74521. private _meshDisposeObserver;
  74522. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  74523. isEnabled: boolean;
  74524. /**
  74525. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  74526. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  74527. * @param source Mesh used to create edges
  74528. * @param epsilon sum of angles in adjacency to check for edge
  74529. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  74530. * @param generateEdgesLines - should generate Lines or only prepare resources.
  74531. */
  74532. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  74533. protected _prepareRessources(): void;
  74534. /** @hidden */
  74535. _rebuild(): void;
  74536. /**
  74537. * Releases the required resources for the edges renderer
  74538. */
  74539. dispose(): void;
  74540. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  74541. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  74542. /**
  74543. * Checks if the pair of p0 and p1 is en edge
  74544. * @param faceIndex
  74545. * @param edge
  74546. * @param faceNormals
  74547. * @param p0
  74548. * @param p1
  74549. * @private
  74550. */
  74551. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  74552. /**
  74553. * push line into the position, normal and index buffer
  74554. * @protected
  74555. */
  74556. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  74557. /**
  74558. * Generates lines edges from adjacencjes
  74559. * @private
  74560. */
  74561. _generateEdgesLines(): void;
  74562. /**
  74563. * Checks wether or not the edges renderer is ready to render.
  74564. * @return true if ready, otherwise false.
  74565. */
  74566. isReady(): boolean;
  74567. /**
  74568. * Renders the edges of the attached mesh,
  74569. */
  74570. render(): void;
  74571. }
  74572. /**
  74573. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  74574. */
  74575. export class LineEdgesRenderer extends EdgesRenderer {
  74576. /**
  74577. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  74578. * @param source LineMesh used to generate edges
  74579. * @param epsilon not important (specified angle for edge detection)
  74580. * @param checkVerticesInsteadOfIndices not important for LineMesh
  74581. */
  74582. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  74583. /**
  74584. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  74585. */
  74586. _generateEdgesLines(): void;
  74587. }
  74588. }
  74589. declare module BABYLON {
  74590. /**
  74591. * This represents the object necessary to create a rendering group.
  74592. * This is exclusively used and created by the rendering manager.
  74593. * To modify the behavior, you use the available helpers in your scene or meshes.
  74594. * @hidden
  74595. */
  74596. export class RenderingGroup {
  74597. index: number;
  74598. private _scene;
  74599. private _opaqueSubMeshes;
  74600. private _transparentSubMeshes;
  74601. private _alphaTestSubMeshes;
  74602. private _depthOnlySubMeshes;
  74603. private _particleSystems;
  74604. private _spriteManagers;
  74605. private _opaqueSortCompareFn;
  74606. private _alphaTestSortCompareFn;
  74607. private _transparentSortCompareFn;
  74608. private _renderOpaque;
  74609. private _renderAlphaTest;
  74610. private _renderTransparent;
  74611. private _edgesRenderers;
  74612. onBeforeTransparentRendering: () => void;
  74613. /**
  74614. * Set the opaque sort comparison function.
  74615. * If null the sub meshes will be render in the order they were created
  74616. */
  74617. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  74618. /**
  74619. * Set the alpha test sort comparison function.
  74620. * If null the sub meshes will be render in the order they were created
  74621. */
  74622. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  74623. /**
  74624. * Set the transparent sort comparison function.
  74625. * If null the sub meshes will be render in the order they were created
  74626. */
  74627. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  74628. /**
  74629. * Creates a new rendering group.
  74630. * @param index The rendering group index
  74631. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  74632. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  74633. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  74634. */
  74635. 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>);
  74636. /**
  74637. * Render all the sub meshes contained in the group.
  74638. * @param customRenderFunction Used to override the default render behaviour of the group.
  74639. * @returns true if rendered some submeshes.
  74640. */
  74641. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  74642. /**
  74643. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  74644. * @param subMeshes The submeshes to render
  74645. */
  74646. private renderOpaqueSorted;
  74647. /**
  74648. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  74649. * @param subMeshes The submeshes to render
  74650. */
  74651. private renderAlphaTestSorted;
  74652. /**
  74653. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  74654. * @param subMeshes The submeshes to render
  74655. */
  74656. private renderTransparentSorted;
  74657. /**
  74658. * Renders the submeshes in a specified order.
  74659. * @param subMeshes The submeshes to sort before render
  74660. * @param sortCompareFn The comparison function use to sort
  74661. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  74662. * @param transparent Specifies to activate blending if true
  74663. */
  74664. private static renderSorted;
  74665. /**
  74666. * Renders the submeshes in the order they were dispatched (no sort applied).
  74667. * @param subMeshes The submeshes to render
  74668. */
  74669. private static renderUnsorted;
  74670. /**
  74671. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  74672. * are rendered back to front if in the same alpha index.
  74673. *
  74674. * @param a The first submesh
  74675. * @param b The second submesh
  74676. * @returns The result of the comparison
  74677. */
  74678. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  74679. /**
  74680. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  74681. * are rendered back to front.
  74682. *
  74683. * @param a The first submesh
  74684. * @param b The second submesh
  74685. * @returns The result of the comparison
  74686. */
  74687. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  74688. /**
  74689. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  74690. * are rendered front to back (prevent overdraw).
  74691. *
  74692. * @param a The first submesh
  74693. * @param b The second submesh
  74694. * @returns The result of the comparison
  74695. */
  74696. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  74697. /**
  74698. * Resets the different lists of submeshes to prepare a new frame.
  74699. */
  74700. prepare(): void;
  74701. dispose(): void;
  74702. /**
  74703. * Inserts the submesh in its correct queue depending on its material.
  74704. * @param subMesh The submesh to dispatch
  74705. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  74706. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  74707. */
  74708. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  74709. dispatchSprites(spriteManager: ISpriteManager): void;
  74710. dispatchParticles(particleSystem: IParticleSystem): void;
  74711. private _renderParticles;
  74712. private _renderSprites;
  74713. }
  74714. }
  74715. declare module BABYLON {
  74716. /**
  74717. * Interface describing the different options available in the rendering manager
  74718. * regarding Auto Clear between groups.
  74719. */
  74720. export interface IRenderingManagerAutoClearSetup {
  74721. /**
  74722. * Defines whether or not autoclear is enable.
  74723. */
  74724. autoClear: boolean;
  74725. /**
  74726. * Defines whether or not to autoclear the depth buffer.
  74727. */
  74728. depth: boolean;
  74729. /**
  74730. * Defines whether or not to autoclear the stencil buffer.
  74731. */
  74732. stencil: boolean;
  74733. }
  74734. /**
  74735. * This class is used by the onRenderingGroupObservable
  74736. */
  74737. export class RenderingGroupInfo {
  74738. /**
  74739. * The Scene that being rendered
  74740. */
  74741. scene: Scene;
  74742. /**
  74743. * The camera currently used for the rendering pass
  74744. */
  74745. camera: Nullable<Camera>;
  74746. /**
  74747. * The ID of the renderingGroup being processed
  74748. */
  74749. renderingGroupId: number;
  74750. }
  74751. /**
  74752. * This is the manager responsible of all the rendering for meshes sprites and particles.
  74753. * It is enable to manage the different groups as well as the different necessary sort functions.
  74754. * This should not be used directly aside of the few static configurations
  74755. */
  74756. export class RenderingManager {
  74757. /**
  74758. * The max id used for rendering groups (not included)
  74759. */
  74760. static MAX_RENDERINGGROUPS: number;
  74761. /**
  74762. * The min id used for rendering groups (included)
  74763. */
  74764. static MIN_RENDERINGGROUPS: number;
  74765. /**
  74766. * Used to globally prevent autoclearing scenes.
  74767. */
  74768. static AUTOCLEAR: boolean;
  74769. /**
  74770. * @hidden
  74771. */
  74772. _useSceneAutoClearSetup: boolean;
  74773. private _scene;
  74774. private _renderingGroups;
  74775. private _depthStencilBufferAlreadyCleaned;
  74776. private _autoClearDepthStencil;
  74777. private _customOpaqueSortCompareFn;
  74778. private _customAlphaTestSortCompareFn;
  74779. private _customTransparentSortCompareFn;
  74780. private _renderingGroupInfo;
  74781. /**
  74782. * Instantiates a new rendering group for a particular scene
  74783. * @param scene Defines the scene the groups belongs to
  74784. */
  74785. constructor(scene: Scene);
  74786. private _clearDepthStencilBuffer;
  74787. /**
  74788. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  74789. * @hidden
  74790. */
  74791. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  74792. /**
  74793. * Resets the different information of the group to prepare a new frame
  74794. * @hidden
  74795. */
  74796. reset(): void;
  74797. /**
  74798. * Dispose and release the group and its associated resources.
  74799. * @hidden
  74800. */
  74801. dispose(): void;
  74802. /**
  74803. * Clear the info related to rendering groups preventing retention points during dispose.
  74804. */
  74805. freeRenderingGroups(): void;
  74806. private _prepareRenderingGroup;
  74807. /**
  74808. * Add a sprite manager to the rendering manager in order to render it this frame.
  74809. * @param spriteManager Define the sprite manager to render
  74810. */
  74811. dispatchSprites(spriteManager: ISpriteManager): void;
  74812. /**
  74813. * Add a particle system to the rendering manager in order to render it this frame.
  74814. * @param particleSystem Define the particle system to render
  74815. */
  74816. dispatchParticles(particleSystem: IParticleSystem): void;
  74817. /**
  74818. * Add a submesh to the manager in order to render it this frame
  74819. * @param subMesh The submesh to dispatch
  74820. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  74821. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  74822. */
  74823. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  74824. /**
  74825. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  74826. * This allowed control for front to back rendering or reversly depending of the special needs.
  74827. *
  74828. * @param renderingGroupId The rendering group id corresponding to its index
  74829. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  74830. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  74831. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  74832. */
  74833. 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;
  74834. /**
  74835. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  74836. *
  74837. * @param renderingGroupId The rendering group id corresponding to its index
  74838. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  74839. * @param depth Automatically clears depth between groups if true and autoClear is true.
  74840. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  74841. */
  74842. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  74843. /**
  74844. * Gets the current auto clear configuration for one rendering group of the rendering
  74845. * manager.
  74846. * @param index the rendering group index to get the information for
  74847. * @returns The auto clear setup for the requested rendering group
  74848. */
  74849. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  74850. }
  74851. }
  74852. declare module BABYLON {
  74853. /**
  74854. * This Helps creating a texture that will be created from a camera in your scene.
  74855. * It is basically a dynamic texture that could be used to create special effects for instance.
  74856. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  74857. */
  74858. export class RenderTargetTexture extends Texture {
  74859. isCube: boolean;
  74860. /**
  74861. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  74862. */
  74863. static readonly REFRESHRATE_RENDER_ONCE: number;
  74864. /**
  74865. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  74866. */
  74867. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  74868. /**
  74869. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  74870. * the central point of your effect and can save a lot of performances.
  74871. */
  74872. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  74873. /**
  74874. * Use this predicate to dynamically define the list of mesh you want to render.
  74875. * If set, the renderList property will be overwritten.
  74876. */
  74877. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  74878. private _renderList;
  74879. /**
  74880. * Use this list to define the list of mesh you want to render.
  74881. */
  74882. renderList: Nullable<Array<AbstractMesh>>;
  74883. private _hookArray;
  74884. /**
  74885. * Define if particles should be rendered in your texture.
  74886. */
  74887. renderParticles: boolean;
  74888. /**
  74889. * Define if sprites should be rendered in your texture.
  74890. */
  74891. renderSprites: boolean;
  74892. /**
  74893. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  74894. */
  74895. coordinatesMode: number;
  74896. /**
  74897. * Define the camera used to render the texture.
  74898. */
  74899. activeCamera: Nullable<Camera>;
  74900. /**
  74901. * Override the render function of the texture with your own one.
  74902. */
  74903. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  74904. /**
  74905. * Define if camera post processes should be use while rendering the texture.
  74906. */
  74907. useCameraPostProcesses: boolean;
  74908. /**
  74909. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  74910. */
  74911. ignoreCameraViewport: boolean;
  74912. private _postProcessManager;
  74913. private _postProcesses;
  74914. private _resizeObserver;
  74915. /**
  74916. * An event triggered when the texture is unbind.
  74917. */
  74918. onBeforeBindObservable: Observable<RenderTargetTexture>;
  74919. /**
  74920. * An event triggered when the texture is unbind.
  74921. */
  74922. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  74923. private _onAfterUnbindObserver;
  74924. /**
  74925. * Set a after unbind callback in the texture.
  74926. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  74927. */
  74928. onAfterUnbind: () => void;
  74929. /**
  74930. * An event triggered before rendering the texture
  74931. */
  74932. onBeforeRenderObservable: Observable<number>;
  74933. private _onBeforeRenderObserver;
  74934. /**
  74935. * Set a before render callback in the texture.
  74936. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  74937. */
  74938. onBeforeRender: (faceIndex: number) => void;
  74939. /**
  74940. * An event triggered after rendering the texture
  74941. */
  74942. onAfterRenderObservable: Observable<number>;
  74943. private _onAfterRenderObserver;
  74944. /**
  74945. * Set a after render callback in the texture.
  74946. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  74947. */
  74948. onAfterRender: (faceIndex: number) => void;
  74949. /**
  74950. * An event triggered after the texture clear
  74951. */
  74952. onClearObservable: Observable<Engine>;
  74953. private _onClearObserver;
  74954. /**
  74955. * Set a clear callback in the texture.
  74956. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  74957. */
  74958. onClear: (Engine: Engine) => void;
  74959. /**
  74960. * Define the clear color of the Render Target if it should be different from the scene.
  74961. */
  74962. clearColor: Color4;
  74963. protected _size: number | {
  74964. width: number;
  74965. height: number;
  74966. };
  74967. protected _initialSizeParameter: number | {
  74968. width: number;
  74969. height: number;
  74970. } | {
  74971. ratio: number;
  74972. };
  74973. protected _sizeRatio: Nullable<number>;
  74974. /** @hidden */
  74975. _generateMipMaps: boolean;
  74976. protected _renderingManager: RenderingManager;
  74977. /** @hidden */
  74978. _waitingRenderList: string[];
  74979. protected _doNotChangeAspectRatio: boolean;
  74980. protected _currentRefreshId: number;
  74981. protected _refreshRate: number;
  74982. protected _textureMatrix: Matrix;
  74983. protected _samples: number;
  74984. protected _renderTargetOptions: RenderTargetCreationOptions;
  74985. /**
  74986. * Gets render target creation options that were used.
  74987. */
  74988. readonly renderTargetOptions: RenderTargetCreationOptions;
  74989. protected _engine: Engine;
  74990. protected _onRatioRescale(): void;
  74991. /**
  74992. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  74993. * It must define where the camera used to render the texture is set
  74994. */
  74995. boundingBoxPosition: Vector3;
  74996. private _boundingBoxSize;
  74997. /**
  74998. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  74999. * When defined, the cubemap will switch to local mode
  75000. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  75001. * @example https://www.babylonjs-playground.com/#RNASML
  75002. */
  75003. boundingBoxSize: Vector3;
  75004. /**
  75005. * In case the RTT has been created with a depth texture, get the associated
  75006. * depth texture.
  75007. * Otherwise, return null.
  75008. */
  75009. depthStencilTexture: Nullable<InternalTexture>;
  75010. /**
  75011. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  75012. * or used a shadow, depth texture...
  75013. * @param name The friendly name of the texture
  75014. * @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)
  75015. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  75016. * @param generateMipMaps True if mip maps need to be generated after render.
  75017. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  75018. * @param type The type of the buffer in the RTT (int, half float, float...)
  75019. * @param isCube True if a cube texture needs to be created
  75020. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  75021. * @param generateDepthBuffer True to generate a depth buffer
  75022. * @param generateStencilBuffer True to generate a stencil buffer
  75023. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  75024. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  75025. * @param delayAllocation if the texture allocation should be delayed (default: false)
  75026. */
  75027. constructor(name: string, size: number | {
  75028. width: number;
  75029. height: number;
  75030. } | {
  75031. ratio: number;
  75032. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  75033. /**
  75034. * Creates a depth stencil texture.
  75035. * This is only available in WebGL 2 or with the depth texture extension available.
  75036. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  75037. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  75038. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  75039. */
  75040. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  75041. private _processSizeParameter;
  75042. /**
  75043. * Define the number of samples to use in case of MSAA.
  75044. * It defaults to one meaning no MSAA has been enabled.
  75045. */
  75046. samples: number;
  75047. /**
  75048. * Resets the refresh counter of the texture and start bak from scratch.
  75049. * Could be useful to regenerate the texture if it is setup to render only once.
  75050. */
  75051. resetRefreshCounter(): void;
  75052. /**
  75053. * Define the refresh rate of the texture or the rendering frequency.
  75054. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  75055. */
  75056. refreshRate: number;
  75057. /**
  75058. * Adds a post process to the render target rendering passes.
  75059. * @param postProcess define the post process to add
  75060. */
  75061. addPostProcess(postProcess: PostProcess): void;
  75062. /**
  75063. * Clear all the post processes attached to the render target
  75064. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  75065. */
  75066. clearPostProcesses(dispose?: boolean): void;
  75067. /**
  75068. * Remove one of the post process from the list of attached post processes to the texture
  75069. * @param postProcess define the post process to remove from the list
  75070. */
  75071. removePostProcess(postProcess: PostProcess): void;
  75072. /** @hidden */
  75073. _shouldRender(): boolean;
  75074. /**
  75075. * Gets the actual render size of the texture.
  75076. * @returns the width of the render size
  75077. */
  75078. getRenderSize(): number;
  75079. /**
  75080. * Gets the actual render width of the texture.
  75081. * @returns the width of the render size
  75082. */
  75083. getRenderWidth(): number;
  75084. /**
  75085. * Gets the actual render height of the texture.
  75086. * @returns the height of the render size
  75087. */
  75088. getRenderHeight(): number;
  75089. /**
  75090. * Get if the texture can be rescaled or not.
  75091. */
  75092. readonly canRescale: boolean;
  75093. /**
  75094. * Resize the texture using a ratio.
  75095. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  75096. */
  75097. scale(ratio: number): void;
  75098. /**
  75099. * Get the texture reflection matrix used to rotate/transform the reflection.
  75100. * @returns the reflection matrix
  75101. */
  75102. getReflectionTextureMatrix(): Matrix;
  75103. /**
  75104. * Resize the texture to a new desired size.
  75105. * Be carrefull as it will recreate all the data in the new texture.
  75106. * @param size Define the new size. It can be:
  75107. * - a number for squared texture,
  75108. * - an object containing { width: number, height: number }
  75109. * - or an object containing a ratio { ratio: number }
  75110. */
  75111. resize(size: number | {
  75112. width: number;
  75113. height: number;
  75114. } | {
  75115. ratio: number;
  75116. }): void;
  75117. /**
  75118. * Renders all the objects from the render list into the texture.
  75119. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  75120. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  75121. */
  75122. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  75123. private _bestReflectionRenderTargetDimension;
  75124. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  75125. private renderToTarget;
  75126. /**
  75127. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  75128. * This allowed control for front to back rendering or reversly depending of the special needs.
  75129. *
  75130. * @param renderingGroupId The rendering group id corresponding to its index
  75131. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  75132. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  75133. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  75134. */
  75135. 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;
  75136. /**
  75137. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  75138. *
  75139. * @param renderingGroupId The rendering group id corresponding to its index
  75140. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  75141. */
  75142. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  75143. /**
  75144. * Clones the texture.
  75145. * @returns the cloned texture
  75146. */
  75147. clone(): RenderTargetTexture;
  75148. /**
  75149. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  75150. * @returns The JSON representation of the texture
  75151. */
  75152. serialize(): any;
  75153. /**
  75154. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  75155. */
  75156. disposeFramebufferObjects(): void;
  75157. /**
  75158. * Dispose the texture and release its associated resources.
  75159. */
  75160. dispose(): void;
  75161. /** @hidden */
  75162. _rebuild(): void;
  75163. /**
  75164. * Clear the info related to rendering groups preventing retention point in material dispose.
  75165. */
  75166. freeRenderingGroups(): void;
  75167. }
  75168. }
  75169. declare module BABYLON {
  75170. /**
  75171. * Mirror texture can be used to simulate the view from a mirror in a scene.
  75172. * It will dynamically be rendered every frame to adapt to the camera point of view.
  75173. * You can then easily use it as a reflectionTexture on a flat surface.
  75174. * In case the surface is not a plane, please consider relying on reflection probes.
  75175. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  75176. */
  75177. export class MirrorTexture extends RenderTargetTexture {
  75178. private scene;
  75179. /**
  75180. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  75181. * 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.
  75182. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  75183. */
  75184. mirrorPlane: Plane;
  75185. /**
  75186. * Define the blur ratio used to blur the reflection if needed.
  75187. */
  75188. blurRatio: number;
  75189. /**
  75190. * Define the adaptive blur kernel used to blur the reflection if needed.
  75191. * This will autocompute the closest best match for the `blurKernel`
  75192. */
  75193. adaptiveBlurKernel: number;
  75194. /**
  75195. * Define the blur kernel used to blur the reflection if needed.
  75196. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  75197. */
  75198. blurKernel: number;
  75199. /**
  75200. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  75201. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  75202. */
  75203. blurKernelX: number;
  75204. /**
  75205. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  75206. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  75207. */
  75208. blurKernelY: number;
  75209. private _autoComputeBlurKernel;
  75210. protected _onRatioRescale(): void;
  75211. private _updateGammaSpace;
  75212. private _imageProcessingConfigChangeObserver;
  75213. private _transformMatrix;
  75214. private _mirrorMatrix;
  75215. private _savedViewMatrix;
  75216. private _blurX;
  75217. private _blurY;
  75218. private _adaptiveBlurKernel;
  75219. private _blurKernelX;
  75220. private _blurKernelY;
  75221. private _blurRatio;
  75222. /**
  75223. * Instantiates a Mirror Texture.
  75224. * Mirror texture can be used to simulate the view from a mirror in a scene.
  75225. * It will dynamically be rendered every frame to adapt to the camera point of view.
  75226. * You can then easily use it as a reflectionTexture on a flat surface.
  75227. * In case the surface is not a plane, please consider relying on reflection probes.
  75228. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  75229. * @param name
  75230. * @param size
  75231. * @param scene
  75232. * @param generateMipMaps
  75233. * @param type
  75234. * @param samplingMode
  75235. * @param generateDepthBuffer
  75236. */
  75237. constructor(name: string, size: number | {
  75238. width: number;
  75239. height: number;
  75240. } | {
  75241. ratio: number;
  75242. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  75243. private _preparePostProcesses;
  75244. /**
  75245. * Clone the mirror texture.
  75246. * @returns the cloned texture
  75247. */
  75248. clone(): MirrorTexture;
  75249. /**
  75250. * Serialize the texture to a JSON representation you could use in Parse later on
  75251. * @returns the serialized JSON representation
  75252. */
  75253. serialize(): any;
  75254. /**
  75255. * Dispose the texture and release its associated resources.
  75256. */
  75257. dispose(): void;
  75258. }
  75259. }
  75260. declare module BABYLON {
  75261. /**
  75262. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  75263. * @see http://doc.babylonjs.com/babylon101/materials#texture
  75264. */
  75265. export class Texture extends BaseTexture {
  75266. /** @hidden */
  75267. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  75268. /** @hidden */
  75269. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  75270. /** @hidden */
  75271. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  75272. /** nearest is mag = nearest and min = nearest and mip = linear */
  75273. static readonly NEAREST_SAMPLINGMODE: number;
  75274. /** nearest is mag = nearest and min = nearest and mip = linear */
  75275. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  75276. /** Bilinear is mag = linear and min = linear and mip = nearest */
  75277. static readonly BILINEAR_SAMPLINGMODE: number;
  75278. /** Bilinear is mag = linear and min = linear and mip = nearest */
  75279. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  75280. /** Trilinear is mag = linear and min = linear and mip = linear */
  75281. static readonly TRILINEAR_SAMPLINGMODE: number;
  75282. /** Trilinear is mag = linear and min = linear and mip = linear */
  75283. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  75284. /** mag = nearest and min = nearest and mip = nearest */
  75285. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  75286. /** mag = nearest and min = linear and mip = nearest */
  75287. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  75288. /** mag = nearest and min = linear and mip = linear */
  75289. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  75290. /** mag = nearest and min = linear and mip = none */
  75291. static readonly NEAREST_LINEAR: number;
  75292. /** mag = nearest and min = nearest and mip = none */
  75293. static readonly NEAREST_NEAREST: number;
  75294. /** mag = linear and min = nearest and mip = nearest */
  75295. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  75296. /** mag = linear and min = nearest and mip = linear */
  75297. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  75298. /** mag = linear and min = linear and mip = none */
  75299. static readonly LINEAR_LINEAR: number;
  75300. /** mag = linear and min = nearest and mip = none */
  75301. static readonly LINEAR_NEAREST: number;
  75302. /** Explicit coordinates mode */
  75303. static readonly EXPLICIT_MODE: number;
  75304. /** Spherical coordinates mode */
  75305. static readonly SPHERICAL_MODE: number;
  75306. /** Planar coordinates mode */
  75307. static readonly PLANAR_MODE: number;
  75308. /** Cubic coordinates mode */
  75309. static readonly CUBIC_MODE: number;
  75310. /** Projection coordinates mode */
  75311. static readonly PROJECTION_MODE: number;
  75312. /** Inverse Cubic coordinates mode */
  75313. static readonly SKYBOX_MODE: number;
  75314. /** Inverse Cubic coordinates mode */
  75315. static readonly INVCUBIC_MODE: number;
  75316. /** Equirectangular coordinates mode */
  75317. static readonly EQUIRECTANGULAR_MODE: number;
  75318. /** Equirectangular Fixed coordinates mode */
  75319. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  75320. /** Equirectangular Fixed Mirrored coordinates mode */
  75321. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  75322. /** Texture is not repeating outside of 0..1 UVs */
  75323. static readonly CLAMP_ADDRESSMODE: number;
  75324. /** Texture is repeating outside of 0..1 UVs */
  75325. static readonly WRAP_ADDRESSMODE: number;
  75326. /** Texture is repeating and mirrored */
  75327. static readonly MIRROR_ADDRESSMODE: number;
  75328. /**
  75329. * 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
  75330. */
  75331. static UseSerializedUrlIfAny: boolean;
  75332. /**
  75333. * Define the url of the texture.
  75334. */
  75335. url: Nullable<string>;
  75336. /**
  75337. * Define an offset on the texture to offset the u coordinates of the UVs
  75338. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  75339. */
  75340. uOffset: number;
  75341. /**
  75342. * Define an offset on the texture to offset the v coordinates of the UVs
  75343. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  75344. */
  75345. vOffset: number;
  75346. /**
  75347. * Define an offset on the texture to scale the u coordinates of the UVs
  75348. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  75349. */
  75350. uScale: number;
  75351. /**
  75352. * Define an offset on the texture to scale the v coordinates of the UVs
  75353. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  75354. */
  75355. vScale: number;
  75356. /**
  75357. * Define an offset on the texture to rotate around the u coordinates of the UVs
  75358. * @see http://doc.babylonjs.com/how_to/more_materials
  75359. */
  75360. uAng: number;
  75361. /**
  75362. * Define an offset on the texture to rotate around the v coordinates of the UVs
  75363. * @see http://doc.babylonjs.com/how_to/more_materials
  75364. */
  75365. vAng: number;
  75366. /**
  75367. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  75368. * @see http://doc.babylonjs.com/how_to/more_materials
  75369. */
  75370. wAng: number;
  75371. /**
  75372. * Defines the center of rotation (U)
  75373. */
  75374. uRotationCenter: number;
  75375. /**
  75376. * Defines the center of rotation (V)
  75377. */
  75378. vRotationCenter: number;
  75379. /**
  75380. * Defines the center of rotation (W)
  75381. */
  75382. wRotationCenter: number;
  75383. /**
  75384. * Are mip maps generated for this texture or not.
  75385. */
  75386. readonly noMipmap: boolean;
  75387. private _noMipmap;
  75388. /** @hidden */
  75389. _invertY: boolean;
  75390. private _rowGenerationMatrix;
  75391. private _cachedTextureMatrix;
  75392. private _projectionModeMatrix;
  75393. private _t0;
  75394. private _t1;
  75395. private _t2;
  75396. private _cachedUOffset;
  75397. private _cachedVOffset;
  75398. private _cachedUScale;
  75399. private _cachedVScale;
  75400. private _cachedUAng;
  75401. private _cachedVAng;
  75402. private _cachedWAng;
  75403. private _cachedProjectionMatrixId;
  75404. private _cachedCoordinatesMode;
  75405. /** @hidden */
  75406. protected _initialSamplingMode: number;
  75407. /** @hidden */
  75408. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  75409. private _deleteBuffer;
  75410. protected _format: Nullable<number>;
  75411. private _delayedOnLoad;
  75412. private _delayedOnError;
  75413. /**
  75414. * Observable triggered once the texture has been loaded.
  75415. */
  75416. onLoadObservable: Observable<Texture>;
  75417. protected _isBlocking: boolean;
  75418. /**
  75419. * Is the texture preventing material to render while loading.
  75420. * If false, a default texture will be used instead of the loading one during the preparation step.
  75421. */
  75422. isBlocking: boolean;
  75423. /**
  75424. * Get the current sampling mode associated with the texture.
  75425. */
  75426. readonly samplingMode: number;
  75427. /**
  75428. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  75429. */
  75430. readonly invertY: boolean;
  75431. /**
  75432. * Instantiates a new texture.
  75433. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  75434. * @see http://doc.babylonjs.com/babylon101/materials#texture
  75435. * @param url define the url of the picture to load as a texture
  75436. * @param scene define the scene the texture will belong to
  75437. * @param noMipmap define if the texture will require mip maps or not
  75438. * @param invertY define if the texture needs to be inverted on the y axis during loading
  75439. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  75440. * @param onLoad define a callback triggered when the texture has been loaded
  75441. * @param onError define a callback triggered when an error occurred during the loading session
  75442. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  75443. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  75444. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  75445. */
  75446. 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);
  75447. /**
  75448. * Update the url (and optional buffer) of this texture if url was null during construction.
  75449. * @param url the url of the texture
  75450. * @param buffer the buffer of the texture (defaults to null)
  75451. * @param onLoad callback called when the texture is loaded (defaults to null)
  75452. */
  75453. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  75454. /**
  75455. * Finish the loading sequence of a texture flagged as delayed load.
  75456. * @hidden
  75457. */
  75458. delayLoad(): void;
  75459. private _prepareRowForTextureGeneration;
  75460. /**
  75461. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  75462. * @returns the transform matrix of the texture.
  75463. */
  75464. getTextureMatrix(): Matrix;
  75465. /**
  75466. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  75467. * @returns The reflection texture transform
  75468. */
  75469. getReflectionTextureMatrix(): Matrix;
  75470. /**
  75471. * Clones the texture.
  75472. * @returns the cloned texture
  75473. */
  75474. clone(): Texture;
  75475. /**
  75476. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  75477. * @returns The JSON representation of the texture
  75478. */
  75479. serialize(): any;
  75480. /**
  75481. * Get the current class name of the texture useful for serialization or dynamic coding.
  75482. * @returns "Texture"
  75483. */
  75484. getClassName(): string;
  75485. /**
  75486. * Dispose the texture and release its associated resources.
  75487. */
  75488. dispose(): void;
  75489. /**
  75490. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  75491. * @param parsedTexture Define the JSON representation of the texture
  75492. * @param scene Define the scene the parsed texture should be instantiated in
  75493. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  75494. * @returns The parsed texture if successful
  75495. */
  75496. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  75497. /**
  75498. * Creates a texture from its base 64 representation.
  75499. * @param data Define the base64 payload without the data: prefix
  75500. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  75501. * @param scene Define the scene the texture should belong to
  75502. * @param noMipmap Forces the texture to not create mip map information if true
  75503. * @param invertY define if the texture needs to be inverted on the y axis during loading
  75504. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  75505. * @param onLoad define a callback triggered when the texture has been loaded
  75506. * @param onError define a callback triggered when an error occurred during the loading session
  75507. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  75508. * @returns the created texture
  75509. */
  75510. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  75511. /**
  75512. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  75513. * @param data Define the base64 payload without the data: prefix
  75514. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  75515. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  75516. * @param scene Define the scene the texture should belong to
  75517. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  75518. * @param noMipmap Forces the texture to not create mip map information if true
  75519. * @param invertY define if the texture needs to be inverted on the y axis during loading
  75520. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  75521. * @param onLoad define a callback triggered when the texture has been loaded
  75522. * @param onError define a callback triggered when an error occurred during the loading session
  75523. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  75524. * @returns the created texture
  75525. */
  75526. 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;
  75527. }
  75528. }
  75529. declare module BABYLON {
  75530. /**
  75531. * Raw texture can help creating a texture directly from an array of data.
  75532. * This can be super useful if you either get the data from an uncompressed source or
  75533. * if you wish to create your texture pixel by pixel.
  75534. */
  75535. export class RawTexture extends Texture {
  75536. /**
  75537. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  75538. */
  75539. format: number;
  75540. private _engine;
  75541. /**
  75542. * Instantiates a new RawTexture.
  75543. * Raw texture can help creating a texture directly from an array of data.
  75544. * This can be super useful if you either get the data from an uncompressed source or
  75545. * if you wish to create your texture pixel by pixel.
  75546. * @param data define the array of data to use to create the texture
  75547. * @param width define the width of the texture
  75548. * @param height define the height of the texture
  75549. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  75550. * @param scene define the scene the texture belongs to
  75551. * @param generateMipMaps define whether mip maps should be generated or not
  75552. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  75553. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  75554. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  75555. */
  75556. constructor(data: ArrayBufferView, width: number, height: number,
  75557. /**
  75558. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  75559. */
  75560. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  75561. /**
  75562. * Updates the texture underlying data.
  75563. * @param data Define the new data of the texture
  75564. */
  75565. update(data: ArrayBufferView): void;
  75566. /**
  75567. * Creates a luminance texture from some data.
  75568. * @param data Define the texture data
  75569. * @param width Define the width of the texture
  75570. * @param height Define the height of the texture
  75571. * @param scene Define the scene the texture belongs to
  75572. * @param generateMipMaps Define whether or not to create mip maps for the texture
  75573. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  75574. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  75575. * @returns the luminance texture
  75576. */
  75577. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  75578. /**
  75579. * Creates a luminance alpha texture from some data.
  75580. * @param data Define the texture data
  75581. * @param width Define the width of the texture
  75582. * @param height Define the height of the texture
  75583. * @param scene Define the scene the texture belongs to
  75584. * @param generateMipMaps Define whether or not to create mip maps for the texture
  75585. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  75586. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  75587. * @returns the luminance alpha texture
  75588. */
  75589. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  75590. /**
  75591. * Creates an alpha texture from some data.
  75592. * @param data Define the texture data
  75593. * @param width Define the width of the texture
  75594. * @param height Define the height of the texture
  75595. * @param scene Define the scene the texture belongs to
  75596. * @param generateMipMaps Define whether or not to create mip maps for the texture
  75597. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  75598. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  75599. * @returns the alpha texture
  75600. */
  75601. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  75602. /**
  75603. * Creates a RGB texture from some data.
  75604. * @param data Define the texture data
  75605. * @param width Define the width of the texture
  75606. * @param height Define the height of the texture
  75607. * @param scene Define the scene the texture belongs to
  75608. * @param generateMipMaps Define whether or not to create mip maps for the texture
  75609. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  75610. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  75611. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  75612. * @returns the RGB alpha texture
  75613. */
  75614. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  75615. /**
  75616. * Creates a RGBA texture from some data.
  75617. * @param data Define the texture data
  75618. * @param width Define the width of the texture
  75619. * @param height Define the height of the texture
  75620. * @param scene Define the scene the texture belongs to
  75621. * @param generateMipMaps Define whether or not to create mip maps for the texture
  75622. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  75623. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  75624. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  75625. * @returns the RGBA texture
  75626. */
  75627. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  75628. /**
  75629. * Creates a R texture from some data.
  75630. * @param data Define the texture data
  75631. * @param width Define the width of the texture
  75632. * @param height Define the height of the texture
  75633. * @param scene Define the scene the texture belongs to
  75634. * @param generateMipMaps Define whether or not to create mip maps for the texture
  75635. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  75636. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  75637. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  75638. * @returns the R texture
  75639. */
  75640. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  75641. }
  75642. }
  75643. declare module BABYLON {
  75644. /**
  75645. * Defines a runtime animation
  75646. */
  75647. export class RuntimeAnimation {
  75648. private _events;
  75649. /**
  75650. * The current frame of the runtime animation
  75651. */
  75652. private _currentFrame;
  75653. /**
  75654. * The animation used by the runtime animation
  75655. */
  75656. private _animation;
  75657. /**
  75658. * The target of the runtime animation
  75659. */
  75660. private _target;
  75661. /**
  75662. * The initiating animatable
  75663. */
  75664. private _host;
  75665. /**
  75666. * The original value of the runtime animation
  75667. */
  75668. private _originalValue;
  75669. /**
  75670. * The original blend value of the runtime animation
  75671. */
  75672. private _originalBlendValue;
  75673. /**
  75674. * The offsets cache of the runtime animation
  75675. */
  75676. private _offsetsCache;
  75677. /**
  75678. * The high limits cache of the runtime animation
  75679. */
  75680. private _highLimitsCache;
  75681. /**
  75682. * Specifies if the runtime animation has been stopped
  75683. */
  75684. private _stopped;
  75685. /**
  75686. * The blending factor of the runtime animation
  75687. */
  75688. private _blendingFactor;
  75689. /**
  75690. * The BabylonJS scene
  75691. */
  75692. private _scene;
  75693. /**
  75694. * The current value of the runtime animation
  75695. */
  75696. private _currentValue;
  75697. /** @hidden */
  75698. _workValue: any;
  75699. /**
  75700. * The active target of the runtime animation
  75701. */
  75702. private _activeTarget;
  75703. /**
  75704. * The target path of the runtime animation
  75705. */
  75706. private _targetPath;
  75707. /**
  75708. * The weight of the runtime animation
  75709. */
  75710. private _weight;
  75711. /**
  75712. * The ratio offset of the runtime animation
  75713. */
  75714. private _ratioOffset;
  75715. /**
  75716. * The previous delay of the runtime animation
  75717. */
  75718. private _previousDelay;
  75719. /**
  75720. * The previous ratio of the runtime animation
  75721. */
  75722. private _previousRatio;
  75723. /**
  75724. * Gets the current frame of the runtime animation
  75725. */
  75726. readonly currentFrame: number;
  75727. /**
  75728. * Gets the weight of the runtime animation
  75729. */
  75730. readonly weight: number;
  75731. /**
  75732. * Gets the current value of the runtime animation
  75733. */
  75734. readonly currentValue: any;
  75735. /**
  75736. * Gets the target path of the runtime animation
  75737. */
  75738. readonly targetPath: string;
  75739. /**
  75740. * Gets the actual target of the runtime animation
  75741. */
  75742. readonly target: any;
  75743. /**
  75744. * Create a new RuntimeAnimation object
  75745. * @param target defines the target of the animation
  75746. * @param animation defines the source animation object
  75747. * @param scene defines the hosting scene
  75748. * @param host defines the initiating Animatable
  75749. */
  75750. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  75751. /**
  75752. * Gets the animation from the runtime animation
  75753. */
  75754. readonly animation: Animation;
  75755. /**
  75756. * Resets the runtime animation to the beginning
  75757. * @param restoreOriginal defines whether to restore the target property to the original value
  75758. */
  75759. reset(restoreOriginal?: boolean): void;
  75760. /**
  75761. * Specifies if the runtime animation is stopped
  75762. * @returns Boolean specifying if the runtime animation is stopped
  75763. */
  75764. isStopped(): boolean;
  75765. /**
  75766. * Disposes of the runtime animation
  75767. */
  75768. dispose(): void;
  75769. /**
  75770. * Interpolates the animation from the current frame
  75771. * @param currentFrame The frame to interpolate the animation to
  75772. * @param repeatCount The number of times that the animation should loop
  75773. * @param loopMode The type of looping mode to use
  75774. * @param offsetValue Animation offset value
  75775. * @param highLimitValue The high limit value
  75776. * @returns The interpolated value
  75777. */
  75778. private _interpolate;
  75779. /**
  75780. * Apply the interpolated value to the target
  75781. * @param currentValue defines the value computed by the animation
  75782. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  75783. */
  75784. setValue(currentValue: any, weight?: number): void;
  75785. private _setValue;
  75786. /**
  75787. * Gets the loop pmode of the runtime animation
  75788. * @returns Loop Mode
  75789. */
  75790. private _getCorrectLoopMode;
  75791. /**
  75792. * Move the current animation to a given frame
  75793. * @param frame defines the frame to move to
  75794. */
  75795. goToFrame(frame: number): void;
  75796. /**
  75797. * @hidden Internal use only
  75798. */
  75799. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  75800. /**
  75801. * Execute the current animation
  75802. * @param delay defines the delay to add to the current frame
  75803. * @param from defines the lower bound of the animation range
  75804. * @param to defines the upper bound of the animation range
  75805. * @param loop defines if the current animation must loop
  75806. * @param speedRatio defines the current speed ratio
  75807. * @param weight defines the weight of the animation (default is -1 so no weight)
  75808. * @param onLoop optional callback called when animation loops
  75809. * @returns a boolean indicating if the animation is running
  75810. */
  75811. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number, onLoop?: () => void): boolean;
  75812. }
  75813. }
  75814. declare module BABYLON {
  75815. /**
  75816. * Class used to store an actual running animation
  75817. */
  75818. export class Animatable {
  75819. /** defines the target object */
  75820. target: any;
  75821. /** defines the starting frame number (default is 0) */
  75822. fromFrame: number;
  75823. /** defines the ending frame number (default is 100) */
  75824. toFrame: number;
  75825. /** defines if the animation must loop (default is false) */
  75826. loopAnimation: boolean;
  75827. /** defines a callback to call when animation ends if it is not looping */
  75828. onAnimationEnd?: (() => void) | null | undefined;
  75829. /** defines a callback to call when animation loops */
  75830. onAnimationLoop?: (() => void) | null | undefined;
  75831. private _localDelayOffset;
  75832. private _pausedDelay;
  75833. private _runtimeAnimations;
  75834. private _paused;
  75835. private _scene;
  75836. private _speedRatio;
  75837. private _weight;
  75838. private _syncRoot;
  75839. /**
  75840. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  75841. * This will only apply for non looping animation (default is true)
  75842. */
  75843. disposeOnEnd: boolean;
  75844. /**
  75845. * Gets a boolean indicating if the animation has started
  75846. */
  75847. animationStarted: boolean;
  75848. /**
  75849. * Observer raised when the animation ends
  75850. */
  75851. onAnimationEndObservable: Observable<Animatable>;
  75852. /**
  75853. * Observer raised when the animation loops
  75854. */
  75855. onAnimationLoopObservable: Observable<Animatable>;
  75856. /**
  75857. * Gets the root Animatable used to synchronize and normalize animations
  75858. */
  75859. readonly syncRoot: Animatable;
  75860. /**
  75861. * Gets the current frame of the first RuntimeAnimation
  75862. * Used to synchronize Animatables
  75863. */
  75864. readonly masterFrame: number;
  75865. /**
  75866. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  75867. */
  75868. weight: number;
  75869. /**
  75870. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  75871. */
  75872. speedRatio: number;
  75873. /**
  75874. * Creates a new Animatable
  75875. * @param scene defines the hosting scene
  75876. * @param target defines the target object
  75877. * @param fromFrame defines the starting frame number (default is 0)
  75878. * @param toFrame defines the ending frame number (default is 100)
  75879. * @param loopAnimation defines if the animation must loop (default is false)
  75880. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  75881. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  75882. * @param animations defines a group of animation to add to the new Animatable
  75883. * @param onAnimationLoop defines a callback to call when animation loops
  75884. */
  75885. constructor(scene: Scene,
  75886. /** defines the target object */
  75887. target: any,
  75888. /** defines the starting frame number (default is 0) */
  75889. fromFrame?: number,
  75890. /** defines the ending frame number (default is 100) */
  75891. toFrame?: number,
  75892. /** defines if the animation must loop (default is false) */
  75893. loopAnimation?: boolean, speedRatio?: number,
  75894. /** defines a callback to call when animation ends if it is not looping */
  75895. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  75896. /** defines a callback to call when animation loops */
  75897. onAnimationLoop?: (() => void) | null | undefined);
  75898. /**
  75899. * Synchronize and normalize current Animatable with a source Animatable
  75900. * This is useful when using animation weights and when animations are not of the same length
  75901. * @param root defines the root Animatable to synchronize with
  75902. * @returns the current Animatable
  75903. */
  75904. syncWith(root: Animatable): Animatable;
  75905. /**
  75906. * Gets the list of runtime animations
  75907. * @returns an array of RuntimeAnimation
  75908. */
  75909. getAnimations(): RuntimeAnimation[];
  75910. /**
  75911. * Adds more animations to the current animatable
  75912. * @param target defines the target of the animations
  75913. * @param animations defines the new animations to add
  75914. */
  75915. appendAnimations(target: any, animations: Animation[]): void;
  75916. /**
  75917. * Gets the source animation for a specific property
  75918. * @param property defines the propertyu to look for
  75919. * @returns null or the source animation for the given property
  75920. */
  75921. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  75922. /**
  75923. * Gets the runtime animation for a specific property
  75924. * @param property defines the propertyu to look for
  75925. * @returns null or the runtime animation for the given property
  75926. */
  75927. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  75928. /**
  75929. * Resets the animatable to its original state
  75930. */
  75931. reset(): void;
  75932. /**
  75933. * Allows the animatable to blend with current running animations
  75934. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  75935. * @param blendingSpeed defines the blending speed to use
  75936. */
  75937. enableBlending(blendingSpeed: number): void;
  75938. /**
  75939. * Disable animation blending
  75940. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  75941. */
  75942. disableBlending(): void;
  75943. /**
  75944. * Jump directly to a given frame
  75945. * @param frame defines the frame to jump to
  75946. */
  75947. goToFrame(frame: number): void;
  75948. /**
  75949. * Pause the animation
  75950. */
  75951. pause(): void;
  75952. /**
  75953. * Restart the animation
  75954. */
  75955. restart(): void;
  75956. private _raiseOnAnimationEnd;
  75957. /**
  75958. * Stop and delete the current animation
  75959. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  75960. * @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)
  75961. */
  75962. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  75963. /**
  75964. * Wait asynchronously for the animation to end
  75965. * @returns a promise which will be fullfilled when the animation ends
  75966. */
  75967. waitAsync(): Promise<Animatable>;
  75968. /** @hidden */
  75969. _animate(delay: number): boolean;
  75970. }
  75971. interface Scene {
  75972. /** @hidden */
  75973. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  75974. /** @hidden */
  75975. _processLateAnimationBindingsForMatrices(holder: {
  75976. totalWeight: number;
  75977. animations: RuntimeAnimation[];
  75978. originalValue: Matrix;
  75979. }): any;
  75980. /** @hidden */
  75981. _processLateAnimationBindingsForQuaternions(holder: {
  75982. totalWeight: number;
  75983. animations: RuntimeAnimation[];
  75984. originalValue: Quaternion;
  75985. }, refQuaternion: Quaternion): Quaternion;
  75986. /** @hidden */
  75987. _processLateAnimationBindings(): void;
  75988. /**
  75989. * Will start the animation sequence of a given target
  75990. * @param target defines the target
  75991. * @param from defines from which frame should animation start
  75992. * @param to defines until which frame should animation run.
  75993. * @param weight defines the weight to apply to the animation (1.0 by default)
  75994. * @param loop defines if the animation loops
  75995. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  75996. * @param onAnimationEnd defines the function to be executed when the animation ends
  75997. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  75998. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  75999. * @param onAnimationLoop defines the callback to call when an animation loops
  76000. * @returns the animatable object created for this animation
  76001. */
  76002. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  76003. /**
  76004. * Will start the animation sequence of a given target
  76005. * @param target defines the target
  76006. * @param from defines from which frame should animation start
  76007. * @param to defines until which frame should animation run.
  76008. * @param loop defines if the animation loops
  76009. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  76010. * @param onAnimationEnd defines the function to be executed when the animation ends
  76011. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  76012. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  76013. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  76014. * @param onAnimationLoop defines the callback to call when an animation loops
  76015. * @returns the animatable object created for this animation
  76016. */
  76017. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  76018. /**
  76019. * Will start the animation sequence of a given target and its hierarchy
  76020. * @param target defines the target
  76021. * @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.
  76022. * @param from defines from which frame should animation start
  76023. * @param to defines until which frame should animation run.
  76024. * @param loop defines if the animation loops
  76025. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  76026. * @param onAnimationEnd defines the function to be executed when the animation ends
  76027. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  76028. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  76029. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  76030. * @param onAnimationLoop defines the callback to call when an animation loops
  76031. * @returns the list of created animatables
  76032. */
  76033. 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[];
  76034. /**
  76035. * Begin a new animation on a given node
  76036. * @param target defines the target where the animation will take place
  76037. * @param animations defines the list of animations to start
  76038. * @param from defines the initial value
  76039. * @param to defines the final value
  76040. * @param loop defines if you want animation to loop (off by default)
  76041. * @param speedRatio defines the speed ratio to apply to all animations
  76042. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  76043. * @param onAnimationLoop defines the callback to call when an animation loops
  76044. * @returns the list of created animatables
  76045. */
  76046. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  76047. /**
  76048. * Begin a new animation on a given node and its hierarchy
  76049. * @param target defines the root node where the animation will take place
  76050. * @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.
  76051. * @param animations defines the list of animations to start
  76052. * @param from defines the initial value
  76053. * @param to defines the final value
  76054. * @param loop defines if you want animation to loop (off by default)
  76055. * @param speedRatio defines the speed ratio to apply to all animations
  76056. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  76057. * @param onAnimationLoop defines the callback to call when an animation loops
  76058. * @returns the list of animatables created for all nodes
  76059. */
  76060. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  76061. /**
  76062. * Gets the animatable associated with a specific target
  76063. * @param target defines the target of the animatable
  76064. * @returns the required animatable if found
  76065. */
  76066. getAnimatableByTarget(target: any): Nullable<Animatable>;
  76067. /**
  76068. * Gets all animatables associated with a given target
  76069. * @param target defines the target to look animatables for
  76070. * @returns an array of Animatables
  76071. */
  76072. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  76073. /**
  76074. * Will stop the animation of the given target
  76075. * @param target - the target
  76076. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  76077. * @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)
  76078. */
  76079. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  76080. /**
  76081. * Stops and removes all animations that have been applied to the scene
  76082. */
  76083. stopAllAnimations(): void;
  76084. }
  76085. interface Bone {
  76086. /**
  76087. * Copy an animation range from another bone
  76088. * @param source defines the source bone
  76089. * @param rangeName defines the range name to copy
  76090. * @param frameOffset defines the frame offset
  76091. * @param rescaleAsRequired defines if rescaling must be applied if required
  76092. * @param skelDimensionsRatio defines the scaling ratio
  76093. * @returns true if operation was successful
  76094. */
  76095. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  76096. }
  76097. }
  76098. declare module BABYLON {
  76099. /**
  76100. * Class used to handle skinning animations
  76101. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  76102. */
  76103. export class Skeleton implements IAnimatable {
  76104. /** defines the skeleton name */
  76105. name: string;
  76106. /** defines the skeleton Id */
  76107. id: string;
  76108. /**
  76109. * Defines the list of child bones
  76110. */
  76111. bones: Bone[];
  76112. /**
  76113. * Defines an estimate of the dimension of the skeleton at rest
  76114. */
  76115. dimensionsAtRest: Vector3;
  76116. /**
  76117. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  76118. */
  76119. needInitialSkinMatrix: boolean;
  76120. /**
  76121. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  76122. */
  76123. overrideMesh: Nullable<AbstractMesh>;
  76124. /**
  76125. * Gets the list of animations attached to this skeleton
  76126. */
  76127. animations: Array<Animation>;
  76128. private _scene;
  76129. private _isDirty;
  76130. private _transformMatrices;
  76131. private _transformMatrixTexture;
  76132. private _meshesWithPoseMatrix;
  76133. private _animatables;
  76134. private _identity;
  76135. private _synchronizedWithMesh;
  76136. private _ranges;
  76137. private _lastAbsoluteTransformsUpdateId;
  76138. private _canUseTextureForBones;
  76139. /** @hidden */
  76140. _numBonesWithLinkedTransformNode: number;
  76141. /**
  76142. * Specifies if the skeleton should be serialized
  76143. */
  76144. doNotSerialize: boolean;
  76145. /**
  76146. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  76147. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  76148. */
  76149. useTextureToStoreBoneMatrices: boolean;
  76150. private _animationPropertiesOverride;
  76151. /**
  76152. * Gets or sets the animation properties override
  76153. */
  76154. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  76155. /**
  76156. * An observable triggered before computing the skeleton's matrices
  76157. */
  76158. onBeforeComputeObservable: Observable<Skeleton>;
  76159. /**
  76160. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  76161. */
  76162. readonly isUsingTextureForMatrices: boolean;
  76163. /**
  76164. * Creates a new skeleton
  76165. * @param name defines the skeleton name
  76166. * @param id defines the skeleton Id
  76167. * @param scene defines the hosting scene
  76168. */
  76169. constructor(
  76170. /** defines the skeleton name */
  76171. name: string,
  76172. /** defines the skeleton Id */
  76173. id: string, scene: Scene);
  76174. /**
  76175. * Gets the current object class name.
  76176. * @return the class name
  76177. */
  76178. getClassName(): string;
  76179. /**
  76180. * Returns an array containing the root bones
  76181. * @returns an array containing the root bones
  76182. */
  76183. getChildren(): Array<Bone>;
  76184. /**
  76185. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  76186. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  76187. * @returns a Float32Array containing matrices data
  76188. */
  76189. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  76190. /**
  76191. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  76192. * @returns a raw texture containing the data
  76193. */
  76194. getTransformMatrixTexture(): Nullable<RawTexture>;
  76195. /**
  76196. * Gets the current hosting scene
  76197. * @returns a scene object
  76198. */
  76199. getScene(): Scene;
  76200. /**
  76201. * Gets a string representing the current skeleton data
  76202. * @param fullDetails defines a boolean indicating if we want a verbose version
  76203. * @returns a string representing the current skeleton data
  76204. */
  76205. toString(fullDetails?: boolean): string;
  76206. /**
  76207. * Get bone's index searching by name
  76208. * @param name defines bone's name to search for
  76209. * @return the indice of the bone. Returns -1 if not found
  76210. */
  76211. getBoneIndexByName(name: string): number;
  76212. /**
  76213. * Creater a new animation range
  76214. * @param name defines the name of the range
  76215. * @param from defines the start key
  76216. * @param to defines the end key
  76217. */
  76218. createAnimationRange(name: string, from: number, to: number): void;
  76219. /**
  76220. * Delete a specific animation range
  76221. * @param name defines the name of the range
  76222. * @param deleteFrames defines if frames must be removed as well
  76223. */
  76224. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  76225. /**
  76226. * Gets a specific animation range
  76227. * @param name defines the name of the range to look for
  76228. * @returns the requested animation range or null if not found
  76229. */
  76230. getAnimationRange(name: string): Nullable<AnimationRange>;
  76231. /**
  76232. * Gets the list of all animation ranges defined on this skeleton
  76233. * @returns an array
  76234. */
  76235. getAnimationRanges(): Nullable<AnimationRange>[];
  76236. /**
  76237. * Copy animation range from a source skeleton.
  76238. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  76239. * @param source defines the source skeleton
  76240. * @param name defines the name of the range to copy
  76241. * @param rescaleAsRequired defines if rescaling must be applied if required
  76242. * @returns true if operation was successful
  76243. */
  76244. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  76245. /**
  76246. * Forces the skeleton to go to rest pose
  76247. */
  76248. returnToRest(): void;
  76249. private _getHighestAnimationFrame;
  76250. /**
  76251. * Begin a specific animation range
  76252. * @param name defines the name of the range to start
  76253. * @param loop defines if looping must be turned on (false by default)
  76254. * @param speedRatio defines the speed ratio to apply (1 by default)
  76255. * @param onAnimationEnd defines a callback which will be called when animation will end
  76256. * @returns a new animatable
  76257. */
  76258. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  76259. /** @hidden */
  76260. _markAsDirty(): void;
  76261. /** @hidden */
  76262. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  76263. /** @hidden */
  76264. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  76265. private _computeTransformMatrices;
  76266. /**
  76267. * Build all resources required to render a skeleton
  76268. */
  76269. prepare(): void;
  76270. /**
  76271. * Gets the list of animatables currently running for this skeleton
  76272. * @returns an array of animatables
  76273. */
  76274. getAnimatables(): IAnimatable[];
  76275. /**
  76276. * Clone the current skeleton
  76277. * @param name defines the name of the new skeleton
  76278. * @param id defines the id of the enw skeleton
  76279. * @returns the new skeleton
  76280. */
  76281. clone(name: string, id: string): Skeleton;
  76282. /**
  76283. * Enable animation blending for this skeleton
  76284. * @param blendingSpeed defines the blending speed to apply
  76285. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  76286. */
  76287. enableBlending(blendingSpeed?: number): void;
  76288. /**
  76289. * Releases all resources associated with the current skeleton
  76290. */
  76291. dispose(): void;
  76292. /**
  76293. * Serialize the skeleton in a JSON object
  76294. * @returns a JSON object
  76295. */
  76296. serialize(): any;
  76297. /**
  76298. * Creates a new skeleton from serialized data
  76299. * @param parsedSkeleton defines the serialized data
  76300. * @param scene defines the hosting scene
  76301. * @returns a new skeleton
  76302. */
  76303. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  76304. /**
  76305. * Compute all node absolute transforms
  76306. * @param forceUpdate defines if computation must be done even if cache is up to date
  76307. */
  76308. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  76309. /**
  76310. * Gets the root pose matrix
  76311. * @returns a matrix
  76312. */
  76313. getPoseMatrix(): Nullable<Matrix>;
  76314. /**
  76315. * Sorts bones per internal index
  76316. */
  76317. sortBones(): void;
  76318. private _sortBones;
  76319. }
  76320. }
  76321. declare module BABYLON {
  76322. /**
  76323. * Defines a target to use with MorphTargetManager
  76324. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  76325. */
  76326. export class MorphTarget implements IAnimatable {
  76327. /** defines the name of the target */
  76328. name: string;
  76329. /**
  76330. * Gets or sets the list of animations
  76331. */
  76332. animations: Animation[];
  76333. private _scene;
  76334. private _positions;
  76335. private _normals;
  76336. private _tangents;
  76337. private _influence;
  76338. /**
  76339. * Observable raised when the influence changes
  76340. */
  76341. onInfluenceChanged: Observable<boolean>;
  76342. /** @hidden */
  76343. _onDataLayoutChanged: Observable<void>;
  76344. /**
  76345. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  76346. */
  76347. influence: number;
  76348. /**
  76349. * Gets or sets the id of the morph Target
  76350. */
  76351. id: string;
  76352. private _animationPropertiesOverride;
  76353. /**
  76354. * Gets or sets the animation properties override
  76355. */
  76356. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  76357. /**
  76358. * Creates a new MorphTarget
  76359. * @param name defines the name of the target
  76360. * @param influence defines the influence to use
  76361. * @param scene defines the scene the morphtarget belongs to
  76362. */
  76363. constructor(
  76364. /** defines the name of the target */
  76365. name: string, influence?: number, scene?: Nullable<Scene>);
  76366. /**
  76367. * Gets a boolean defining if the target contains position data
  76368. */
  76369. readonly hasPositions: boolean;
  76370. /**
  76371. * Gets a boolean defining if the target contains normal data
  76372. */
  76373. readonly hasNormals: boolean;
  76374. /**
  76375. * Gets a boolean defining if the target contains tangent data
  76376. */
  76377. readonly hasTangents: boolean;
  76378. /**
  76379. * Affects position data to this target
  76380. * @param data defines the position data to use
  76381. */
  76382. setPositions(data: Nullable<FloatArray>): void;
  76383. /**
  76384. * Gets the position data stored in this target
  76385. * @returns a FloatArray containing the position data (or null if not present)
  76386. */
  76387. getPositions(): Nullable<FloatArray>;
  76388. /**
  76389. * Affects normal data to this target
  76390. * @param data defines the normal data to use
  76391. */
  76392. setNormals(data: Nullable<FloatArray>): void;
  76393. /**
  76394. * Gets the normal data stored in this target
  76395. * @returns a FloatArray containing the normal data (or null if not present)
  76396. */
  76397. getNormals(): Nullable<FloatArray>;
  76398. /**
  76399. * Affects tangent data to this target
  76400. * @param data defines the tangent data to use
  76401. */
  76402. setTangents(data: Nullable<FloatArray>): void;
  76403. /**
  76404. * Gets the tangent data stored in this target
  76405. * @returns a FloatArray containing the tangent data (or null if not present)
  76406. */
  76407. getTangents(): Nullable<FloatArray>;
  76408. /**
  76409. * Serializes the current target into a Serialization object
  76410. * @returns the serialized object
  76411. */
  76412. serialize(): any;
  76413. /**
  76414. * Returns the string "MorphTarget"
  76415. * @returns "MorphTarget"
  76416. */
  76417. getClassName(): string;
  76418. /**
  76419. * Creates a new target from serialized data
  76420. * @param serializationObject defines the serialized data to use
  76421. * @returns a new MorphTarget
  76422. */
  76423. static Parse(serializationObject: any): MorphTarget;
  76424. /**
  76425. * Creates a MorphTarget from mesh data
  76426. * @param mesh defines the source mesh
  76427. * @param name defines the name to use for the new target
  76428. * @param influence defines the influence to attach to the target
  76429. * @returns a new MorphTarget
  76430. */
  76431. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  76432. }
  76433. }
  76434. declare module BABYLON {
  76435. /**
  76436. * This class is used to deform meshes using morphing between different targets
  76437. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  76438. */
  76439. export class MorphTargetManager {
  76440. private _targets;
  76441. private _targetInfluenceChangedObservers;
  76442. private _targetDataLayoutChangedObservers;
  76443. private _activeTargets;
  76444. private _scene;
  76445. private _influences;
  76446. private _supportsNormals;
  76447. private _supportsTangents;
  76448. private _vertexCount;
  76449. private _uniqueId;
  76450. private _tempInfluences;
  76451. /**
  76452. * Creates a new MorphTargetManager
  76453. * @param scene defines the current scene
  76454. */
  76455. constructor(scene?: Nullable<Scene>);
  76456. /**
  76457. * Gets the unique ID of this manager
  76458. */
  76459. readonly uniqueId: number;
  76460. /**
  76461. * Gets the number of vertices handled by this manager
  76462. */
  76463. readonly vertexCount: number;
  76464. /**
  76465. * Gets a boolean indicating if this manager supports morphing of normals
  76466. */
  76467. readonly supportsNormals: boolean;
  76468. /**
  76469. * Gets a boolean indicating if this manager supports morphing of tangents
  76470. */
  76471. readonly supportsTangents: boolean;
  76472. /**
  76473. * Gets the number of targets stored in this manager
  76474. */
  76475. readonly numTargets: number;
  76476. /**
  76477. * Gets the number of influencers (ie. the number of targets with influences > 0)
  76478. */
  76479. readonly numInfluencers: number;
  76480. /**
  76481. * Gets the list of influences (one per target)
  76482. */
  76483. readonly influences: Float32Array;
  76484. /**
  76485. * Gets the active target at specified index. An active target is a target with an influence > 0
  76486. * @param index defines the index to check
  76487. * @returns the requested target
  76488. */
  76489. getActiveTarget(index: number): MorphTarget;
  76490. /**
  76491. * Gets the target at specified index
  76492. * @param index defines the index to check
  76493. * @returns the requested target
  76494. */
  76495. getTarget(index: number): MorphTarget;
  76496. /**
  76497. * Add a new target to this manager
  76498. * @param target defines the target to add
  76499. */
  76500. addTarget(target: MorphTarget): void;
  76501. /**
  76502. * Removes a target from the manager
  76503. * @param target defines the target to remove
  76504. */
  76505. removeTarget(target: MorphTarget): void;
  76506. /**
  76507. * Serializes the current manager into a Serialization object
  76508. * @returns the serialized object
  76509. */
  76510. serialize(): any;
  76511. private _syncActiveTargets;
  76512. /**
  76513. * Syncrhonize the targets with all the meshes using this morph target manager
  76514. */
  76515. synchronize(): void;
  76516. /**
  76517. * Creates a new MorphTargetManager from serialized data
  76518. * @param serializationObject defines the serialized data
  76519. * @param scene defines the hosting scene
  76520. * @returns the new MorphTargetManager
  76521. */
  76522. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  76523. }
  76524. }
  76525. declare module BABYLON {
  76526. /**
  76527. * Mesh representing the gorund
  76528. */
  76529. export class GroundMesh extends Mesh {
  76530. /** If octree should be generated */
  76531. generateOctree: boolean;
  76532. private _heightQuads;
  76533. /** @hidden */
  76534. _subdivisionsX: number;
  76535. /** @hidden */
  76536. _subdivisionsY: number;
  76537. /** @hidden */
  76538. _width: number;
  76539. /** @hidden */
  76540. _height: number;
  76541. /** @hidden */
  76542. _minX: number;
  76543. /** @hidden */
  76544. _maxX: number;
  76545. /** @hidden */
  76546. _minZ: number;
  76547. /** @hidden */
  76548. _maxZ: number;
  76549. constructor(name: string, scene: Scene);
  76550. /**
  76551. * "GroundMesh"
  76552. * @returns "GroundMesh"
  76553. */
  76554. getClassName(): string;
  76555. /**
  76556. * The minimum of x and y subdivisions
  76557. */
  76558. readonly subdivisions: number;
  76559. /**
  76560. * X subdivisions
  76561. */
  76562. readonly subdivisionsX: number;
  76563. /**
  76564. * Y subdivisions
  76565. */
  76566. readonly subdivisionsY: number;
  76567. /**
  76568. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  76569. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  76570. * @param chunksCount the number of subdivisions for x and y
  76571. * @param octreeBlocksSize (Default: 32)
  76572. */
  76573. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  76574. /**
  76575. * Returns a height (y) value in the Worl system :
  76576. * the ground altitude at the coordinates (x, z) expressed in the World system.
  76577. * @param x x coordinate
  76578. * @param z z coordinate
  76579. * @returns the ground y position if (x, z) are outside the ground surface.
  76580. */
  76581. getHeightAtCoordinates(x: number, z: number): number;
  76582. /**
  76583. * Returns a normalized vector (Vector3) orthogonal to the ground
  76584. * at the ground coordinates (x, z) expressed in the World system.
  76585. * @param x x coordinate
  76586. * @param z z coordinate
  76587. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  76588. */
  76589. getNormalAtCoordinates(x: number, z: number): Vector3;
  76590. /**
  76591. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  76592. * at the ground coordinates (x, z) expressed in the World system.
  76593. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  76594. * @param x x coordinate
  76595. * @param z z coordinate
  76596. * @param ref vector to store the result
  76597. * @returns the GroundMesh.
  76598. */
  76599. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  76600. /**
  76601. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  76602. * if the ground has been updated.
  76603. * This can be used in the render loop.
  76604. * @returns the GroundMesh.
  76605. */
  76606. updateCoordinateHeights(): GroundMesh;
  76607. private _getFacetAt;
  76608. private _initHeightQuads;
  76609. private _computeHeightQuads;
  76610. /**
  76611. * Serializes this ground mesh
  76612. * @param serializationObject object to write serialization to
  76613. */
  76614. serialize(serializationObject: any): void;
  76615. /**
  76616. * Parses a serialized ground mesh
  76617. * @param parsedMesh the serialized mesh
  76618. * @param scene the scene to create the ground mesh in
  76619. * @returns the created ground mesh
  76620. */
  76621. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  76622. }
  76623. }
  76624. declare module BABYLON {
  76625. /**
  76626. * Interface for Physics-Joint data
  76627. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76628. */
  76629. export interface PhysicsJointData {
  76630. /**
  76631. * The main pivot of the joint
  76632. */
  76633. mainPivot?: Vector3;
  76634. /**
  76635. * The connected pivot of the joint
  76636. */
  76637. connectedPivot?: Vector3;
  76638. /**
  76639. * The main axis of the joint
  76640. */
  76641. mainAxis?: Vector3;
  76642. /**
  76643. * The connected axis of the joint
  76644. */
  76645. connectedAxis?: Vector3;
  76646. /**
  76647. * The collision of the joint
  76648. */
  76649. collision?: boolean;
  76650. /**
  76651. * Native Oimo/Cannon/Energy data
  76652. */
  76653. nativeParams?: any;
  76654. }
  76655. /**
  76656. * This is a holder class for the physics joint created by the physics plugin
  76657. * It holds a set of functions to control the underlying joint
  76658. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76659. */
  76660. export class PhysicsJoint {
  76661. /**
  76662. * The type of the physics joint
  76663. */
  76664. type: number;
  76665. /**
  76666. * The data for the physics joint
  76667. */
  76668. jointData: PhysicsJointData;
  76669. private _physicsJoint;
  76670. protected _physicsPlugin: IPhysicsEnginePlugin;
  76671. /**
  76672. * Initializes the physics joint
  76673. * @param type The type of the physics joint
  76674. * @param jointData The data for the physics joint
  76675. */
  76676. constructor(
  76677. /**
  76678. * The type of the physics joint
  76679. */
  76680. type: number,
  76681. /**
  76682. * The data for the physics joint
  76683. */
  76684. jointData: PhysicsJointData);
  76685. /**
  76686. * Gets the physics joint
  76687. */
  76688. /**
  76689. * Sets the physics joint
  76690. */
  76691. physicsJoint: any;
  76692. /**
  76693. * Sets the physics plugin
  76694. */
  76695. physicsPlugin: IPhysicsEnginePlugin;
  76696. /**
  76697. * Execute a function that is physics-plugin specific.
  76698. * @param {Function} func the function that will be executed.
  76699. * It accepts two parameters: the physics world and the physics joint
  76700. */
  76701. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  76702. /**
  76703. * Distance-Joint type
  76704. */
  76705. static DistanceJoint: number;
  76706. /**
  76707. * Hinge-Joint type
  76708. */
  76709. static HingeJoint: number;
  76710. /**
  76711. * Ball-and-Socket joint type
  76712. */
  76713. static BallAndSocketJoint: number;
  76714. /**
  76715. * Wheel-Joint type
  76716. */
  76717. static WheelJoint: number;
  76718. /**
  76719. * Slider-Joint type
  76720. */
  76721. static SliderJoint: number;
  76722. /**
  76723. * Prismatic-Joint type
  76724. */
  76725. static PrismaticJoint: number;
  76726. /**
  76727. * Universal-Joint type
  76728. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  76729. */
  76730. static UniversalJoint: number;
  76731. /**
  76732. * Hinge-Joint 2 type
  76733. */
  76734. static Hinge2Joint: number;
  76735. /**
  76736. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  76737. */
  76738. static PointToPointJoint: number;
  76739. /**
  76740. * Spring-Joint type
  76741. */
  76742. static SpringJoint: number;
  76743. /**
  76744. * Lock-Joint type
  76745. */
  76746. static LockJoint: number;
  76747. }
  76748. /**
  76749. * A class representing a physics distance joint
  76750. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76751. */
  76752. export class DistanceJoint extends PhysicsJoint {
  76753. /**
  76754. *
  76755. * @param jointData The data for the Distance-Joint
  76756. */
  76757. constructor(jointData: DistanceJointData);
  76758. /**
  76759. * Update the predefined distance.
  76760. * @param maxDistance The maximum preferred distance
  76761. * @param minDistance The minimum preferred distance
  76762. */
  76763. updateDistance(maxDistance: number, minDistance?: number): void;
  76764. }
  76765. /**
  76766. * Represents a Motor-Enabled Joint
  76767. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76768. */
  76769. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  76770. /**
  76771. * Initializes the Motor-Enabled Joint
  76772. * @param type The type of the joint
  76773. * @param jointData The physica joint data for the joint
  76774. */
  76775. constructor(type: number, jointData: PhysicsJointData);
  76776. /**
  76777. * Set the motor values.
  76778. * Attention, this function is plugin specific. Engines won't react 100% the same.
  76779. * @param force the force to apply
  76780. * @param maxForce max force for this motor.
  76781. */
  76782. setMotor(force?: number, maxForce?: number): void;
  76783. /**
  76784. * Set the motor's limits.
  76785. * Attention, this function is plugin specific. Engines won't react 100% the same.
  76786. * @param upperLimit The upper limit of the motor
  76787. * @param lowerLimit The lower limit of the motor
  76788. */
  76789. setLimit(upperLimit: number, lowerLimit?: number): void;
  76790. }
  76791. /**
  76792. * This class represents a single physics Hinge-Joint
  76793. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76794. */
  76795. export class HingeJoint extends MotorEnabledJoint {
  76796. /**
  76797. * Initializes the Hinge-Joint
  76798. * @param jointData The joint data for the Hinge-Joint
  76799. */
  76800. constructor(jointData: PhysicsJointData);
  76801. /**
  76802. * Set the motor values.
  76803. * Attention, this function is plugin specific. Engines won't react 100% the same.
  76804. * @param {number} force the force to apply
  76805. * @param {number} maxForce max force for this motor.
  76806. */
  76807. setMotor(force?: number, maxForce?: number): void;
  76808. /**
  76809. * Set the motor's limits.
  76810. * Attention, this function is plugin specific. Engines won't react 100% the same.
  76811. * @param upperLimit The upper limit of the motor
  76812. * @param lowerLimit The lower limit of the motor
  76813. */
  76814. setLimit(upperLimit: number, lowerLimit?: number): void;
  76815. }
  76816. /**
  76817. * This class represents a dual hinge physics joint (same as wheel joint)
  76818. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76819. */
  76820. export class Hinge2Joint extends MotorEnabledJoint {
  76821. /**
  76822. * Initializes the Hinge2-Joint
  76823. * @param jointData The joint data for the Hinge2-Joint
  76824. */
  76825. constructor(jointData: PhysicsJointData);
  76826. /**
  76827. * Set the motor values.
  76828. * Attention, this function is plugin specific. Engines won't react 100% the same.
  76829. * @param {number} targetSpeed the speed the motor is to reach
  76830. * @param {number} maxForce max force for this motor.
  76831. * @param {motorIndex} the motor's index, 0 or 1.
  76832. */
  76833. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  76834. /**
  76835. * Set the motor limits.
  76836. * Attention, this function is plugin specific. Engines won't react 100% the same.
  76837. * @param {number} upperLimit the upper limit
  76838. * @param {number} lowerLimit lower limit
  76839. * @param {motorIndex} the motor's index, 0 or 1.
  76840. */
  76841. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  76842. }
  76843. /**
  76844. * Interface for a motor enabled joint
  76845. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76846. */
  76847. export interface IMotorEnabledJoint {
  76848. /**
  76849. * Physics joint
  76850. */
  76851. physicsJoint: any;
  76852. /**
  76853. * Sets the motor of the motor-enabled joint
  76854. * @param force The force of the motor
  76855. * @param maxForce The maximum force of the motor
  76856. * @param motorIndex The index of the motor
  76857. */
  76858. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  76859. /**
  76860. * Sets the limit of the motor
  76861. * @param upperLimit The upper limit of the motor
  76862. * @param lowerLimit The lower limit of the motor
  76863. * @param motorIndex The index of the motor
  76864. */
  76865. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  76866. }
  76867. /**
  76868. * Joint data for a Distance-Joint
  76869. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76870. */
  76871. export interface DistanceJointData extends PhysicsJointData {
  76872. /**
  76873. * Max distance the 2 joint objects can be apart
  76874. */
  76875. maxDistance: number;
  76876. }
  76877. /**
  76878. * Joint data from a spring joint
  76879. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76880. */
  76881. export interface SpringJointData extends PhysicsJointData {
  76882. /**
  76883. * Length of the spring
  76884. */
  76885. length: number;
  76886. /**
  76887. * Stiffness of the spring
  76888. */
  76889. stiffness: number;
  76890. /**
  76891. * Damping of the spring
  76892. */
  76893. damping: number;
  76894. /** this callback will be called when applying the force to the impostors. */
  76895. forceApplicationCallback: () => void;
  76896. }
  76897. }
  76898. declare module BABYLON {
  76899. /**
  76900. * Interface used to describe a physics joint
  76901. */
  76902. export interface PhysicsImpostorJoint {
  76903. /** Defines the main impostor to which the joint is linked */
  76904. mainImpostor: PhysicsImpostor;
  76905. /** Defines the impostor that is connected to the main impostor using this joint */
  76906. connectedImpostor: PhysicsImpostor;
  76907. /** Defines the joint itself */
  76908. joint: PhysicsJoint;
  76909. }
  76910. /** @hidden */
  76911. export interface IPhysicsEnginePlugin {
  76912. world: any;
  76913. name: string;
  76914. setGravity(gravity: Vector3): void;
  76915. setTimeStep(timeStep: number): void;
  76916. getTimeStep(): number;
  76917. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  76918. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  76919. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  76920. generatePhysicsBody(impostor: PhysicsImpostor): void;
  76921. removePhysicsBody(impostor: PhysicsImpostor): void;
  76922. generateJoint(joint: PhysicsImpostorJoint): void;
  76923. removeJoint(joint: PhysicsImpostorJoint): void;
  76924. isSupported(): boolean;
  76925. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  76926. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  76927. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  76928. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  76929. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  76930. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  76931. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  76932. getBodyMass(impostor: PhysicsImpostor): number;
  76933. getBodyFriction(impostor: PhysicsImpostor): number;
  76934. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  76935. getBodyRestitution(impostor: PhysicsImpostor): number;
  76936. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  76937. sleepBody(impostor: PhysicsImpostor): void;
  76938. wakeUpBody(impostor: PhysicsImpostor): void;
  76939. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  76940. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  76941. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  76942. getRadius(impostor: PhysicsImpostor): number;
  76943. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  76944. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  76945. dispose(): void;
  76946. }
  76947. /**
  76948. * Interface used to define a physics engine
  76949. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  76950. */
  76951. export interface IPhysicsEngine {
  76952. /**
  76953. * Gets the gravity vector used by the simulation
  76954. */
  76955. gravity: Vector3;
  76956. /**
  76957. * Sets the gravity vector used by the simulation
  76958. * @param gravity defines the gravity vector to use
  76959. */
  76960. setGravity(gravity: Vector3): void;
  76961. /**
  76962. * Set the time step of the physics engine.
  76963. * Default is 1/60.
  76964. * To slow it down, enter 1/600 for example.
  76965. * To speed it up, 1/30
  76966. * @param newTimeStep the new timestep to apply to this world.
  76967. */
  76968. setTimeStep(newTimeStep: number): void;
  76969. /**
  76970. * Get the time step of the physics engine.
  76971. * @returns the current time step
  76972. */
  76973. getTimeStep(): number;
  76974. /**
  76975. * Release all resources
  76976. */
  76977. dispose(): void;
  76978. /**
  76979. * Gets the name of the current physics plugin
  76980. * @returns the name of the plugin
  76981. */
  76982. getPhysicsPluginName(): string;
  76983. /**
  76984. * Adding a new impostor for the impostor tracking.
  76985. * This will be done by the impostor itself.
  76986. * @param impostor the impostor to add
  76987. */
  76988. addImpostor(impostor: PhysicsImpostor): void;
  76989. /**
  76990. * Remove an impostor from the engine.
  76991. * This impostor and its mesh will not longer be updated by the physics engine.
  76992. * @param impostor the impostor to remove
  76993. */
  76994. removeImpostor(impostor: PhysicsImpostor): void;
  76995. /**
  76996. * Add a joint to the physics engine
  76997. * @param mainImpostor defines the main impostor to which the joint is added.
  76998. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  76999. * @param joint defines the joint that will connect both impostors.
  77000. */
  77001. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  77002. /**
  77003. * Removes a joint from the simulation
  77004. * @param mainImpostor defines the impostor used with the joint
  77005. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  77006. * @param joint defines the joint to remove
  77007. */
  77008. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  77009. /**
  77010. * Gets the current plugin used to run the simulation
  77011. * @returns current plugin
  77012. */
  77013. getPhysicsPlugin(): IPhysicsEnginePlugin;
  77014. /**
  77015. * Gets the list of physic impostors
  77016. * @returns an array of PhysicsImpostor
  77017. */
  77018. getImpostors(): Array<PhysicsImpostor>;
  77019. /**
  77020. * Gets the impostor for a physics enabled object
  77021. * @param object defines the object impersonated by the impostor
  77022. * @returns the PhysicsImpostor or null if not found
  77023. */
  77024. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  77025. /**
  77026. * Gets the impostor for a physics body object
  77027. * @param body defines physics body used by the impostor
  77028. * @returns the PhysicsImpostor or null if not found
  77029. */
  77030. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  77031. /**
  77032. * Called by the scene. No need to call it.
  77033. * @param delta defines the timespam between frames
  77034. */
  77035. _step(delta: number): void;
  77036. }
  77037. }
  77038. declare module BABYLON {
  77039. /**
  77040. * The interface for the physics imposter parameters
  77041. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  77042. */
  77043. export interface PhysicsImpostorParameters {
  77044. /**
  77045. * The mass of the physics imposter
  77046. */
  77047. mass: number;
  77048. /**
  77049. * The friction of the physics imposter
  77050. */
  77051. friction?: number;
  77052. /**
  77053. * The coefficient of restitution of the physics imposter
  77054. */
  77055. restitution?: number;
  77056. /**
  77057. * The native options of the physics imposter
  77058. */
  77059. nativeOptions?: any;
  77060. /**
  77061. * Specifies if the parent should be ignored
  77062. */
  77063. ignoreParent?: boolean;
  77064. /**
  77065. * Specifies if bi-directional transformations should be disabled
  77066. */
  77067. disableBidirectionalTransformation?: boolean;
  77068. }
  77069. /**
  77070. * Interface for a physics-enabled object
  77071. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  77072. */
  77073. export interface IPhysicsEnabledObject {
  77074. /**
  77075. * The position of the physics-enabled object
  77076. */
  77077. position: Vector3;
  77078. /**
  77079. * The rotation of the physics-enabled object
  77080. */
  77081. rotationQuaternion: Nullable<Quaternion>;
  77082. /**
  77083. * The scale of the physics-enabled object
  77084. */
  77085. scaling: Vector3;
  77086. /**
  77087. * The rotation of the physics-enabled object
  77088. */
  77089. rotation?: Vector3;
  77090. /**
  77091. * The parent of the physics-enabled object
  77092. */
  77093. parent?: any;
  77094. /**
  77095. * The bounding info of the physics-enabled object
  77096. * @returns The bounding info of the physics-enabled object
  77097. */
  77098. getBoundingInfo(): BoundingInfo;
  77099. /**
  77100. * Computes the world matrix
  77101. * @param force Specifies if the world matrix should be computed by force
  77102. * @returns A world matrix
  77103. */
  77104. computeWorldMatrix(force: boolean): Matrix;
  77105. /**
  77106. * Gets the world matrix
  77107. * @returns A world matrix
  77108. */
  77109. getWorldMatrix?(): Matrix;
  77110. /**
  77111. * Gets the child meshes
  77112. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  77113. * @returns An array of abstract meshes
  77114. */
  77115. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  77116. /**
  77117. * Gets the vertex data
  77118. * @param kind The type of vertex data
  77119. * @returns A nullable array of numbers, or a float32 array
  77120. */
  77121. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  77122. /**
  77123. * Gets the indices from the mesh
  77124. * @returns A nullable array of index arrays
  77125. */
  77126. getIndices?(): Nullable<IndicesArray>;
  77127. /**
  77128. * Gets the scene from the mesh
  77129. * @returns the indices array or null
  77130. */
  77131. getScene?(): Scene;
  77132. /**
  77133. * Gets the absolute position from the mesh
  77134. * @returns the absolute position
  77135. */
  77136. getAbsolutePosition(): Vector3;
  77137. /**
  77138. * Gets the absolute pivot point from the mesh
  77139. * @returns the absolute pivot point
  77140. */
  77141. getAbsolutePivotPoint(): Vector3;
  77142. /**
  77143. * Rotates the mesh
  77144. * @param axis The axis of rotation
  77145. * @param amount The amount of rotation
  77146. * @param space The space of the rotation
  77147. * @returns The rotation transform node
  77148. */
  77149. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  77150. /**
  77151. * Translates the mesh
  77152. * @param axis The axis of translation
  77153. * @param distance The distance of translation
  77154. * @param space The space of the translation
  77155. * @returns The transform node
  77156. */
  77157. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  77158. /**
  77159. * Sets the absolute position of the mesh
  77160. * @param absolutePosition The absolute position of the mesh
  77161. * @returns The transform node
  77162. */
  77163. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  77164. /**
  77165. * Gets the class name of the mesh
  77166. * @returns The class name
  77167. */
  77168. getClassName(): string;
  77169. }
  77170. /**
  77171. * Represents a physics imposter
  77172. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  77173. */
  77174. export class PhysicsImpostor {
  77175. /**
  77176. * The physics-enabled object used as the physics imposter
  77177. */
  77178. object: IPhysicsEnabledObject;
  77179. /**
  77180. * The type of the physics imposter
  77181. */
  77182. type: number;
  77183. private _options;
  77184. private _scene?;
  77185. /**
  77186. * The default object size of the imposter
  77187. */
  77188. static DEFAULT_OBJECT_SIZE: Vector3;
  77189. /**
  77190. * The identity quaternion of the imposter
  77191. */
  77192. static IDENTITY_QUATERNION: Quaternion;
  77193. /** @hidden */
  77194. _pluginData: any;
  77195. private _physicsEngine;
  77196. private _physicsBody;
  77197. private _bodyUpdateRequired;
  77198. private _onBeforePhysicsStepCallbacks;
  77199. private _onAfterPhysicsStepCallbacks;
  77200. /** @hidden */
  77201. _onPhysicsCollideCallbacks: Array<{
  77202. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  77203. otherImpostors: Array<PhysicsImpostor>;
  77204. }>;
  77205. private _deltaPosition;
  77206. private _deltaRotation;
  77207. private _deltaRotationConjugated;
  77208. private _parent;
  77209. private _isDisposed;
  77210. private static _tmpVecs;
  77211. private static _tmpQuat;
  77212. /**
  77213. * Specifies if the physics imposter is disposed
  77214. */
  77215. readonly isDisposed: boolean;
  77216. /**
  77217. * Gets the mass of the physics imposter
  77218. */
  77219. mass: number;
  77220. /**
  77221. * Gets the coefficient of friction
  77222. */
  77223. /**
  77224. * Sets the coefficient of friction
  77225. */
  77226. friction: number;
  77227. /**
  77228. * Gets the coefficient of restitution
  77229. */
  77230. /**
  77231. * Sets the coefficient of restitution
  77232. */
  77233. restitution: number;
  77234. /**
  77235. * The unique id of the physics imposter
  77236. * set by the physics engine when adding this impostor to the array
  77237. */
  77238. uniqueId: number;
  77239. private _joints;
  77240. /**
  77241. * Initializes the physics imposter
  77242. * @param object The physics-enabled object used as the physics imposter
  77243. * @param type The type of the physics imposter
  77244. * @param _options The options for the physics imposter
  77245. * @param _scene The Babylon scene
  77246. */
  77247. constructor(
  77248. /**
  77249. * The physics-enabled object used as the physics imposter
  77250. */
  77251. object: IPhysicsEnabledObject,
  77252. /**
  77253. * The type of the physics imposter
  77254. */
  77255. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  77256. /**
  77257. * This function will completly initialize this impostor.
  77258. * It will create a new body - but only if this mesh has no parent.
  77259. * If it has, this impostor will not be used other than to define the impostor
  77260. * of the child mesh.
  77261. * @hidden
  77262. */
  77263. _init(): void;
  77264. private _getPhysicsParent;
  77265. /**
  77266. * Should a new body be generated.
  77267. * @returns boolean specifying if body initialization is required
  77268. */
  77269. isBodyInitRequired(): boolean;
  77270. /**
  77271. * Sets the updated scaling
  77272. * @param updated Specifies if the scaling is updated
  77273. */
  77274. setScalingUpdated(): void;
  77275. /**
  77276. * Force a regeneration of this or the parent's impostor's body.
  77277. * Use under cautious - This will remove all joints already implemented.
  77278. */
  77279. forceUpdate(): void;
  77280. /**
  77281. * Gets the body that holds this impostor. Either its own, or its parent.
  77282. */
  77283. /**
  77284. * Set the physics body. Used mainly by the physics engine/plugin
  77285. */
  77286. physicsBody: any;
  77287. /**
  77288. * Get the parent of the physics imposter
  77289. * @returns Physics imposter or null
  77290. */
  77291. /**
  77292. * Sets the parent of the physics imposter
  77293. */
  77294. parent: Nullable<PhysicsImpostor>;
  77295. /**
  77296. * Resets the update flags
  77297. */
  77298. resetUpdateFlags(): void;
  77299. /**
  77300. * Gets the object extend size
  77301. * @returns the object extend size
  77302. */
  77303. getObjectExtendSize(): Vector3;
  77304. /**
  77305. * Gets the object center
  77306. * @returns The object center
  77307. */
  77308. getObjectCenter(): Vector3;
  77309. /**
  77310. * Get a specific parametes from the options parameter
  77311. * @param paramName The object parameter name
  77312. * @returns The object parameter
  77313. */
  77314. getParam(paramName: string): any;
  77315. /**
  77316. * Sets a specific parameter in the options given to the physics plugin
  77317. * @param paramName The parameter name
  77318. * @param value The value of the parameter
  77319. */
  77320. setParam(paramName: string, value: number): void;
  77321. /**
  77322. * Specifically change the body's mass option. Won't recreate the physics body object
  77323. * @param mass The mass of the physics imposter
  77324. */
  77325. setMass(mass: number): void;
  77326. /**
  77327. * Gets the linear velocity
  77328. * @returns linear velocity or null
  77329. */
  77330. getLinearVelocity(): Nullable<Vector3>;
  77331. /**
  77332. * Sets the linear velocity
  77333. * @param velocity linear velocity or null
  77334. */
  77335. setLinearVelocity(velocity: Nullable<Vector3>): void;
  77336. /**
  77337. * Gets the angular velocity
  77338. * @returns angular velocity or null
  77339. */
  77340. getAngularVelocity(): Nullable<Vector3>;
  77341. /**
  77342. * Sets the angular velocity
  77343. * @param velocity The velocity or null
  77344. */
  77345. setAngularVelocity(velocity: Nullable<Vector3>): void;
  77346. /**
  77347. * Execute a function with the physics plugin native code
  77348. * Provide a function the will have two variables - the world object and the physics body object
  77349. * @param func The function to execute with the physics plugin native code
  77350. */
  77351. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  77352. /**
  77353. * Register a function that will be executed before the physics world is stepping forward
  77354. * @param func The function to execute before the physics world is stepped forward
  77355. */
  77356. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  77357. /**
  77358. * Unregister a function that will be executed before the physics world is stepping forward
  77359. * @param func The function to execute before the physics world is stepped forward
  77360. */
  77361. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  77362. /**
  77363. * Register a function that will be executed after the physics step
  77364. * @param func The function to execute after physics step
  77365. */
  77366. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  77367. /**
  77368. * Unregisters a function that will be executed after the physics step
  77369. * @param func The function to execute after physics step
  77370. */
  77371. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  77372. /**
  77373. * register a function that will be executed when this impostor collides against a different body
  77374. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  77375. * @param func Callback that is executed on collision
  77376. */
  77377. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  77378. /**
  77379. * Unregisters the physics imposter on contact
  77380. * @param collideAgainst The physics object to collide against
  77381. * @param func Callback to execute on collision
  77382. */
  77383. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  77384. private _tmpQuat;
  77385. private _tmpQuat2;
  77386. /**
  77387. * Get the parent rotation
  77388. * @returns The parent rotation
  77389. */
  77390. getParentsRotation(): Quaternion;
  77391. /**
  77392. * this function is executed by the physics engine.
  77393. */
  77394. beforeStep: () => void;
  77395. /**
  77396. * this function is executed by the physics engine
  77397. */
  77398. afterStep: () => void;
  77399. /**
  77400. * Legacy collision detection event support
  77401. */
  77402. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  77403. /**
  77404. * event and body object due to cannon's event-based architecture.
  77405. */
  77406. onCollide: (e: {
  77407. body: any;
  77408. }) => void;
  77409. /**
  77410. * Apply a force
  77411. * @param force The force to apply
  77412. * @param contactPoint The contact point for the force
  77413. * @returns The physics imposter
  77414. */
  77415. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  77416. /**
  77417. * Apply an impulse
  77418. * @param force The impulse force
  77419. * @param contactPoint The contact point for the impulse force
  77420. * @returns The physics imposter
  77421. */
  77422. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  77423. /**
  77424. * A help function to create a joint
  77425. * @param otherImpostor A physics imposter used to create a joint
  77426. * @param jointType The type of joint
  77427. * @param jointData The data for the joint
  77428. * @returns The physics imposter
  77429. */
  77430. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  77431. /**
  77432. * Add a joint to this impostor with a different impostor
  77433. * @param otherImpostor A physics imposter used to add a joint
  77434. * @param joint The joint to add
  77435. * @returns The physics imposter
  77436. */
  77437. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  77438. /**
  77439. * Will keep this body still, in a sleep mode.
  77440. * @returns the physics imposter
  77441. */
  77442. sleep(): PhysicsImpostor;
  77443. /**
  77444. * Wake the body up.
  77445. * @returns The physics imposter
  77446. */
  77447. wakeUp(): PhysicsImpostor;
  77448. /**
  77449. * Clones the physics imposter
  77450. * @param newObject The physics imposter clones to this physics-enabled object
  77451. * @returns A nullable physics imposter
  77452. */
  77453. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  77454. /**
  77455. * Disposes the physics imposter
  77456. */
  77457. dispose(): void;
  77458. /**
  77459. * Sets the delta position
  77460. * @param position The delta position amount
  77461. */
  77462. setDeltaPosition(position: Vector3): void;
  77463. /**
  77464. * Sets the delta rotation
  77465. * @param rotation The delta rotation amount
  77466. */
  77467. setDeltaRotation(rotation: Quaternion): void;
  77468. /**
  77469. * Gets the box size of the physics imposter and stores the result in the input parameter
  77470. * @param result Stores the box size
  77471. * @returns The physics imposter
  77472. */
  77473. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  77474. /**
  77475. * Gets the radius of the physics imposter
  77476. * @returns Radius of the physics imposter
  77477. */
  77478. getRadius(): number;
  77479. /**
  77480. * Sync a bone with this impostor
  77481. * @param bone The bone to sync to the impostor.
  77482. * @param boneMesh The mesh that the bone is influencing.
  77483. * @param jointPivot The pivot of the joint / bone in local space.
  77484. * @param distToJoint Optional distance from the impostor to the joint.
  77485. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  77486. */
  77487. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  77488. /**
  77489. * Sync impostor to a bone
  77490. * @param bone The bone that the impostor will be synced to.
  77491. * @param boneMesh The mesh that the bone is influencing.
  77492. * @param jointPivot The pivot of the joint / bone in local space.
  77493. * @param distToJoint Optional distance from the impostor to the joint.
  77494. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  77495. * @param boneAxis Optional vector3 axis the bone is aligned with
  77496. */
  77497. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  77498. /**
  77499. * No-Imposter type
  77500. */
  77501. static NoImpostor: number;
  77502. /**
  77503. * Sphere-Imposter type
  77504. */
  77505. static SphereImpostor: number;
  77506. /**
  77507. * Box-Imposter type
  77508. */
  77509. static BoxImpostor: number;
  77510. /**
  77511. * Plane-Imposter type
  77512. */
  77513. static PlaneImpostor: number;
  77514. /**
  77515. * Mesh-imposter type
  77516. */
  77517. static MeshImpostor: number;
  77518. /**
  77519. * Cylinder-Imposter type
  77520. */
  77521. static CylinderImpostor: number;
  77522. /**
  77523. * Particle-Imposter type
  77524. */
  77525. static ParticleImpostor: number;
  77526. /**
  77527. * Heightmap-Imposter type
  77528. */
  77529. static HeightmapImpostor: number;
  77530. }
  77531. }
  77532. declare module BABYLON {
  77533. /**
  77534. * Class used to represent a specific level of detail of a mesh
  77535. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  77536. */
  77537. export class MeshLODLevel {
  77538. /** Defines the distance where this level should star being displayed */
  77539. distance: number;
  77540. /** Defines the mesh to use to render this level */
  77541. mesh: Nullable<Mesh>;
  77542. /**
  77543. * Creates a new LOD level
  77544. * @param distance defines the distance where this level should star being displayed
  77545. * @param mesh defines the mesh to use to render this level
  77546. */
  77547. constructor(
  77548. /** Defines the distance where this level should star being displayed */
  77549. distance: number,
  77550. /** Defines the mesh to use to render this level */
  77551. mesh: Nullable<Mesh>);
  77552. }
  77553. /**
  77554. * @hidden
  77555. **/
  77556. export class _CreationDataStorage {
  77557. closePath?: boolean;
  77558. closeArray?: boolean;
  77559. idx: number[];
  77560. dashSize: number;
  77561. gapSize: number;
  77562. path3D: Path3D;
  77563. pathArray: Vector3[][];
  77564. arc: number;
  77565. radius: number;
  77566. cap: number;
  77567. tessellation: number;
  77568. }
  77569. /**
  77570. * @hidden
  77571. **/
  77572. class _InstanceDataStorage {
  77573. visibleInstances: any;
  77574. renderIdForInstances: number[];
  77575. batchCache: _InstancesBatch;
  77576. instancesBufferSize: number;
  77577. instancesBuffer: Nullable<Buffer>;
  77578. instancesData: Float32Array;
  77579. overridenInstanceCount: number;
  77580. }
  77581. /**
  77582. * @hidden
  77583. **/
  77584. export class _InstancesBatch {
  77585. mustReturn: boolean;
  77586. visibleInstances: Nullable<InstancedMesh[]>[];
  77587. renderSelf: boolean[];
  77588. }
  77589. /**
  77590. * Class used to represent renderable models
  77591. */
  77592. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  77593. /**
  77594. * Mesh side orientation : usually the external or front surface
  77595. */
  77596. static readonly FRONTSIDE: number;
  77597. /**
  77598. * Mesh side orientation : usually the internal or back surface
  77599. */
  77600. static readonly BACKSIDE: number;
  77601. /**
  77602. * Mesh side orientation : both internal and external or front and back surfaces
  77603. */
  77604. static readonly DOUBLESIDE: number;
  77605. /**
  77606. * Mesh side orientation : by default, `FRONTSIDE`
  77607. */
  77608. static readonly DEFAULTSIDE: number;
  77609. /**
  77610. * Mesh cap setting : no cap
  77611. */
  77612. static readonly NO_CAP: number;
  77613. /**
  77614. * Mesh cap setting : one cap at the beginning of the mesh
  77615. */
  77616. static readonly CAP_START: number;
  77617. /**
  77618. * Mesh cap setting : one cap at the end of the mesh
  77619. */
  77620. static readonly CAP_END: number;
  77621. /**
  77622. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  77623. */
  77624. static readonly CAP_ALL: number;
  77625. /**
  77626. * Gets the default side orientation.
  77627. * @param orientation the orientation to value to attempt to get
  77628. * @returns the default orientation
  77629. * @hidden
  77630. */
  77631. static _GetDefaultSideOrientation(orientation?: number): number;
  77632. private _onBeforeRenderObservable;
  77633. private _onBeforeBindObservable;
  77634. private _onAfterRenderObservable;
  77635. private _onBeforeDrawObservable;
  77636. /**
  77637. * An event triggered before rendering the mesh
  77638. */
  77639. readonly onBeforeRenderObservable: Observable<Mesh>;
  77640. /**
  77641. * An event triggered before binding the mesh
  77642. */
  77643. readonly onBeforeBindObservable: Observable<Mesh>;
  77644. /**
  77645. * An event triggered after rendering the mesh
  77646. */
  77647. readonly onAfterRenderObservable: Observable<Mesh>;
  77648. /**
  77649. * An event triggered before drawing the mesh
  77650. */
  77651. readonly onBeforeDrawObservable: Observable<Mesh>;
  77652. private _onBeforeDrawObserver;
  77653. /**
  77654. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  77655. */
  77656. onBeforeDraw: () => void;
  77657. /**
  77658. * Gets the delay loading state of the mesh (when delay loading is turned on)
  77659. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  77660. */
  77661. delayLoadState: number;
  77662. /**
  77663. * Gets the list of instances created from this mesh
  77664. * it is not supposed to be modified manually.
  77665. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  77666. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  77667. */
  77668. instances: InstancedMesh[];
  77669. /**
  77670. * Gets the file containing delay loading data for this mesh
  77671. */
  77672. delayLoadingFile: string;
  77673. /** @hidden */
  77674. _binaryInfo: any;
  77675. private _LODLevels;
  77676. /**
  77677. * User defined function used to change how LOD level selection is done
  77678. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  77679. */
  77680. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  77681. private _morphTargetManager;
  77682. /**
  77683. * Gets or sets the morph target manager
  77684. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  77685. */
  77686. morphTargetManager: Nullable<MorphTargetManager>;
  77687. /** @hidden */
  77688. _creationDataStorage: Nullable<_CreationDataStorage>;
  77689. /** @hidden */
  77690. _geometry: Nullable<Geometry>;
  77691. /** @hidden */
  77692. _delayInfo: Array<string>;
  77693. /** @hidden */
  77694. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  77695. /** @hidden */
  77696. _instanceDataStorage: _InstanceDataStorage;
  77697. private _effectiveMaterial;
  77698. /** @hidden */
  77699. _shouldGenerateFlatShading: boolean;
  77700. private _preActivateId;
  77701. /** @hidden */
  77702. _originalBuilderSideOrientation: number;
  77703. /**
  77704. * Use this property to change the original side orientation defined at construction time
  77705. */
  77706. overrideMaterialSideOrientation: Nullable<number>;
  77707. private _areNormalsFrozen;
  77708. private _sourcePositions;
  77709. private _sourceNormals;
  77710. private _source;
  77711. private meshMap;
  77712. /**
  77713. * Gets the source mesh (the one used to clone this one from)
  77714. */
  77715. readonly source: Nullable<Mesh>;
  77716. /**
  77717. * Gets or sets a boolean indicating that this mesh does not use index buffer
  77718. */
  77719. isUnIndexed: boolean;
  77720. /**
  77721. * @constructor
  77722. * @param name The value used by scene.getMeshByName() to do a lookup.
  77723. * @param scene The scene to add this mesh to.
  77724. * @param parent The parent of this mesh, if it has one
  77725. * @param source An optional Mesh from which geometry is shared, cloned.
  77726. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  77727. * When false, achieved by calling a clone(), also passing False.
  77728. * This will make creation of children, recursive.
  77729. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  77730. */
  77731. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  77732. /**
  77733. * Gets the class name
  77734. * @returns the string "Mesh".
  77735. */
  77736. getClassName(): string;
  77737. /** @hidden */
  77738. readonly _isMesh: boolean;
  77739. /**
  77740. * Returns a description of this mesh
  77741. * @param fullDetails define if full details about this mesh must be used
  77742. * @returns a descriptive string representing this mesh
  77743. */
  77744. toString(fullDetails?: boolean): string;
  77745. /** @hidden */
  77746. _unBindEffect(): void;
  77747. /**
  77748. * Gets a boolean indicating if this mesh has LOD
  77749. */
  77750. readonly hasLODLevels: boolean;
  77751. /**
  77752. * Gets the list of MeshLODLevel associated with the current mesh
  77753. * @returns an array of MeshLODLevel
  77754. */
  77755. getLODLevels(): MeshLODLevel[];
  77756. private _sortLODLevels;
  77757. /**
  77758. * Add a mesh as LOD level triggered at the given distance.
  77759. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  77760. * @param distance The distance from the center of the object to show this level
  77761. * @param mesh The mesh to be added as LOD level (can be null)
  77762. * @return This mesh (for chaining)
  77763. */
  77764. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  77765. /**
  77766. * Returns the LOD level mesh at the passed distance or null if not found.
  77767. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  77768. * @param distance The distance from the center of the object to show this level
  77769. * @returns a Mesh or `null`
  77770. */
  77771. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  77772. /**
  77773. * Remove a mesh from the LOD array
  77774. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  77775. * @param mesh defines the mesh to be removed
  77776. * @return This mesh (for chaining)
  77777. */
  77778. removeLODLevel(mesh: Mesh): Mesh;
  77779. /**
  77780. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  77781. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  77782. * @param camera defines the camera to use to compute distance
  77783. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  77784. * @return This mesh (for chaining)
  77785. */
  77786. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  77787. /**
  77788. * Gets the mesh internal Geometry object
  77789. */
  77790. readonly geometry: Nullable<Geometry>;
  77791. /**
  77792. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  77793. * @returns the total number of vertices
  77794. */
  77795. getTotalVertices(): number;
  77796. /**
  77797. * Returns the content of an associated vertex buffer
  77798. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  77799. * - VertexBuffer.PositionKind
  77800. * - VertexBuffer.UVKind
  77801. * - VertexBuffer.UV2Kind
  77802. * - VertexBuffer.UV3Kind
  77803. * - VertexBuffer.UV4Kind
  77804. * - VertexBuffer.UV5Kind
  77805. * - VertexBuffer.UV6Kind
  77806. * - VertexBuffer.ColorKind
  77807. * - VertexBuffer.MatricesIndicesKind
  77808. * - VertexBuffer.MatricesIndicesExtraKind
  77809. * - VertexBuffer.MatricesWeightsKind
  77810. * - VertexBuffer.MatricesWeightsExtraKind
  77811. * @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
  77812. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  77813. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  77814. */
  77815. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  77816. /**
  77817. * Returns the mesh VertexBuffer object from the requested `kind`
  77818. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  77819. * - VertexBuffer.PositionKind
  77820. * - VertexBuffer.UVKind
  77821. * - VertexBuffer.UV2Kind
  77822. * - VertexBuffer.UV3Kind
  77823. * - VertexBuffer.UV4Kind
  77824. * - VertexBuffer.UV5Kind
  77825. * - VertexBuffer.UV6Kind
  77826. * - VertexBuffer.ColorKind
  77827. * - VertexBuffer.MatricesIndicesKind
  77828. * - VertexBuffer.MatricesIndicesExtraKind
  77829. * - VertexBuffer.MatricesWeightsKind
  77830. * - VertexBuffer.MatricesWeightsExtraKind
  77831. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  77832. */
  77833. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  77834. /**
  77835. * Tests if a specific vertex buffer is associated with this mesh
  77836. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  77837. * - VertexBuffer.PositionKind
  77838. * - VertexBuffer.UVKind
  77839. * - VertexBuffer.UV2Kind
  77840. * - VertexBuffer.UV3Kind
  77841. * - VertexBuffer.UV4Kind
  77842. * - VertexBuffer.UV5Kind
  77843. * - VertexBuffer.UV6Kind
  77844. * - VertexBuffer.ColorKind
  77845. * - VertexBuffer.MatricesIndicesKind
  77846. * - VertexBuffer.MatricesIndicesExtraKind
  77847. * - VertexBuffer.MatricesWeightsKind
  77848. * - VertexBuffer.MatricesWeightsExtraKind
  77849. * @returns a boolean
  77850. */
  77851. isVerticesDataPresent(kind: string): boolean;
  77852. /**
  77853. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  77854. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  77855. * - VertexBuffer.PositionKind
  77856. * - VertexBuffer.UVKind
  77857. * - VertexBuffer.UV2Kind
  77858. * - VertexBuffer.UV3Kind
  77859. * - VertexBuffer.UV4Kind
  77860. * - VertexBuffer.UV5Kind
  77861. * - VertexBuffer.UV6Kind
  77862. * - VertexBuffer.ColorKind
  77863. * - VertexBuffer.MatricesIndicesKind
  77864. * - VertexBuffer.MatricesIndicesExtraKind
  77865. * - VertexBuffer.MatricesWeightsKind
  77866. * - VertexBuffer.MatricesWeightsExtraKind
  77867. * @returns a boolean
  77868. */
  77869. isVertexBufferUpdatable(kind: string): boolean;
  77870. /**
  77871. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  77872. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  77873. * - VertexBuffer.PositionKind
  77874. * - VertexBuffer.UVKind
  77875. * - VertexBuffer.UV2Kind
  77876. * - VertexBuffer.UV3Kind
  77877. * - VertexBuffer.UV4Kind
  77878. * - VertexBuffer.UV5Kind
  77879. * - VertexBuffer.UV6Kind
  77880. * - VertexBuffer.ColorKind
  77881. * - VertexBuffer.MatricesIndicesKind
  77882. * - VertexBuffer.MatricesIndicesExtraKind
  77883. * - VertexBuffer.MatricesWeightsKind
  77884. * - VertexBuffer.MatricesWeightsExtraKind
  77885. * @returns an array of strings
  77886. */
  77887. getVerticesDataKinds(): string[];
  77888. /**
  77889. * Returns a positive integer : the total number of indices in this mesh geometry.
  77890. * @returns the numner of indices or zero if the mesh has no geometry.
  77891. */
  77892. getTotalIndices(): number;
  77893. /**
  77894. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  77895. * @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.
  77896. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  77897. * @returns the indices array or an empty array if the mesh has no geometry
  77898. */
  77899. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  77900. readonly isBlocked: boolean;
  77901. /**
  77902. * Determine if the current mesh is ready to be rendered
  77903. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  77904. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  77905. * @returns true if all associated assets are ready (material, textures, shaders)
  77906. */
  77907. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  77908. /**
  77909. * 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.
  77910. */
  77911. readonly areNormalsFrozen: boolean;
  77912. /**
  77913. * 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.
  77914. * @returns the current mesh
  77915. */
  77916. freezeNormals(): Mesh;
  77917. /**
  77918. * 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
  77919. * @returns the current mesh
  77920. */
  77921. unfreezeNormals(): Mesh;
  77922. /**
  77923. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  77924. */
  77925. overridenInstanceCount: number;
  77926. /** @hidden */
  77927. _preActivate(): Mesh;
  77928. /** @hidden */
  77929. _preActivateForIntermediateRendering(renderId: number): Mesh;
  77930. /** @hidden */
  77931. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  77932. /**
  77933. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  77934. * This means the mesh underlying bounding box and sphere are recomputed.
  77935. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  77936. * @returns the current mesh
  77937. */
  77938. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  77939. /** @hidden */
  77940. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  77941. /**
  77942. * This function will subdivide the mesh into multiple submeshes
  77943. * @param count defines the expected number of submeshes
  77944. */
  77945. subdivide(count: number): void;
  77946. /**
  77947. * Copy a FloatArray into a specific associated vertex buffer
  77948. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  77949. * - VertexBuffer.PositionKind
  77950. * - VertexBuffer.UVKind
  77951. * - VertexBuffer.UV2Kind
  77952. * - VertexBuffer.UV3Kind
  77953. * - VertexBuffer.UV4Kind
  77954. * - VertexBuffer.UV5Kind
  77955. * - VertexBuffer.UV6Kind
  77956. * - VertexBuffer.ColorKind
  77957. * - VertexBuffer.MatricesIndicesKind
  77958. * - VertexBuffer.MatricesIndicesExtraKind
  77959. * - VertexBuffer.MatricesWeightsKind
  77960. * - VertexBuffer.MatricesWeightsExtraKind
  77961. * @param data defines the data source
  77962. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  77963. * @param stride defines the data stride size (can be null)
  77964. * @returns the current mesh
  77965. */
  77966. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  77967. /**
  77968. * Flags an associated vertex buffer as updatable
  77969. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  77970. * - VertexBuffer.PositionKind
  77971. * - VertexBuffer.UVKind
  77972. * - VertexBuffer.UV2Kind
  77973. * - VertexBuffer.UV3Kind
  77974. * - VertexBuffer.UV4Kind
  77975. * - VertexBuffer.UV5Kind
  77976. * - VertexBuffer.UV6Kind
  77977. * - VertexBuffer.ColorKind
  77978. * - VertexBuffer.MatricesIndicesKind
  77979. * - VertexBuffer.MatricesIndicesExtraKind
  77980. * - VertexBuffer.MatricesWeightsKind
  77981. * - VertexBuffer.MatricesWeightsExtraKind
  77982. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  77983. */
  77984. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  77985. /**
  77986. * Sets the mesh global Vertex Buffer
  77987. * @param buffer defines the buffer to use
  77988. * @returns the current mesh
  77989. */
  77990. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  77991. /**
  77992. * Update a specific associated vertex buffer
  77993. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  77994. * - VertexBuffer.PositionKind
  77995. * - VertexBuffer.UVKind
  77996. * - VertexBuffer.UV2Kind
  77997. * - VertexBuffer.UV3Kind
  77998. * - VertexBuffer.UV4Kind
  77999. * - VertexBuffer.UV5Kind
  78000. * - VertexBuffer.UV6Kind
  78001. * - VertexBuffer.ColorKind
  78002. * - VertexBuffer.MatricesIndicesKind
  78003. * - VertexBuffer.MatricesIndicesExtraKind
  78004. * - VertexBuffer.MatricesWeightsKind
  78005. * - VertexBuffer.MatricesWeightsExtraKind
  78006. * @param data defines the data source
  78007. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  78008. * @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)
  78009. * @returns the current mesh
  78010. */
  78011. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  78012. /**
  78013. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  78014. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  78015. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  78016. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  78017. * @returns the current mesh
  78018. */
  78019. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  78020. /**
  78021. * Creates a un-shared specific occurence of the geometry for the mesh.
  78022. * @returns the current mesh
  78023. */
  78024. makeGeometryUnique(): Mesh;
  78025. /**
  78026. * Set the index buffer of this mesh
  78027. * @param indices defines the source data
  78028. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  78029. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  78030. * @returns the current mesh
  78031. */
  78032. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  78033. /**
  78034. * Update the current index buffer
  78035. * @param indices defines the source data
  78036. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  78037. * @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)
  78038. * @returns the current mesh
  78039. */
  78040. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  78041. /**
  78042. * Invert the geometry to move from a right handed system to a left handed one.
  78043. * @returns the current mesh
  78044. */
  78045. toLeftHanded(): Mesh;
  78046. /** @hidden */
  78047. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  78048. /** @hidden */
  78049. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number, alternate?: boolean): Mesh;
  78050. /**
  78051. * Registers for this mesh a javascript function called just before the rendering process
  78052. * @param func defines the function to call before rendering this mesh
  78053. * @returns the current mesh
  78054. */
  78055. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  78056. /**
  78057. * Disposes a previously registered javascript function called before the rendering
  78058. * @param func defines the function to remove
  78059. * @returns the current mesh
  78060. */
  78061. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  78062. /**
  78063. * Registers for this mesh a javascript function called just after the rendering is complete
  78064. * @param func defines the function to call after rendering this mesh
  78065. * @returns the current mesh
  78066. */
  78067. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  78068. /**
  78069. * Disposes a previously registered javascript function called after the rendering.
  78070. * @param func defines the function to remove
  78071. * @returns the current mesh
  78072. */
  78073. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  78074. /** @hidden */
  78075. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  78076. /** @hidden */
  78077. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  78078. /** @hidden */
  78079. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  78080. /**
  78081. * 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
  78082. * @param subMesh defines the subMesh to render
  78083. * @param enableAlphaMode defines if alpha mode can be changed
  78084. * @returns the current mesh
  78085. */
  78086. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  78087. private _onBeforeDraw;
  78088. /**
  78089. * Renormalize the mesh and patch it up if there are no weights
  78090. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  78091. * However in the case of zero weights then we set just a single influence to 1.
  78092. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  78093. */
  78094. cleanMatrixWeights(): void;
  78095. private normalizeSkinFourWeights;
  78096. private normalizeSkinWeightsAndExtra;
  78097. /**
  78098. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  78099. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  78100. * the user know there was an issue with importing the mesh
  78101. * @returns a validation object with skinned, valid and report string
  78102. */
  78103. validateSkinning(): {
  78104. skinned: boolean;
  78105. valid: boolean;
  78106. report: string;
  78107. };
  78108. /** @hidden */
  78109. _checkDelayState(): Mesh;
  78110. private _queueLoad;
  78111. /**
  78112. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  78113. * A mesh is in the frustum if its bounding box intersects the frustum
  78114. * @param frustumPlanes defines the frustum to test
  78115. * @returns true if the mesh is in the frustum planes
  78116. */
  78117. isInFrustum(frustumPlanes: Plane[]): boolean;
  78118. /**
  78119. * Sets the mesh material by the material or multiMaterial `id` property
  78120. * @param id is a string identifying the material or the multiMaterial
  78121. * @returns the current mesh
  78122. */
  78123. setMaterialByID(id: string): Mesh;
  78124. /**
  78125. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  78126. * @returns an array of IAnimatable
  78127. */
  78128. getAnimatables(): IAnimatable[];
  78129. /**
  78130. * Modifies the mesh geometry according to the passed transformation matrix.
  78131. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  78132. * The mesh normals are modified using the same transformation.
  78133. * Note that, under the hood, this method sets a new VertexBuffer each call.
  78134. * @param transform defines the transform matrix to use
  78135. * @see http://doc.babylonjs.com/resources/baking_transformations
  78136. * @returns the current mesh
  78137. */
  78138. bakeTransformIntoVertices(transform: Matrix): Mesh;
  78139. /**
  78140. * Modifies the mesh geometry according to its own current World Matrix.
  78141. * The mesh World Matrix is then reset.
  78142. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  78143. * Note that, under the hood, this method sets a new VertexBuffer each call.
  78144. * @see http://doc.babylonjs.com/resources/baking_transformations
  78145. * @returns the current mesh
  78146. */
  78147. bakeCurrentTransformIntoVertices(): Mesh;
  78148. /** @hidden */
  78149. readonly _positions: Nullable<Vector3[]>;
  78150. /** @hidden */
  78151. _resetPointsArrayCache(): Mesh;
  78152. /** @hidden */
  78153. _generatePointsArray(): boolean;
  78154. /**
  78155. * Returns a new Mesh object generated from the current mesh properties.
  78156. * This method must not get confused with createInstance()
  78157. * @param name is a string, the name given to the new mesh
  78158. * @param newParent can be any Node object (default `null`)
  78159. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  78160. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  78161. * @returns a new mesh
  78162. */
  78163. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  78164. /**
  78165. * Releases resources associated with this mesh.
  78166. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  78167. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  78168. */
  78169. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  78170. /**
  78171. * Modifies the mesh geometry according to a displacement map.
  78172. * 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.
  78173. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  78174. * @param url is a string, the URL from the image file is to be downloaded.
  78175. * @param minHeight is the lower limit of the displacement.
  78176. * @param maxHeight is the upper limit of the displacement.
  78177. * @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.
  78178. * @param uvOffset is an optional vector2 used to offset UV.
  78179. * @param uvScale is an optional vector2 used to scale UV.
  78180. * @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.
  78181. * @returns the Mesh.
  78182. */
  78183. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  78184. /**
  78185. * Modifies the mesh geometry according to a displacementMap buffer.
  78186. * 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.
  78187. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  78188. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  78189. * @param heightMapWidth is the width of the buffer image.
  78190. * @param heightMapHeight is the height of the buffer image.
  78191. * @param minHeight is the lower limit of the displacement.
  78192. * @param maxHeight is the upper limit of the displacement.
  78193. * @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.
  78194. * @param uvOffset is an optional vector2 used to offset UV.
  78195. * @param uvScale is an optional vector2 used to scale UV.
  78196. * @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.
  78197. * @returns the Mesh.
  78198. */
  78199. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  78200. /**
  78201. * Modify the mesh to get a flat shading rendering.
  78202. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  78203. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  78204. * @returns current mesh
  78205. */
  78206. convertToFlatShadedMesh(): Mesh;
  78207. /**
  78208. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  78209. * In other words, more vertices, no more indices and a single bigger VBO.
  78210. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  78211. * @returns current mesh
  78212. */
  78213. convertToUnIndexedMesh(): Mesh;
  78214. /**
  78215. * Inverses facet orientations.
  78216. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  78217. * @param flipNormals will also inverts the normals
  78218. * @returns current mesh
  78219. */
  78220. flipFaces(flipNormals?: boolean): Mesh;
  78221. /** @hidden */
  78222. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  78223. /** @hidden */
  78224. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  78225. /**
  78226. * Creates a new InstancedMesh object from the mesh model.
  78227. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  78228. * @param name defines the name of the new instance
  78229. * @returns a new InstancedMesh
  78230. */
  78231. createInstance(name: string): InstancedMesh;
  78232. /**
  78233. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  78234. * After this call, all the mesh instances have the same submeshes than the current mesh.
  78235. * @returns the current mesh
  78236. */
  78237. synchronizeInstances(): Mesh;
  78238. /**
  78239. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  78240. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  78241. * This should be used together with the simplification to avoid disappearing triangles.
  78242. * @param successCallback an optional success callback to be called after the optimization finished.
  78243. * @returns the current mesh
  78244. */
  78245. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  78246. /**
  78247. * Serialize current mesh
  78248. * @param serializationObject defines the object which will receive the serialization data
  78249. */
  78250. serialize(serializationObject: any): void;
  78251. /** @hidden */
  78252. _syncGeometryWithMorphTargetManager(): void;
  78253. /** @hidden */
  78254. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  78255. /**
  78256. * Returns a new Mesh object parsed from the source provided.
  78257. * @param parsedMesh is the source
  78258. * @param scene defines the hosting scene
  78259. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  78260. * @returns a new Mesh
  78261. */
  78262. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  78263. /**
  78264. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  78265. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  78266. * @param name defines the name of the mesh to create
  78267. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  78268. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  78269. * @param closePath creates a seam between the first and the last points of each path of the path array
  78270. * @param offset is taken in account only if the `pathArray` is containing a single path
  78271. * @param scene defines the hosting scene
  78272. * @param updatable defines if the mesh must be flagged as updatable
  78273. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78274. * @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)
  78275. * @returns a new Mesh
  78276. */
  78277. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  78278. /**
  78279. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  78280. * @param name defines the name of the mesh to create
  78281. * @param radius sets the radius size (float) of the polygon (default 0.5)
  78282. * @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
  78283. * @param scene defines the hosting scene
  78284. * @param updatable defines if the mesh must be flagged as updatable
  78285. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78286. * @returns a new Mesh
  78287. */
  78288. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  78289. /**
  78290. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  78291. * @param name defines the name of the mesh to create
  78292. * @param size sets the size (float) of each box side (default 1)
  78293. * @param scene defines the hosting scene
  78294. * @param updatable defines if the mesh must be flagged as updatable
  78295. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78296. * @returns a new Mesh
  78297. */
  78298. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  78299. /**
  78300. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  78301. * @param name defines the name of the mesh to create
  78302. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  78303. * @param diameter sets the diameter size (float) of the sphere (default 1)
  78304. * @param scene defines the hosting scene
  78305. * @param updatable defines if the mesh must be flagged as updatable
  78306. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78307. * @returns a new Mesh
  78308. */
  78309. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  78310. /**
  78311. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  78312. * @param name defines the name of the mesh to create
  78313. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  78314. * @param diameterTop set the top cap diameter (floats, default 1)
  78315. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  78316. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  78317. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  78318. * @param scene defines the hosting scene
  78319. * @param updatable defines if the mesh must be flagged as updatable
  78320. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78321. * @returns a new Mesh
  78322. */
  78323. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  78324. /**
  78325. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  78326. * @param name defines the name of the mesh to create
  78327. * @param diameter sets the diameter size (float) of the torus (default 1)
  78328. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  78329. * @param tessellation sets the number of torus sides (postive integer, default 16)
  78330. * @param scene defines the hosting scene
  78331. * @param updatable defines if the mesh must be flagged as updatable
  78332. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78333. * @returns a new Mesh
  78334. */
  78335. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  78336. /**
  78337. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  78338. * @param name defines the name of the mesh to create
  78339. * @param radius sets the global radius size (float) of the torus knot (default 2)
  78340. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  78341. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  78342. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  78343. * @param p the number of windings on X axis (positive integers, default 2)
  78344. * @param q the number of windings on Y axis (positive integers, default 3)
  78345. * @param scene defines the hosting scene
  78346. * @param updatable defines if the mesh must be flagged as updatable
  78347. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78348. * @returns a new Mesh
  78349. */
  78350. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  78351. /**
  78352. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  78353. * @param name defines the name of the mesh to create
  78354. * @param points is an array successive Vector3
  78355. * @param scene defines the hosting scene
  78356. * @param updatable defines if the mesh must be flagged as updatable
  78357. * @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).
  78358. * @returns a new Mesh
  78359. */
  78360. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  78361. /**
  78362. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  78363. * @param name defines the name of the mesh to create
  78364. * @param points is an array successive Vector3
  78365. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  78366. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  78367. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  78368. * @param scene defines the hosting scene
  78369. * @param updatable defines if the mesh must be flagged as updatable
  78370. * @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)
  78371. * @returns a new Mesh
  78372. */
  78373. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  78374. /**
  78375. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  78376. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  78377. * 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.
  78378. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  78379. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  78380. * Remember you can only change the shape positions, not their number when updating a polygon.
  78381. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  78382. * @param name defines the name of the mesh to create
  78383. * @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
  78384. * @param scene defines the hosting scene
  78385. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  78386. * @param updatable defines if the mesh must be flagged as updatable
  78387. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78388. * @param earcutInjection can be used to inject your own earcut reference
  78389. * @returns a new Mesh
  78390. */
  78391. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  78392. /**
  78393. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  78394. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  78395. * @param name defines the name of the mesh to create
  78396. * @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
  78397. * @param depth defines the height of extrusion
  78398. * @param scene defines the hosting scene
  78399. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  78400. * @param updatable defines if the mesh must be flagged as updatable
  78401. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78402. * @param earcutInjection can be used to inject your own earcut reference
  78403. * @returns a new Mesh
  78404. */
  78405. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  78406. /**
  78407. * Creates an extruded shape mesh.
  78408. * 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
  78409. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  78410. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  78411. * @param name defines the name of the mesh to create
  78412. * @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
  78413. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  78414. * @param scale is the value to scale the shape
  78415. * @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
  78416. * @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
  78417. * @param scene defines the hosting scene
  78418. * @param updatable defines if the mesh must be flagged as updatable
  78419. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78420. * @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)
  78421. * @returns a new Mesh
  78422. */
  78423. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  78424. /**
  78425. * Creates an custom extruded shape mesh.
  78426. * The custom extrusion is a parametric shape.
  78427. * It has no predefined shape. Its final shape will depend on the input parameters.
  78428. * Please consider using the same method from the MeshBuilder class instead
  78429. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  78430. * @param name defines the name of the mesh to create
  78431. * @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
  78432. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  78433. * @param scaleFunction is a custom Javascript function called on each path point
  78434. * @param rotationFunction is a custom Javascript function called on each path point
  78435. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  78436. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  78437. * @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
  78438. * @param scene defines the hosting scene
  78439. * @param updatable defines if the mesh must be flagged as updatable
  78440. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78441. * @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)
  78442. * @returns a new Mesh
  78443. */
  78444. 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;
  78445. /**
  78446. * Creates lathe mesh.
  78447. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  78448. * Please consider using the same method from the MeshBuilder class instead
  78449. * @param name defines the name of the mesh to create
  78450. * @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
  78451. * @param radius is the radius value of the lathe
  78452. * @param tessellation is the side number of the lathe.
  78453. * @param scene defines the hosting scene
  78454. * @param updatable defines if the mesh must be flagged as updatable
  78455. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78456. * @returns a new Mesh
  78457. */
  78458. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  78459. /**
  78460. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  78461. * @param name defines the name of the mesh to create
  78462. * @param size sets the size (float) of both sides of the plane at once (default 1)
  78463. * @param scene defines the hosting scene
  78464. * @param updatable defines if the mesh must be flagged as updatable
  78465. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78466. * @returns a new Mesh
  78467. */
  78468. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  78469. /**
  78470. * Creates a ground mesh.
  78471. * Please consider using the same method from the MeshBuilder class instead
  78472. * @param name defines the name of the mesh to create
  78473. * @param width set the width of the ground
  78474. * @param height set the height of the ground
  78475. * @param subdivisions sets the number of subdivisions per side
  78476. * @param scene defines the hosting scene
  78477. * @param updatable defines if the mesh must be flagged as updatable
  78478. * @returns a new Mesh
  78479. */
  78480. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  78481. /**
  78482. * Creates a tiled ground mesh.
  78483. * Please consider using the same method from the MeshBuilder class instead
  78484. * @param name defines the name of the mesh to create
  78485. * @param xmin set the ground minimum X coordinate
  78486. * @param zmin set the ground minimum Y coordinate
  78487. * @param xmax set the ground maximum X coordinate
  78488. * @param zmax set the ground maximum Z coordinate
  78489. * @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
  78490. * @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
  78491. * @param scene defines the hosting scene
  78492. * @param updatable defines if the mesh must be flagged as updatable
  78493. * @returns a new Mesh
  78494. */
  78495. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  78496. w: number;
  78497. h: number;
  78498. }, precision: {
  78499. w: number;
  78500. h: number;
  78501. }, scene: Scene, updatable?: boolean): Mesh;
  78502. /**
  78503. * Creates a ground mesh from a height map.
  78504. * Please consider using the same method from the MeshBuilder class instead
  78505. * @see http://doc.babylonjs.com/babylon101/height_map
  78506. * @param name defines the name of the mesh to create
  78507. * @param url sets the URL of the height map image resource
  78508. * @param width set the ground width size
  78509. * @param height set the ground height size
  78510. * @param subdivisions sets the number of subdivision per side
  78511. * @param minHeight is the minimum altitude on the ground
  78512. * @param maxHeight is the maximum altitude on the ground
  78513. * @param scene defines the hosting scene
  78514. * @param updatable defines if the mesh must be flagged as updatable
  78515. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  78516. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  78517. * @returns a new Mesh
  78518. */
  78519. 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;
  78520. /**
  78521. * Creates a tube mesh.
  78522. * The tube is a parametric shape.
  78523. * It has no predefined shape. Its final shape will depend on the input parameters.
  78524. * Please consider using the same method from the MeshBuilder class instead
  78525. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  78526. * @param name defines the name of the mesh to create
  78527. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  78528. * @param radius sets the tube radius size
  78529. * @param tessellation is the number of sides on the tubular surface
  78530. * @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
  78531. * @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
  78532. * @param scene defines the hosting scene
  78533. * @param updatable defines if the mesh must be flagged as updatable
  78534. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78535. * @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)
  78536. * @returns a new Mesh
  78537. */
  78538. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  78539. (i: number, distance: number): number;
  78540. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  78541. /**
  78542. * Creates a polyhedron mesh.
  78543. * Please consider using the same method from the MeshBuilder class instead.
  78544. * * 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
  78545. * * The parameter `size` (positive float, default 1) sets the polygon size
  78546. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  78547. * * 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`
  78548. * * 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
  78549. * * 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)`)
  78550. * * 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
  78551. * * 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
  78552. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  78553. * * If you create a double-sided mesh, you can choose what parts of 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
  78554. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  78555. * @param name defines the name of the mesh to create
  78556. * @param options defines the options used to create the mesh
  78557. * @param scene defines the hosting scene
  78558. * @returns a new Mesh
  78559. */
  78560. static CreatePolyhedron(name: string, options: {
  78561. type?: number;
  78562. size?: number;
  78563. sizeX?: number;
  78564. sizeY?: number;
  78565. sizeZ?: number;
  78566. custom?: any;
  78567. faceUV?: Vector4[];
  78568. faceColors?: Color4[];
  78569. updatable?: boolean;
  78570. sideOrientation?: number;
  78571. }, scene: Scene): Mesh;
  78572. /**
  78573. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  78574. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  78575. * * 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`)
  78576. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  78577. * * 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
  78578. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  78579. * * If you create a double-sided mesh, you can choose what parts of 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
  78580. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  78581. * @param name defines the name of the mesh
  78582. * @param options defines the options used to create the mesh
  78583. * @param scene defines the hosting scene
  78584. * @returns a new Mesh
  78585. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  78586. */
  78587. static CreateIcoSphere(name: string, options: {
  78588. radius?: number;
  78589. flat?: boolean;
  78590. subdivisions?: number;
  78591. sideOrientation?: number;
  78592. updatable?: boolean;
  78593. }, scene: Scene): Mesh;
  78594. /**
  78595. * Creates a decal mesh.
  78596. * Please consider using the same method from the MeshBuilder class instead.
  78597. * A decal is a mesh usually applied as a model onto the surface of another mesh
  78598. * @param name defines the name of the mesh
  78599. * @param sourceMesh defines the mesh receiving the decal
  78600. * @param position sets the position of the decal in world coordinates
  78601. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  78602. * @param size sets the decal scaling
  78603. * @param angle sets the angle to rotate the decal
  78604. * @returns a new Mesh
  78605. */
  78606. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  78607. /**
  78608. * Prepare internal position array for software CPU skinning
  78609. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  78610. */
  78611. setPositionsForCPUSkinning(): Float32Array;
  78612. /**
  78613. * Prepare internal normal array for software CPU skinning
  78614. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  78615. */
  78616. setNormalsForCPUSkinning(): Float32Array;
  78617. /**
  78618. * Updates the vertex buffer by applying transformation from the bones
  78619. * @param skeleton defines the skeleton to apply to current mesh
  78620. * @returns the current mesh
  78621. */
  78622. applySkeleton(skeleton: Skeleton): Mesh;
  78623. /**
  78624. * 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
  78625. * @param meshes defines the list of meshes to scan
  78626. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  78627. */
  78628. static MinMax(meshes: AbstractMesh[]): {
  78629. min: Vector3;
  78630. max: Vector3;
  78631. };
  78632. /**
  78633. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  78634. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  78635. * @returns a vector3
  78636. */
  78637. static Center(meshesOrMinMaxVector: {
  78638. min: Vector3;
  78639. max: Vector3;
  78640. } | AbstractMesh[]): Vector3;
  78641. /**
  78642. * Merge the array of meshes into a single mesh for performance reasons.
  78643. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  78644. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  78645. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  78646. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  78647. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  78648. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  78649. * @returns a new mesh
  78650. */
  78651. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  78652. /** @hidden */
  78653. addInstance(instance: InstancedMesh): void;
  78654. /** @hidden */
  78655. removeInstance(instance: InstancedMesh): void;
  78656. }
  78657. }
  78658. declare module BABYLON {
  78659. /**
  78660. * Base class for the main features of a material in Babylon.js
  78661. */
  78662. export class Material implements IAnimatable {
  78663. /**
  78664. * Returns the triangle fill mode
  78665. */
  78666. static readonly TriangleFillMode: number;
  78667. /**
  78668. * Returns the wireframe mode
  78669. */
  78670. static readonly WireFrameFillMode: number;
  78671. /**
  78672. * Returns the point fill mode
  78673. */
  78674. static readonly PointFillMode: number;
  78675. /**
  78676. * Returns the point list draw mode
  78677. */
  78678. static readonly PointListDrawMode: number;
  78679. /**
  78680. * Returns the line list draw mode
  78681. */
  78682. static readonly LineListDrawMode: number;
  78683. /**
  78684. * Returns the line loop draw mode
  78685. */
  78686. static readonly LineLoopDrawMode: number;
  78687. /**
  78688. * Returns the line strip draw mode
  78689. */
  78690. static readonly LineStripDrawMode: number;
  78691. /**
  78692. * Returns the triangle strip draw mode
  78693. */
  78694. static readonly TriangleStripDrawMode: number;
  78695. /**
  78696. * Returns the triangle fan draw mode
  78697. */
  78698. static readonly TriangleFanDrawMode: number;
  78699. /**
  78700. * Stores the clock-wise side orientation
  78701. */
  78702. static readonly ClockWiseSideOrientation: number;
  78703. /**
  78704. * Stores the counter clock-wise side orientation
  78705. */
  78706. static readonly CounterClockWiseSideOrientation: number;
  78707. /**
  78708. * The dirty texture flag value
  78709. */
  78710. static readonly TextureDirtyFlag: number;
  78711. /**
  78712. * The dirty light flag value
  78713. */
  78714. static readonly LightDirtyFlag: number;
  78715. /**
  78716. * The dirty fresnel flag value
  78717. */
  78718. static readonly FresnelDirtyFlag: number;
  78719. /**
  78720. * The dirty attribute flag value
  78721. */
  78722. static readonly AttributesDirtyFlag: number;
  78723. /**
  78724. * The dirty misc flag value
  78725. */
  78726. static readonly MiscDirtyFlag: number;
  78727. /**
  78728. * The all dirty flag value
  78729. */
  78730. static readonly AllDirtyFlag: number;
  78731. /**
  78732. * The ID of the material
  78733. */
  78734. id: string;
  78735. /**
  78736. * Gets or sets the unique id of the material
  78737. */
  78738. uniqueId: number;
  78739. /**
  78740. * The name of the material
  78741. */
  78742. name: string;
  78743. /**
  78744. * Gets or sets user defined metadata
  78745. */
  78746. metadata: any;
  78747. /**
  78748. * For internal use only. Please do not use.
  78749. */
  78750. reservedDataStore: any;
  78751. /**
  78752. * Specifies if the ready state should be checked on each call
  78753. */
  78754. checkReadyOnEveryCall: boolean;
  78755. /**
  78756. * Specifies if the ready state should be checked once
  78757. */
  78758. checkReadyOnlyOnce: boolean;
  78759. /**
  78760. * The state of the material
  78761. */
  78762. state: string;
  78763. /**
  78764. * The alpha value of the material
  78765. */
  78766. protected _alpha: number;
  78767. /**
  78768. * Sets the alpha value of the material
  78769. */
  78770. /**
  78771. * Gets the alpha value of the material
  78772. */
  78773. alpha: number;
  78774. /**
  78775. * Specifies if back face culling is enabled
  78776. */
  78777. protected _backFaceCulling: boolean;
  78778. /**
  78779. * Sets the back-face culling state
  78780. */
  78781. /**
  78782. * Gets the back-face culling state
  78783. */
  78784. backFaceCulling: boolean;
  78785. /**
  78786. * Stores the value for side orientation
  78787. */
  78788. sideOrientation: number;
  78789. /**
  78790. * Callback triggered when the material is compiled
  78791. */
  78792. onCompiled: (effect: Effect) => void;
  78793. /**
  78794. * Callback triggered when an error occurs
  78795. */
  78796. onError: (effect: Effect, errors: string) => void;
  78797. /**
  78798. * Callback triggered to get the render target textures
  78799. */
  78800. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  78801. /**
  78802. * Gets a boolean indicating that current material needs to register RTT
  78803. */
  78804. readonly hasRenderTargetTextures: boolean;
  78805. /**
  78806. * Specifies if the material should be serialized
  78807. */
  78808. doNotSerialize: boolean;
  78809. /**
  78810. * @hidden
  78811. */
  78812. _storeEffectOnSubMeshes: boolean;
  78813. /**
  78814. * Stores the animations for the material
  78815. */
  78816. animations: Array<Animation>;
  78817. /**
  78818. * An event triggered when the material is disposed
  78819. */
  78820. onDisposeObservable: Observable<Material>;
  78821. /**
  78822. * An observer which watches for dispose events
  78823. */
  78824. private _onDisposeObserver;
  78825. private _onUnBindObservable;
  78826. /**
  78827. * Called during a dispose event
  78828. */
  78829. onDispose: () => void;
  78830. private _onBindObservable;
  78831. /**
  78832. * An event triggered when the material is bound
  78833. */
  78834. readonly onBindObservable: Observable<AbstractMesh>;
  78835. /**
  78836. * An observer which watches for bind events
  78837. */
  78838. private _onBindObserver;
  78839. /**
  78840. * Called during a bind event
  78841. */
  78842. onBind: (Mesh: AbstractMesh) => void;
  78843. /**
  78844. * An event triggered when the material is unbound
  78845. */
  78846. readonly onUnBindObservable: Observable<Material>;
  78847. /**
  78848. * Stores the value of the alpha mode
  78849. */
  78850. private _alphaMode;
  78851. /**
  78852. * Sets the value of the alpha mode.
  78853. *
  78854. * | Value | Type | Description |
  78855. * | --- | --- | --- |
  78856. * | 0 | ALPHA_DISABLE | |
  78857. * | 1 | ALPHA_ADD | |
  78858. * | 2 | ALPHA_COMBINE | |
  78859. * | 3 | ALPHA_SUBTRACT | |
  78860. * | 4 | ALPHA_MULTIPLY | |
  78861. * | 5 | ALPHA_MAXIMIZED | |
  78862. * | 6 | ALPHA_ONEONE | |
  78863. * | 7 | ALPHA_PREMULTIPLIED | |
  78864. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  78865. * | 9 | ALPHA_INTERPOLATE | |
  78866. * | 10 | ALPHA_SCREENMODE | |
  78867. *
  78868. */
  78869. /**
  78870. * Gets the value of the alpha mode
  78871. */
  78872. alphaMode: number;
  78873. /**
  78874. * Stores the state of the need depth pre-pass value
  78875. */
  78876. private _needDepthPrePass;
  78877. /**
  78878. * Sets the need depth pre-pass value
  78879. */
  78880. /**
  78881. * Gets the depth pre-pass value
  78882. */
  78883. needDepthPrePass: boolean;
  78884. /**
  78885. * Specifies if depth writing should be disabled
  78886. */
  78887. disableDepthWrite: boolean;
  78888. /**
  78889. * Specifies if depth writing should be forced
  78890. */
  78891. forceDepthWrite: boolean;
  78892. /**
  78893. * Specifies if there should be a separate pass for culling
  78894. */
  78895. separateCullingPass: boolean;
  78896. /**
  78897. * Stores the state specifing if fog should be enabled
  78898. */
  78899. private _fogEnabled;
  78900. /**
  78901. * Sets the state for enabling fog
  78902. */
  78903. /**
  78904. * Gets the value of the fog enabled state
  78905. */
  78906. fogEnabled: boolean;
  78907. /**
  78908. * Stores the size of points
  78909. */
  78910. pointSize: number;
  78911. /**
  78912. * Stores the z offset value
  78913. */
  78914. zOffset: number;
  78915. /**
  78916. * Gets a value specifying if wireframe mode is enabled
  78917. */
  78918. /**
  78919. * Sets the state of wireframe mode
  78920. */
  78921. wireframe: boolean;
  78922. /**
  78923. * Gets the value specifying if point clouds are enabled
  78924. */
  78925. /**
  78926. * Sets the state of point cloud mode
  78927. */
  78928. pointsCloud: boolean;
  78929. /**
  78930. * Gets the material fill mode
  78931. */
  78932. /**
  78933. * Sets the material fill mode
  78934. */
  78935. fillMode: number;
  78936. /**
  78937. * @hidden
  78938. * Stores the effects for the material
  78939. */
  78940. _effect: Nullable<Effect>;
  78941. /**
  78942. * @hidden
  78943. * Specifies if the material was previously ready
  78944. */
  78945. _wasPreviouslyReady: boolean;
  78946. /**
  78947. * Specifies if uniform buffers should be used
  78948. */
  78949. private _useUBO;
  78950. /**
  78951. * Stores a reference to the scene
  78952. */
  78953. private _scene;
  78954. /**
  78955. * Stores the fill mode state
  78956. */
  78957. private _fillMode;
  78958. /**
  78959. * Specifies if the depth write state should be cached
  78960. */
  78961. private _cachedDepthWriteState;
  78962. /**
  78963. * Stores the uniform buffer
  78964. */
  78965. protected _uniformBuffer: UniformBuffer;
  78966. /** @hidden */
  78967. _indexInSceneMaterialArray: number;
  78968. /** @hidden */
  78969. meshMap: Nullable<{
  78970. [id: string]: AbstractMesh | undefined;
  78971. }>;
  78972. /**
  78973. * Creates a material instance
  78974. * @param name defines the name of the material
  78975. * @param scene defines the scene to reference
  78976. * @param doNotAdd specifies if the material should be added to the scene
  78977. */
  78978. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  78979. /**
  78980. * Returns a string representation of the current material
  78981. * @param fullDetails defines a boolean indicating which levels of logging is desired
  78982. * @returns a string with material information
  78983. */
  78984. toString(fullDetails?: boolean): string;
  78985. /**
  78986. * Gets the class name of the material
  78987. * @returns a string with the class name of the material
  78988. */
  78989. getClassName(): string;
  78990. /**
  78991. * Specifies if updates for the material been locked
  78992. */
  78993. readonly isFrozen: boolean;
  78994. /**
  78995. * Locks updates for the material
  78996. */
  78997. freeze(): void;
  78998. /**
  78999. * Unlocks updates for the material
  79000. */
  79001. unfreeze(): void;
  79002. /**
  79003. * Specifies if the material is ready to be used
  79004. * @param mesh defines the mesh to check
  79005. * @param useInstances specifies if instances should be used
  79006. * @returns a boolean indicating if the material is ready to be used
  79007. */
  79008. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  79009. /**
  79010. * Specifies that the submesh is ready to be used
  79011. * @param mesh defines the mesh to check
  79012. * @param subMesh defines which submesh to check
  79013. * @param useInstances specifies that instances should be used
  79014. * @returns a boolean indicating that the submesh is ready or not
  79015. */
  79016. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  79017. /**
  79018. * Returns the material effect
  79019. * @returns the effect associated with the material
  79020. */
  79021. getEffect(): Nullable<Effect>;
  79022. /**
  79023. * Returns the current scene
  79024. * @returns a Scene
  79025. */
  79026. getScene(): Scene;
  79027. /**
  79028. * Specifies if the material will require alpha blending
  79029. * @returns a boolean specifying if alpha blending is needed
  79030. */
  79031. needAlphaBlending(): boolean;
  79032. /**
  79033. * Specifies if the mesh will require alpha blending
  79034. * @param mesh defines the mesh to check
  79035. * @returns a boolean specifying if alpha blending is needed for the mesh
  79036. */
  79037. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  79038. /**
  79039. * Specifies if this material should be rendered in alpha test mode
  79040. * @returns a boolean specifying if an alpha test is needed.
  79041. */
  79042. needAlphaTesting(): boolean;
  79043. /**
  79044. * Gets the texture used for the alpha test
  79045. * @returns the texture to use for alpha testing
  79046. */
  79047. getAlphaTestTexture(): Nullable<BaseTexture>;
  79048. /**
  79049. * Marks the material to indicate that it needs to be re-calculated
  79050. */
  79051. markDirty(): void;
  79052. /** @hidden */
  79053. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  79054. /**
  79055. * Binds the material to the mesh
  79056. * @param world defines the world transformation matrix
  79057. * @param mesh defines the mesh to bind the material to
  79058. */
  79059. bind(world: Matrix, mesh?: Mesh): void;
  79060. /**
  79061. * Binds the submesh to the material
  79062. * @param world defines the world transformation matrix
  79063. * @param mesh defines the mesh containing the submesh
  79064. * @param subMesh defines the submesh to bind the material to
  79065. */
  79066. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  79067. /**
  79068. * Binds the world matrix to the material
  79069. * @param world defines the world transformation matrix
  79070. */
  79071. bindOnlyWorldMatrix(world: Matrix): void;
  79072. /**
  79073. * Binds the scene's uniform buffer to the effect.
  79074. * @param effect defines the effect to bind to the scene uniform buffer
  79075. * @param sceneUbo defines the uniform buffer storing scene data
  79076. */
  79077. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  79078. /**
  79079. * Binds the view matrix to the effect
  79080. * @param effect defines the effect to bind the view matrix to
  79081. */
  79082. bindView(effect: Effect): void;
  79083. /**
  79084. * Binds the view projection matrix to the effect
  79085. * @param effect defines the effect to bind the view projection matrix to
  79086. */
  79087. bindViewProjection(effect: Effect): void;
  79088. /**
  79089. * Specifies if material alpha testing should be turned on for the mesh
  79090. * @param mesh defines the mesh to check
  79091. */
  79092. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  79093. /**
  79094. * Processes to execute after binding the material to a mesh
  79095. * @param mesh defines the rendered mesh
  79096. */
  79097. protected _afterBind(mesh?: Mesh): void;
  79098. /**
  79099. * Unbinds the material from the mesh
  79100. */
  79101. unbind(): void;
  79102. /**
  79103. * Gets the active textures from the material
  79104. * @returns an array of textures
  79105. */
  79106. getActiveTextures(): BaseTexture[];
  79107. /**
  79108. * Specifies if the material uses a texture
  79109. * @param texture defines the texture to check against the material
  79110. * @returns a boolean specifying if the material uses the texture
  79111. */
  79112. hasTexture(texture: BaseTexture): boolean;
  79113. /**
  79114. * Makes a duplicate of the material, and gives it a new name
  79115. * @param name defines the new name for the duplicated material
  79116. * @returns the cloned material
  79117. */
  79118. clone(name: string): Nullable<Material>;
  79119. /**
  79120. * Gets the meshes bound to the material
  79121. * @returns an array of meshes bound to the material
  79122. */
  79123. getBindedMeshes(): AbstractMesh[];
  79124. /**
  79125. * Force shader compilation
  79126. * @param mesh defines the mesh associated with this material
  79127. * @param onCompiled defines a function to execute once the material is compiled
  79128. * @param options defines the options to configure the compilation
  79129. */
  79130. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  79131. clipPlane: boolean;
  79132. }>): void;
  79133. /**
  79134. * Force shader compilation
  79135. * @param mesh defines the mesh that will use this material
  79136. * @param options defines additional options for compiling the shaders
  79137. * @returns a promise that resolves when the compilation completes
  79138. */
  79139. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  79140. clipPlane: boolean;
  79141. }>): Promise<void>;
  79142. private static readonly _ImageProcessingDirtyCallBack;
  79143. private static readonly _TextureDirtyCallBack;
  79144. private static readonly _FresnelDirtyCallBack;
  79145. private static readonly _MiscDirtyCallBack;
  79146. private static readonly _LightsDirtyCallBack;
  79147. private static readonly _AttributeDirtyCallBack;
  79148. private static _FresnelAndMiscDirtyCallBack;
  79149. private static _TextureAndMiscDirtyCallBack;
  79150. private static readonly _DirtyCallbackArray;
  79151. private static readonly _RunDirtyCallBacks;
  79152. /**
  79153. * Marks a define in the material to indicate that it needs to be re-computed
  79154. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  79155. */
  79156. markAsDirty(flag: number): void;
  79157. /**
  79158. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  79159. * @param func defines a function which checks material defines against the submeshes
  79160. */
  79161. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  79162. /**
  79163. * Indicates that image processing needs to be re-calculated for all submeshes
  79164. */
  79165. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  79166. /**
  79167. * Indicates that textures need to be re-calculated for all submeshes
  79168. */
  79169. protected _markAllSubMeshesAsTexturesDirty(): void;
  79170. /**
  79171. * Indicates that fresnel needs to be re-calculated for all submeshes
  79172. */
  79173. protected _markAllSubMeshesAsFresnelDirty(): void;
  79174. /**
  79175. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  79176. */
  79177. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  79178. /**
  79179. * Indicates that lights need to be re-calculated for all submeshes
  79180. */
  79181. protected _markAllSubMeshesAsLightsDirty(): void;
  79182. /**
  79183. * Indicates that attributes need to be re-calculated for all submeshes
  79184. */
  79185. protected _markAllSubMeshesAsAttributesDirty(): void;
  79186. /**
  79187. * Indicates that misc needs to be re-calculated for all submeshes
  79188. */
  79189. protected _markAllSubMeshesAsMiscDirty(): void;
  79190. /**
  79191. * Indicates that textures and misc need to be re-calculated for all submeshes
  79192. */
  79193. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  79194. /**
  79195. * Disposes the material
  79196. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  79197. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  79198. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  79199. */
  79200. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  79201. /** @hidden */
  79202. private releaseVertexArrayObject;
  79203. /**
  79204. * Serializes this material
  79205. * @returns the serialized material object
  79206. */
  79207. serialize(): any;
  79208. /**
  79209. * Creates a material from parsed material data
  79210. * @param parsedMaterial defines parsed material data
  79211. * @param scene defines the hosting scene
  79212. * @param rootUrl defines the root URL to use to load textures
  79213. * @returns a new material
  79214. */
  79215. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): any;
  79216. }
  79217. }
  79218. declare module BABYLON {
  79219. /**
  79220. * Base class for submeshes
  79221. */
  79222. export class BaseSubMesh {
  79223. /** @hidden */
  79224. _materialDefines: Nullable<MaterialDefines>;
  79225. /** @hidden */
  79226. _materialEffect: Nullable<Effect>;
  79227. /**
  79228. * Gets associated effect
  79229. */
  79230. readonly effect: Nullable<Effect>;
  79231. /**
  79232. * Sets associated effect (effect used to render this submesh)
  79233. * @param effect defines the effect to associate with
  79234. * @param defines defines the set of defines used to compile this effect
  79235. */
  79236. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  79237. }
  79238. /**
  79239. * Defines a subdivision inside a mesh
  79240. */
  79241. export class SubMesh extends BaseSubMesh implements ICullable {
  79242. /** the material index to use */
  79243. materialIndex: number;
  79244. /** vertex index start */
  79245. verticesStart: number;
  79246. /** vertices count */
  79247. verticesCount: number;
  79248. /** index start */
  79249. indexStart: number;
  79250. /** indices count */
  79251. indexCount: number;
  79252. /** @hidden */
  79253. _linesIndexCount: number;
  79254. private _mesh;
  79255. private _renderingMesh;
  79256. private _boundingInfo;
  79257. private _linesIndexBuffer;
  79258. /** @hidden */
  79259. _lastColliderWorldVertices: Nullable<Vector3[]>;
  79260. /** @hidden */
  79261. _trianglePlanes: Plane[];
  79262. /** @hidden */
  79263. _lastColliderTransformMatrix: Matrix;
  79264. /** @hidden */
  79265. _renderId: number;
  79266. /** @hidden */
  79267. _alphaIndex: number;
  79268. /** @hidden */
  79269. _distanceToCamera: number;
  79270. /** @hidden */
  79271. _id: number;
  79272. private _currentMaterial;
  79273. /**
  79274. * Add a new submesh to a mesh
  79275. * @param materialIndex defines the material index to use
  79276. * @param verticesStart defines vertex index start
  79277. * @param verticesCount defines vertices count
  79278. * @param indexStart defines index start
  79279. * @param indexCount defines indices count
  79280. * @param mesh defines the parent mesh
  79281. * @param renderingMesh defines an optional rendering mesh
  79282. * @param createBoundingBox defines if bounding box should be created for this submesh
  79283. * @returns the new submesh
  79284. */
  79285. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  79286. /**
  79287. * Creates a new submesh
  79288. * @param materialIndex defines the material index to use
  79289. * @param verticesStart defines vertex index start
  79290. * @param verticesCount defines vertices count
  79291. * @param indexStart defines index start
  79292. * @param indexCount defines indices count
  79293. * @param mesh defines the parent mesh
  79294. * @param renderingMesh defines an optional rendering mesh
  79295. * @param createBoundingBox defines if bounding box should be created for this submesh
  79296. */
  79297. constructor(
  79298. /** the material index to use */
  79299. materialIndex: number,
  79300. /** vertex index start */
  79301. verticesStart: number,
  79302. /** vertices count */
  79303. verticesCount: number,
  79304. /** index start */
  79305. indexStart: number,
  79306. /** indices count */
  79307. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  79308. /**
  79309. * Returns true if this submesh covers the entire parent mesh
  79310. * @ignorenaming
  79311. */
  79312. readonly IsGlobal: boolean;
  79313. /**
  79314. * Returns the submesh BoudingInfo object
  79315. * @returns current bounding info (or mesh's one if the submesh is global)
  79316. */
  79317. getBoundingInfo(): BoundingInfo;
  79318. /**
  79319. * Sets the submesh BoundingInfo
  79320. * @param boundingInfo defines the new bounding info to use
  79321. * @returns the SubMesh
  79322. */
  79323. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  79324. /**
  79325. * Returns the mesh of the current submesh
  79326. * @return the parent mesh
  79327. */
  79328. getMesh(): AbstractMesh;
  79329. /**
  79330. * Returns the rendering mesh of the submesh
  79331. * @returns the rendering mesh (could be different from parent mesh)
  79332. */
  79333. getRenderingMesh(): Mesh;
  79334. /**
  79335. * Returns the submesh material
  79336. * @returns null or the current material
  79337. */
  79338. getMaterial(): Nullable<Material>;
  79339. /**
  79340. * Sets a new updated BoundingInfo object to the submesh
  79341. * @returns the SubMesh
  79342. */
  79343. refreshBoundingInfo(): SubMesh;
  79344. /** @hidden */
  79345. _checkCollision(collider: Collider): boolean;
  79346. /**
  79347. * Updates the submesh BoundingInfo
  79348. * @param world defines the world matrix to use to update the bounding info
  79349. * @returns the submesh
  79350. */
  79351. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  79352. /**
  79353. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  79354. * @param frustumPlanes defines the frustum planes
  79355. * @returns true if the submesh is intersecting with the frustum
  79356. */
  79357. isInFrustum(frustumPlanes: Plane[]): boolean;
  79358. /**
  79359. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  79360. * @param frustumPlanes defines the frustum planes
  79361. * @returns true if the submesh is inside the frustum
  79362. */
  79363. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  79364. /**
  79365. * Renders the submesh
  79366. * @param enableAlphaMode defines if alpha needs to be used
  79367. * @returns the submesh
  79368. */
  79369. render(enableAlphaMode: boolean): SubMesh;
  79370. /**
  79371. * @hidden
  79372. */
  79373. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  79374. /**
  79375. * Checks if the submesh intersects with a ray
  79376. * @param ray defines the ray to test
  79377. * @returns true is the passed ray intersects the submesh bounding box
  79378. */
  79379. canIntersects(ray: Ray): boolean;
  79380. /**
  79381. * Intersects current submesh with a ray
  79382. * @param ray defines the ray to test
  79383. * @param positions defines mesh's positions array
  79384. * @param indices defines mesh's indices array
  79385. * @param fastCheck defines if only bounding info should be used
  79386. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  79387. * @returns intersection info or null if no intersection
  79388. */
  79389. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  79390. /** @hidden */
  79391. private _intersectLines;
  79392. /** @hidden */
  79393. private _intersectTriangles;
  79394. /** @hidden */
  79395. _rebuild(): void;
  79396. /**
  79397. * Creates a new submesh from the passed mesh
  79398. * @param newMesh defines the new hosting mesh
  79399. * @param newRenderingMesh defines an optional rendering mesh
  79400. * @returns the new submesh
  79401. */
  79402. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  79403. /**
  79404. * Release associated resources
  79405. */
  79406. dispose(): void;
  79407. /**
  79408. * Gets the class name
  79409. * @returns the string "SubMesh".
  79410. */
  79411. getClassName(): string;
  79412. /**
  79413. * Creates a new submesh from indices data
  79414. * @param materialIndex the index of the main mesh material
  79415. * @param startIndex the index where to start the copy in the mesh indices array
  79416. * @param indexCount the number of indices to copy then from the startIndex
  79417. * @param mesh the main mesh to create the submesh from
  79418. * @param renderingMesh the optional rendering mesh
  79419. * @returns a new submesh
  79420. */
  79421. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  79422. }
  79423. }
  79424. declare module BABYLON {
  79425. /**
  79426. * Class used to store geometry data (vertex buffers + index buffer)
  79427. */
  79428. export class Geometry implements IGetSetVerticesData {
  79429. /**
  79430. * Gets or sets the ID of the geometry
  79431. */
  79432. id: string;
  79433. /**
  79434. * Gets or sets the unique ID of the geometry
  79435. */
  79436. uniqueId: number;
  79437. /**
  79438. * Gets the delay loading state of the geometry (none by default which means not delayed)
  79439. */
  79440. delayLoadState: number;
  79441. /**
  79442. * Gets the file containing the data to load when running in delay load state
  79443. */
  79444. delayLoadingFile: Nullable<string>;
  79445. /**
  79446. * Callback called when the geometry is updated
  79447. */
  79448. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  79449. private _scene;
  79450. private _engine;
  79451. private _meshes;
  79452. private _totalVertices;
  79453. /** @hidden */
  79454. _indices: IndicesArray;
  79455. /** @hidden */
  79456. _vertexBuffers: {
  79457. [key: string]: VertexBuffer;
  79458. };
  79459. private _isDisposed;
  79460. private _extend;
  79461. private _boundingBias;
  79462. /** @hidden */
  79463. _delayInfo: Array<string>;
  79464. private _indexBuffer;
  79465. private _indexBufferIsUpdatable;
  79466. /** @hidden */
  79467. _boundingInfo: Nullable<BoundingInfo>;
  79468. /** @hidden */
  79469. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  79470. /** @hidden */
  79471. _softwareSkinningFrameId: number;
  79472. private _vertexArrayObjects;
  79473. private _updatable;
  79474. /** @hidden */
  79475. _positions: Nullable<Vector3[]>;
  79476. /**
  79477. * 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
  79478. */
  79479. /**
  79480. * 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
  79481. */
  79482. boundingBias: Vector2;
  79483. /**
  79484. * Static function used to attach a new empty geometry to a mesh
  79485. * @param mesh defines the mesh to attach the geometry to
  79486. * @returns the new Geometry
  79487. */
  79488. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  79489. /**
  79490. * Creates a new geometry
  79491. * @param id defines the unique ID
  79492. * @param scene defines the hosting scene
  79493. * @param vertexData defines the VertexData used to get geometry data
  79494. * @param updatable defines if geometry must be updatable (false by default)
  79495. * @param mesh defines the mesh that will be associated with the geometry
  79496. */
  79497. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  79498. /**
  79499. * Gets the current extend of the geometry
  79500. */
  79501. readonly extend: {
  79502. minimum: Vector3;
  79503. maximum: Vector3;
  79504. };
  79505. /**
  79506. * Gets the hosting scene
  79507. * @returns the hosting Scene
  79508. */
  79509. getScene(): Scene;
  79510. /**
  79511. * Gets the hosting engine
  79512. * @returns the hosting Engine
  79513. */
  79514. getEngine(): Engine;
  79515. /**
  79516. * Defines if the geometry is ready to use
  79517. * @returns true if the geometry is ready to be used
  79518. */
  79519. isReady(): boolean;
  79520. /**
  79521. * Gets a value indicating that the geometry should not be serialized
  79522. */
  79523. readonly doNotSerialize: boolean;
  79524. /** @hidden */
  79525. _rebuild(): void;
  79526. /**
  79527. * Affects all geometry data in one call
  79528. * @param vertexData defines the geometry data
  79529. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  79530. */
  79531. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  79532. /**
  79533. * Set specific vertex data
  79534. * @param kind defines the data kind (Position, normal, etc...)
  79535. * @param data defines the vertex data to use
  79536. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  79537. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  79538. */
  79539. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  79540. /**
  79541. * Removes a specific vertex data
  79542. * @param kind defines the data kind (Position, normal, etc...)
  79543. */
  79544. removeVerticesData(kind: string): void;
  79545. /**
  79546. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  79547. * @param buffer defines the vertex buffer to use
  79548. * @param totalVertices defines the total number of vertices for position kind (could be null)
  79549. */
  79550. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  79551. /**
  79552. * Update a specific vertex buffer
  79553. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  79554. * It will do nothing if the buffer is not updatable
  79555. * @param kind defines the data kind (Position, normal, etc...)
  79556. * @param data defines the data to use
  79557. * @param offset defines the offset in the target buffer where to store the data
  79558. * @param useBytes set to true if the offset is in bytes
  79559. */
  79560. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  79561. /**
  79562. * Update a specific vertex buffer
  79563. * This function will create a new buffer if the current one is not updatable
  79564. * @param kind defines the data kind (Position, normal, etc...)
  79565. * @param data defines the data to use
  79566. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  79567. */
  79568. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  79569. private _updateBoundingInfo;
  79570. /** @hidden */
  79571. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  79572. /**
  79573. * Gets total number of vertices
  79574. * @returns the total number of vertices
  79575. */
  79576. getTotalVertices(): number;
  79577. /**
  79578. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  79579. * @param kind defines the data kind (Position, normal, etc...)
  79580. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  79581. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  79582. * @returns a float array containing vertex data
  79583. */
  79584. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  79585. /**
  79586. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  79587. * @param kind defines the data kind (Position, normal, etc...)
  79588. * @returns true if the vertex buffer with the specified kind is updatable
  79589. */
  79590. isVertexBufferUpdatable(kind: string): boolean;
  79591. /**
  79592. * Gets a specific vertex buffer
  79593. * @param kind defines the data kind (Position, normal, etc...)
  79594. * @returns a VertexBuffer
  79595. */
  79596. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  79597. /**
  79598. * Returns all vertex buffers
  79599. * @return an object holding all vertex buffers indexed by kind
  79600. */
  79601. getVertexBuffers(): Nullable<{
  79602. [key: string]: VertexBuffer;
  79603. }>;
  79604. /**
  79605. * Gets a boolean indicating if specific vertex buffer is present
  79606. * @param kind defines the data kind (Position, normal, etc...)
  79607. * @returns true if data is present
  79608. */
  79609. isVerticesDataPresent(kind: string): boolean;
  79610. /**
  79611. * Gets a list of all attached data kinds (Position, normal, etc...)
  79612. * @returns a list of string containing all kinds
  79613. */
  79614. getVerticesDataKinds(): string[];
  79615. /**
  79616. * Update index buffer
  79617. * @param indices defines the indices to store in the index buffer
  79618. * @param offset defines the offset in the target buffer where to store the data
  79619. * @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)
  79620. */
  79621. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  79622. /**
  79623. * Creates a new index buffer
  79624. * @param indices defines the indices to store in the index buffer
  79625. * @param totalVertices defines the total number of vertices (could be null)
  79626. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  79627. */
  79628. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  79629. /**
  79630. * Return the total number of indices
  79631. * @returns the total number of indices
  79632. */
  79633. getTotalIndices(): number;
  79634. /**
  79635. * Gets the index buffer array
  79636. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  79637. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  79638. * @returns the index buffer array
  79639. */
  79640. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  79641. /**
  79642. * Gets the index buffer
  79643. * @return the index buffer
  79644. */
  79645. getIndexBuffer(): Nullable<WebGLBuffer>;
  79646. /** @hidden */
  79647. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  79648. /**
  79649. * Release the associated resources for a specific mesh
  79650. * @param mesh defines the source mesh
  79651. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  79652. */
  79653. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  79654. /**
  79655. * Apply current geometry to a given mesh
  79656. * @param mesh defines the mesh to apply geometry to
  79657. */
  79658. applyToMesh(mesh: Mesh): void;
  79659. private _updateExtend;
  79660. private _applyToMesh;
  79661. private notifyUpdate;
  79662. /**
  79663. * Load the geometry if it was flagged as delay loaded
  79664. * @param scene defines the hosting scene
  79665. * @param onLoaded defines a callback called when the geometry is loaded
  79666. */
  79667. load(scene: Scene, onLoaded?: () => void): void;
  79668. private _queueLoad;
  79669. /**
  79670. * Invert the geometry to move from a right handed system to a left handed one.
  79671. */
  79672. toLeftHanded(): void;
  79673. /** @hidden */
  79674. _resetPointsArrayCache(): void;
  79675. /** @hidden */
  79676. _generatePointsArray(): boolean;
  79677. /**
  79678. * Gets a value indicating if the geometry is disposed
  79679. * @returns true if the geometry was disposed
  79680. */
  79681. isDisposed(): boolean;
  79682. private _disposeVertexArrayObjects;
  79683. /**
  79684. * Free all associated resources
  79685. */
  79686. dispose(): void;
  79687. /**
  79688. * Clone the current geometry into a new geometry
  79689. * @param id defines the unique ID of the new geometry
  79690. * @returns a new geometry object
  79691. */
  79692. copy(id: string): Geometry;
  79693. /**
  79694. * Serialize the current geometry info (and not the vertices data) into a JSON object
  79695. * @return a JSON representation of the current geometry data (without the vertices data)
  79696. */
  79697. serialize(): any;
  79698. private toNumberArray;
  79699. /**
  79700. * Serialize all vertices data into a JSON oject
  79701. * @returns a JSON representation of the current geometry data
  79702. */
  79703. serializeVerticeData(): any;
  79704. /**
  79705. * Extracts a clone of a mesh geometry
  79706. * @param mesh defines the source mesh
  79707. * @param id defines the unique ID of the new geometry object
  79708. * @returns the new geometry object
  79709. */
  79710. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  79711. /**
  79712. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  79713. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  79714. * Be aware Math.random() could cause collisions, but:
  79715. * "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"
  79716. * @returns a string containing a new GUID
  79717. */
  79718. static RandomId(): string;
  79719. /** @hidden */
  79720. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  79721. private static _CleanMatricesWeights;
  79722. /**
  79723. * Create a new geometry from persisted data (Using .babylon file format)
  79724. * @param parsedVertexData defines the persisted data
  79725. * @param scene defines the hosting scene
  79726. * @param rootUrl defines the root url to use to load assets (like delayed data)
  79727. * @returns the new geometry object
  79728. */
  79729. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  79730. }
  79731. }
  79732. declare module BABYLON {
  79733. /**
  79734. * Define an interface for all classes that will get and set the data on vertices
  79735. */
  79736. export interface IGetSetVerticesData {
  79737. /**
  79738. * Gets a boolean indicating if specific vertex data is present
  79739. * @param kind defines the vertex data kind to use
  79740. * @returns true is data kind is present
  79741. */
  79742. isVerticesDataPresent(kind: string): boolean;
  79743. /**
  79744. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  79745. * @param kind defines the data kind (Position, normal, etc...)
  79746. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  79747. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  79748. * @returns a float array containing vertex data
  79749. */
  79750. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  79751. /**
  79752. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  79753. * @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.
  79754. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  79755. * @returns the indices array or an empty array if the mesh has no geometry
  79756. */
  79757. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  79758. /**
  79759. * Set specific vertex data
  79760. * @param kind defines the data kind (Position, normal, etc...)
  79761. * @param data defines the vertex data to use
  79762. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  79763. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  79764. */
  79765. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  79766. /**
  79767. * Update a specific associated vertex buffer
  79768. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  79769. * - VertexBuffer.PositionKind
  79770. * - VertexBuffer.UVKind
  79771. * - VertexBuffer.UV2Kind
  79772. * - VertexBuffer.UV3Kind
  79773. * - VertexBuffer.UV4Kind
  79774. * - VertexBuffer.UV5Kind
  79775. * - VertexBuffer.UV6Kind
  79776. * - VertexBuffer.ColorKind
  79777. * - VertexBuffer.MatricesIndicesKind
  79778. * - VertexBuffer.MatricesIndicesExtraKind
  79779. * - VertexBuffer.MatricesWeightsKind
  79780. * - VertexBuffer.MatricesWeightsExtraKind
  79781. * @param data defines the data source
  79782. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  79783. * @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)
  79784. */
  79785. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  79786. /**
  79787. * Creates a new index buffer
  79788. * @param indices defines the indices to store in the index buffer
  79789. * @param totalVertices defines the total number of vertices (could be null)
  79790. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  79791. */
  79792. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  79793. }
  79794. /**
  79795. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  79796. */
  79797. export class VertexData {
  79798. /**
  79799. * Mesh side orientation : usually the external or front surface
  79800. */
  79801. static readonly FRONTSIDE: number;
  79802. /**
  79803. * Mesh side orientation : usually the internal or back surface
  79804. */
  79805. static readonly BACKSIDE: number;
  79806. /**
  79807. * Mesh side orientation : both internal and external or front and back surfaces
  79808. */
  79809. static readonly DOUBLESIDE: number;
  79810. /**
  79811. * Mesh side orientation : by default, `FRONTSIDE`
  79812. */
  79813. static readonly DEFAULTSIDE: number;
  79814. /**
  79815. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  79816. */
  79817. positions: Nullable<FloatArray>;
  79818. /**
  79819. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  79820. */
  79821. normals: Nullable<FloatArray>;
  79822. /**
  79823. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  79824. */
  79825. tangents: Nullable<FloatArray>;
  79826. /**
  79827. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  79828. */
  79829. uvs: Nullable<FloatArray>;
  79830. /**
  79831. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  79832. */
  79833. uvs2: Nullable<FloatArray>;
  79834. /**
  79835. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  79836. */
  79837. uvs3: Nullable<FloatArray>;
  79838. /**
  79839. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  79840. */
  79841. uvs4: Nullable<FloatArray>;
  79842. /**
  79843. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  79844. */
  79845. uvs5: Nullable<FloatArray>;
  79846. /**
  79847. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  79848. */
  79849. uvs6: Nullable<FloatArray>;
  79850. /**
  79851. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  79852. */
  79853. colors: Nullable<FloatArray>;
  79854. /**
  79855. * 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).
  79856. */
  79857. matricesIndices: Nullable<FloatArray>;
  79858. /**
  79859. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  79860. */
  79861. matricesWeights: Nullable<FloatArray>;
  79862. /**
  79863. * An array extending the number of possible indices
  79864. */
  79865. matricesIndicesExtra: Nullable<FloatArray>;
  79866. /**
  79867. * An array extending the number of possible weights when the number of indices is extended
  79868. */
  79869. matricesWeightsExtra: Nullable<FloatArray>;
  79870. /**
  79871. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  79872. */
  79873. indices: Nullable<IndicesArray>;
  79874. /**
  79875. * Uses the passed data array to set the set the values for the specified kind of data
  79876. * @param data a linear array of floating numbers
  79877. * @param kind the type of data that is being set, eg positions, colors etc
  79878. */
  79879. set(data: FloatArray, kind: string): void;
  79880. /**
  79881. * Associates the vertexData to the passed Mesh.
  79882. * Sets it as updatable or not (default `false`)
  79883. * @param mesh the mesh the vertexData is applied to
  79884. * @param updatable when used and having the value true allows new data to update the vertexData
  79885. * @returns the VertexData
  79886. */
  79887. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  79888. /**
  79889. * Associates the vertexData to the passed Geometry.
  79890. * Sets it as updatable or not (default `false`)
  79891. * @param geometry the geometry the vertexData is applied to
  79892. * @param updatable when used and having the value true allows new data to update the vertexData
  79893. * @returns VertexData
  79894. */
  79895. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  79896. /**
  79897. * Updates the associated mesh
  79898. * @param mesh the mesh to be updated
  79899. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  79900. * @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
  79901. * @returns VertexData
  79902. */
  79903. updateMesh(mesh: Mesh): VertexData;
  79904. /**
  79905. * Updates the associated geometry
  79906. * @param geometry the geometry to be updated
  79907. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  79908. * @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
  79909. * @returns VertexData.
  79910. */
  79911. updateGeometry(geometry: Geometry): VertexData;
  79912. private _applyTo;
  79913. private _update;
  79914. /**
  79915. * Transforms each position and each normal of the vertexData according to the passed Matrix
  79916. * @param matrix the transforming matrix
  79917. * @returns the VertexData
  79918. */
  79919. transform(matrix: Matrix): VertexData;
  79920. /**
  79921. * Merges the passed VertexData into the current one
  79922. * @param other the VertexData to be merged into the current one
  79923. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  79924. * @returns the modified VertexData
  79925. */
  79926. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  79927. private _mergeElement;
  79928. private _validate;
  79929. /**
  79930. * Serializes the VertexData
  79931. * @returns a serialized object
  79932. */
  79933. serialize(): any;
  79934. /**
  79935. * Extracts the vertexData from a mesh
  79936. * @param mesh the mesh from which to extract the VertexData
  79937. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  79938. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  79939. * @returns the object VertexData associated to the passed mesh
  79940. */
  79941. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  79942. /**
  79943. * Extracts the vertexData from the geometry
  79944. * @param geometry the geometry from which to extract the VertexData
  79945. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  79946. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  79947. * @returns the object VertexData associated to the passed mesh
  79948. */
  79949. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  79950. private static _ExtractFrom;
  79951. /**
  79952. * Creates the VertexData for a Ribbon
  79953. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  79954. * * pathArray array of paths, each of which an array of successive Vector3
  79955. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  79956. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  79957. * * 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
  79958. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  79959. * * 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)
  79960. * * 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)
  79961. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  79962. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  79963. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  79964. * @returns the VertexData of the ribbon
  79965. */
  79966. static CreateRibbon(options: {
  79967. pathArray: Vector3[][];
  79968. closeArray?: boolean;
  79969. closePath?: boolean;
  79970. offset?: number;
  79971. sideOrientation?: number;
  79972. frontUVs?: Vector4;
  79973. backUVs?: Vector4;
  79974. invertUV?: boolean;
  79975. uvs?: Vector2[];
  79976. colors?: Color4[];
  79977. }): VertexData;
  79978. /**
  79979. * Creates the VertexData for a box
  79980. * @param options an object used to set the following optional parameters for the box, required but can be empty
  79981. * * size sets the width, height and depth of the box to the value of size, optional default 1
  79982. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  79983. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  79984. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  79985. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  79986. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  79987. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  79988. * * 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)
  79989. * * 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)
  79990. * @returns the VertexData of the box
  79991. */
  79992. static CreateBox(options: {
  79993. size?: number;
  79994. width?: number;
  79995. height?: number;
  79996. depth?: number;
  79997. faceUV?: Vector4[];
  79998. faceColors?: Color4[];
  79999. sideOrientation?: number;
  80000. frontUVs?: Vector4;
  80001. backUVs?: Vector4;
  80002. }): VertexData;
  80003. /**
  80004. * Creates the VertexData for an ellipsoid, defaults to a sphere
  80005. * @param options an object used to set the following optional parameters for the box, required but can be empty
  80006. * * segments sets the number of horizontal strips optional, default 32
  80007. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  80008. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  80009. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  80010. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  80011. * * 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
  80012. * * 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
  80013. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  80014. * * 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)
  80015. * * 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)
  80016. * @returns the VertexData of the ellipsoid
  80017. */
  80018. static CreateSphere(options: {
  80019. segments?: number;
  80020. diameter?: number;
  80021. diameterX?: number;
  80022. diameterY?: number;
  80023. diameterZ?: number;
  80024. arc?: number;
  80025. slice?: number;
  80026. sideOrientation?: number;
  80027. frontUVs?: Vector4;
  80028. backUVs?: Vector4;
  80029. }): VertexData;
  80030. /**
  80031. * Creates the VertexData for a cylinder, cone or prism
  80032. * @param options an object used to set the following optional parameters for the box, required but can be empty
  80033. * * height sets the height (y direction) of the cylinder, optional, default 2
  80034. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  80035. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  80036. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  80037. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  80038. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  80039. * * 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
  80040. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  80041. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  80042. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  80043. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  80044. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  80045. * * 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)
  80046. * * 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)
  80047. * @returns the VertexData of the cylinder, cone or prism
  80048. */
  80049. static CreateCylinder(options: {
  80050. height?: number;
  80051. diameterTop?: number;
  80052. diameterBottom?: number;
  80053. diameter?: number;
  80054. tessellation?: number;
  80055. subdivisions?: number;
  80056. arc?: number;
  80057. faceColors?: Color4[];
  80058. faceUV?: Vector4[];
  80059. hasRings?: boolean;
  80060. enclose?: boolean;
  80061. sideOrientation?: number;
  80062. frontUVs?: Vector4;
  80063. backUVs?: Vector4;
  80064. }): VertexData;
  80065. /**
  80066. * Creates the VertexData for a torus
  80067. * @param options an object used to set the following optional parameters for the box, required but can be empty
  80068. * * diameter the diameter of the torus, optional default 1
  80069. * * thickness the diameter of the tube forming the torus, optional default 0.5
  80070. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  80071. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  80072. * * 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)
  80073. * * 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)
  80074. * @returns the VertexData of the torus
  80075. */
  80076. static CreateTorus(options: {
  80077. diameter?: number;
  80078. thickness?: number;
  80079. tessellation?: number;
  80080. sideOrientation?: number;
  80081. frontUVs?: Vector4;
  80082. backUVs?: Vector4;
  80083. }): VertexData;
  80084. /**
  80085. * Creates the VertexData of the LineSystem
  80086. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  80087. * - lines an array of lines, each line being an array of successive Vector3
  80088. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  80089. * @returns the VertexData of the LineSystem
  80090. */
  80091. static CreateLineSystem(options: {
  80092. lines: Vector3[][];
  80093. colors?: Nullable<Color4[][]>;
  80094. }): VertexData;
  80095. /**
  80096. * Create the VertexData for a DashedLines
  80097. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  80098. * - points an array successive Vector3
  80099. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  80100. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  80101. * - dashNb the intended total number of dashes, optional, default 200
  80102. * @returns the VertexData for the DashedLines
  80103. */
  80104. static CreateDashedLines(options: {
  80105. points: Vector3[];
  80106. dashSize?: number;
  80107. gapSize?: number;
  80108. dashNb?: number;
  80109. }): VertexData;
  80110. /**
  80111. * Creates the VertexData for a Ground
  80112. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  80113. * - width the width (x direction) of the ground, optional, default 1
  80114. * - height the height (z direction) of the ground, optional, default 1
  80115. * - subdivisions the number of subdivisions per side, optional, default 1
  80116. * @returns the VertexData of the Ground
  80117. */
  80118. static CreateGround(options: {
  80119. width?: number;
  80120. height?: number;
  80121. subdivisions?: number;
  80122. subdivisionsX?: number;
  80123. subdivisionsY?: number;
  80124. }): VertexData;
  80125. /**
  80126. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  80127. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  80128. * * xmin the ground minimum X coordinate, optional, default -1
  80129. * * zmin the ground minimum Z coordinate, optional, default -1
  80130. * * xmax the ground maximum X coordinate, optional, default 1
  80131. * * zmax the ground maximum Z coordinate, optional, default 1
  80132. * * 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}
  80133. * * 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}
  80134. * @returns the VertexData of the TiledGround
  80135. */
  80136. static CreateTiledGround(options: {
  80137. xmin: number;
  80138. zmin: number;
  80139. xmax: number;
  80140. zmax: number;
  80141. subdivisions?: {
  80142. w: number;
  80143. h: number;
  80144. };
  80145. precision?: {
  80146. w: number;
  80147. h: number;
  80148. };
  80149. }): VertexData;
  80150. /**
  80151. * Creates the VertexData of the Ground designed from a heightmap
  80152. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  80153. * * width the width (x direction) of the ground
  80154. * * height the height (z direction) of the ground
  80155. * * subdivisions the number of subdivisions per side
  80156. * * minHeight the minimum altitude on the ground, optional, default 0
  80157. * * maxHeight the maximum altitude on the ground, optional default 1
  80158. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  80159. * * buffer the array holding the image color data
  80160. * * bufferWidth the width of image
  80161. * * bufferHeight the height of image
  80162. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  80163. * @returns the VertexData of the Ground designed from a heightmap
  80164. */
  80165. static CreateGroundFromHeightMap(options: {
  80166. width: number;
  80167. height: number;
  80168. subdivisions: number;
  80169. minHeight: number;
  80170. maxHeight: number;
  80171. colorFilter: Color3;
  80172. buffer: Uint8Array;
  80173. bufferWidth: number;
  80174. bufferHeight: number;
  80175. alphaFilter: number;
  80176. }): VertexData;
  80177. /**
  80178. * Creates the VertexData for a Plane
  80179. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  80180. * * size sets the width and height of the plane to the value of size, optional default 1
  80181. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  80182. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  80183. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  80184. * * 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)
  80185. * * 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)
  80186. * @returns the VertexData of the box
  80187. */
  80188. static CreatePlane(options: {
  80189. size?: number;
  80190. width?: number;
  80191. height?: number;
  80192. sideOrientation?: number;
  80193. frontUVs?: Vector4;
  80194. backUVs?: Vector4;
  80195. }): VertexData;
  80196. /**
  80197. * Creates the VertexData of the Disc or regular Polygon
  80198. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  80199. * * radius the radius of the disc, optional default 0.5
  80200. * * tessellation the number of polygon sides, optional, default 64
  80201. * * 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
  80202. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  80203. * * 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)
  80204. * * 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)
  80205. * @returns the VertexData of the box
  80206. */
  80207. static CreateDisc(options: {
  80208. radius?: number;
  80209. tessellation?: number;
  80210. arc?: number;
  80211. sideOrientation?: number;
  80212. frontUVs?: Vector4;
  80213. backUVs?: Vector4;
  80214. }): VertexData;
  80215. /**
  80216. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  80217. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  80218. * @param polygon a mesh built from polygonTriangulation.build()
  80219. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  80220. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  80221. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  80222. * @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)
  80223. * @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)
  80224. * @returns the VertexData of the Polygon
  80225. */
  80226. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  80227. /**
  80228. * Creates the VertexData of the IcoSphere
  80229. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  80230. * * radius the radius of the IcoSphere, optional default 1
  80231. * * radiusX allows stretching in the x direction, optional, default radius
  80232. * * radiusY allows stretching in the y direction, optional, default radius
  80233. * * radiusZ allows stretching in the z direction, optional, default radius
  80234. * * flat when true creates a flat shaded mesh, optional, default true
  80235. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  80236. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  80237. * * 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)
  80238. * * 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)
  80239. * @returns the VertexData of the IcoSphere
  80240. */
  80241. static CreateIcoSphere(options: {
  80242. radius?: number;
  80243. radiusX?: number;
  80244. radiusY?: number;
  80245. radiusZ?: number;
  80246. flat?: boolean;
  80247. subdivisions?: number;
  80248. sideOrientation?: number;
  80249. frontUVs?: Vector4;
  80250. backUVs?: Vector4;
  80251. }): VertexData;
  80252. /**
  80253. * Creates the VertexData for a Polyhedron
  80254. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  80255. * * type provided types are:
  80256. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  80257. * * 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)
  80258. * * size the size of the IcoSphere, optional default 1
  80259. * * sizeX allows stretching in the x direction, optional, default size
  80260. * * sizeY allows stretching in the y direction, optional, default size
  80261. * * sizeZ allows stretching in the z direction, optional, default size
  80262. * * 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
  80263. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  80264. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  80265. * * flat when true creates a flat shaded mesh, optional, default true
  80266. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  80267. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  80268. * * 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)
  80269. * * 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)
  80270. * @returns the VertexData of the Polyhedron
  80271. */
  80272. static CreatePolyhedron(options: {
  80273. type?: number;
  80274. size?: number;
  80275. sizeX?: number;
  80276. sizeY?: number;
  80277. sizeZ?: number;
  80278. custom?: any;
  80279. faceUV?: Vector4[];
  80280. faceColors?: Color4[];
  80281. flat?: boolean;
  80282. sideOrientation?: number;
  80283. frontUVs?: Vector4;
  80284. backUVs?: Vector4;
  80285. }): VertexData;
  80286. /**
  80287. * Creates the VertexData for a TorusKnot
  80288. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  80289. * * radius the radius of the torus knot, optional, default 2
  80290. * * tube the thickness of the tube, optional, default 0.5
  80291. * * radialSegments the number of sides on each tube segments, optional, default 32
  80292. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  80293. * * p the number of windings around the z axis, optional, default 2
  80294. * * q the number of windings around the x axis, optional, default 3
  80295. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  80296. * * 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)
  80297. * * 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)
  80298. * @returns the VertexData of the Torus Knot
  80299. */
  80300. static CreateTorusKnot(options: {
  80301. radius?: number;
  80302. tube?: number;
  80303. radialSegments?: number;
  80304. tubularSegments?: number;
  80305. p?: number;
  80306. q?: number;
  80307. sideOrientation?: number;
  80308. frontUVs?: Vector4;
  80309. backUVs?: Vector4;
  80310. }): VertexData;
  80311. /**
  80312. * Compute normals for given positions and indices
  80313. * @param positions an array of vertex positions, [...., x, y, z, ......]
  80314. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  80315. * @param normals an array of vertex normals, [...., x, y, z, ......]
  80316. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  80317. * * facetNormals : optional array of facet normals (vector3)
  80318. * * facetPositions : optional array of facet positions (vector3)
  80319. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  80320. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  80321. * * bInfo : optional bounding info, required for facetPartitioning computation
  80322. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  80323. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  80324. * * useRightHandedSystem: optional boolean to for right handed system computation
  80325. * * depthSort : optional boolean to enable the facet depth sort computation
  80326. * * distanceTo : optional Vector3 to compute the facet depth from this location
  80327. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  80328. */
  80329. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  80330. facetNormals?: any;
  80331. facetPositions?: any;
  80332. facetPartitioning?: any;
  80333. ratio?: number;
  80334. bInfo?: any;
  80335. bbSize?: Vector3;
  80336. subDiv?: any;
  80337. useRightHandedSystem?: boolean;
  80338. depthSort?: boolean;
  80339. distanceTo?: Vector3;
  80340. depthSortedFacets?: any;
  80341. }): void;
  80342. /** @hidden */
  80343. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  80344. /**
  80345. * Applies VertexData created from the imported parameters to the geometry
  80346. * @param parsedVertexData the parsed data from an imported file
  80347. * @param geometry the geometry to apply the VertexData to
  80348. */
  80349. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  80350. }
  80351. }
  80352. declare module BABYLON {
  80353. /**
  80354. * Class containing static functions to help procedurally build meshes
  80355. */
  80356. export class DiscBuilder {
  80357. /**
  80358. * Creates a plane polygonal mesh. By default, this is a disc
  80359. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  80360. * * 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
  80361. * * 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
  80362. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  80363. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  80364. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  80365. * @param name defines the name of the mesh
  80366. * @param options defines the options used to create the mesh
  80367. * @param scene defines the hosting scene
  80368. * @returns the plane polygonal mesh
  80369. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  80370. */
  80371. static CreateDisc(name: string, options: {
  80372. radius?: number;
  80373. tessellation?: number;
  80374. arc?: number;
  80375. updatable?: boolean;
  80376. sideOrientation?: number;
  80377. frontUVs?: Vector4;
  80378. backUVs?: Vector4;
  80379. }, scene?: Nullable<Scene>): Mesh;
  80380. }
  80381. }
  80382. declare module BABYLON {
  80383. /**
  80384. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  80385. *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.
  80386. * The SPS is also a particle system. It provides some methods to manage the particles.
  80387. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  80388. *
  80389. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  80390. */
  80391. export class SolidParticleSystem implements IDisposable {
  80392. /**
  80393. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  80394. * Example : var p = SPS.particles[i];
  80395. */
  80396. particles: SolidParticle[];
  80397. /**
  80398. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  80399. */
  80400. nbParticles: number;
  80401. /**
  80402. * If the particles must ever face the camera (default false). Useful for planar particles.
  80403. */
  80404. billboard: boolean;
  80405. /**
  80406. * Recompute normals when adding a shape
  80407. */
  80408. recomputeNormals: boolean;
  80409. /**
  80410. * This a counter ofr your own usage. It's not set by any SPS functions.
  80411. */
  80412. counter: number;
  80413. /**
  80414. * The SPS name. This name is also given to the underlying mesh.
  80415. */
  80416. name: string;
  80417. /**
  80418. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  80419. */
  80420. mesh: Mesh;
  80421. /**
  80422. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  80423. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  80424. */
  80425. vars: any;
  80426. /**
  80427. * This array is populated when the SPS is set as 'pickable'.
  80428. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  80429. * Each element of this array is an object `{idx: int, faceId: int}`.
  80430. * `idx` is the picked particle index in the `SPS.particles` array
  80431. * `faceId` is the picked face index counted within this particle.
  80432. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  80433. */
  80434. pickedParticles: {
  80435. idx: number;
  80436. faceId: number;
  80437. }[];
  80438. /**
  80439. * This array is populated when `enableDepthSort` is set to true.
  80440. * Each element of this array is an instance of the class DepthSortedParticle.
  80441. */
  80442. depthSortedParticles: DepthSortedParticle[];
  80443. /**
  80444. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  80445. * @hidden
  80446. */
  80447. _bSphereOnly: boolean;
  80448. /**
  80449. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  80450. * @hidden
  80451. */
  80452. _bSphereRadiusFactor: number;
  80453. private _scene;
  80454. private _positions;
  80455. private _indices;
  80456. private _normals;
  80457. private _colors;
  80458. private _uvs;
  80459. private _indices32;
  80460. private _positions32;
  80461. private _normals32;
  80462. private _fixedNormal32;
  80463. private _colors32;
  80464. private _uvs32;
  80465. private _index;
  80466. private _updatable;
  80467. private _pickable;
  80468. private _isVisibilityBoxLocked;
  80469. private _alwaysVisible;
  80470. private _depthSort;
  80471. private _shapeCounter;
  80472. private _copy;
  80473. private _color;
  80474. private _computeParticleColor;
  80475. private _computeParticleTexture;
  80476. private _computeParticleRotation;
  80477. private _computeParticleVertex;
  80478. private _computeBoundingBox;
  80479. private _depthSortParticles;
  80480. private _camera;
  80481. private _mustUnrotateFixedNormals;
  80482. private _particlesIntersect;
  80483. private _needs32Bits;
  80484. /**
  80485. * Creates a SPS (Solid Particle System) object.
  80486. * @param name (String) is the SPS name, this will be the underlying mesh name.
  80487. * @param scene (Scene) is the scene in which the SPS is added.
  80488. * @param options defines the options of the sps e.g.
  80489. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  80490. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  80491. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  80492. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  80493. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  80494. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  80495. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  80496. */
  80497. constructor(name: string, scene: Scene, options?: {
  80498. updatable?: boolean;
  80499. isPickable?: boolean;
  80500. enableDepthSort?: boolean;
  80501. particleIntersection?: boolean;
  80502. boundingSphereOnly?: boolean;
  80503. bSphereRadiusFactor?: number;
  80504. });
  80505. /**
  80506. * Builds the SPS underlying mesh. Returns a standard Mesh.
  80507. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  80508. * @returns the created mesh
  80509. */
  80510. buildMesh(): Mesh;
  80511. /**
  80512. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  80513. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  80514. * Thus the particles generated from `digest()` have their property `position` set yet.
  80515. * @param mesh ( Mesh ) is the mesh to be digested
  80516. * @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
  80517. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  80518. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  80519. * @returns the current SPS
  80520. */
  80521. digest(mesh: Mesh, options?: {
  80522. facetNb?: number;
  80523. number?: number;
  80524. delta?: number;
  80525. }): SolidParticleSystem;
  80526. private _unrotateFixedNormals;
  80527. private _resetCopy;
  80528. private _meshBuilder;
  80529. private _posToShape;
  80530. private _uvsToShapeUV;
  80531. private _addParticle;
  80532. /**
  80533. * Adds some particles to the SPS from the model shape. Returns the shape id.
  80534. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  80535. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  80536. * @param nb (positive integer) the number of particles to be created from this model
  80537. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  80538. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  80539. * @returns the number of shapes in the system
  80540. */
  80541. addShape(mesh: Mesh, nb: number, options?: {
  80542. positionFunction?: any;
  80543. vertexFunction?: any;
  80544. }): number;
  80545. private _rebuildParticle;
  80546. /**
  80547. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  80548. * @returns the SPS.
  80549. */
  80550. rebuildMesh(): SolidParticleSystem;
  80551. /**
  80552. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  80553. * This method calls `updateParticle()` for each particle of the SPS.
  80554. * For an animated SPS, it is usually called within the render loop.
  80555. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  80556. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  80557. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  80558. * @returns the SPS.
  80559. */
  80560. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  80561. /**
  80562. * Disposes the SPS.
  80563. */
  80564. dispose(): void;
  80565. /**
  80566. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  80567. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  80568. * @returns the SPS.
  80569. */
  80570. refreshVisibleSize(): SolidParticleSystem;
  80571. /**
  80572. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  80573. * @param size the size (float) of the visibility box
  80574. * note : this doesn't lock the SPS mesh bounding box.
  80575. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  80576. */
  80577. setVisibilityBox(size: number): void;
  80578. /**
  80579. * Gets whether the SPS as always visible or not
  80580. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  80581. */
  80582. /**
  80583. * Sets the SPS as always visible or not
  80584. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  80585. */
  80586. isAlwaysVisible: boolean;
  80587. /**
  80588. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  80589. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  80590. */
  80591. /**
  80592. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  80593. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  80594. */
  80595. isVisibilityBoxLocked: boolean;
  80596. /**
  80597. * Tells to `setParticles()` to compute the particle rotations or not.
  80598. * Default value : true. The SPS is faster when it's set to false.
  80599. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  80600. */
  80601. /**
  80602. * Gets if `setParticles()` computes the particle rotations or not.
  80603. * Default value : true. The SPS is faster when it's set to false.
  80604. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  80605. */
  80606. computeParticleRotation: boolean;
  80607. /**
  80608. * Tells to `setParticles()` to compute the particle colors or not.
  80609. * Default value : true. The SPS is faster when it's set to false.
  80610. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  80611. */
  80612. /**
  80613. * Gets if `setParticles()` computes the particle colors or not.
  80614. * Default value : true. The SPS is faster when it's set to false.
  80615. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  80616. */
  80617. computeParticleColor: boolean;
  80618. /**
  80619. * Gets if `setParticles()` computes the particle textures or not.
  80620. * Default value : true. The SPS is faster when it's set to false.
  80621. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  80622. */
  80623. computeParticleTexture: boolean;
  80624. /**
  80625. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  80626. * Default value : false. The SPS is faster when it's set to false.
  80627. * Note : the particle custom vertex positions aren't stored values.
  80628. */
  80629. /**
  80630. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  80631. * Default value : false. The SPS is faster when it's set to false.
  80632. * Note : the particle custom vertex positions aren't stored values.
  80633. */
  80634. computeParticleVertex: boolean;
  80635. /**
  80636. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  80637. */
  80638. /**
  80639. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  80640. */
  80641. computeBoundingBox: boolean;
  80642. /**
  80643. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  80644. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  80645. * Default : `true`
  80646. */
  80647. /**
  80648. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  80649. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  80650. * Default : `true`
  80651. */
  80652. depthSortParticles: boolean;
  80653. /**
  80654. * This function does nothing. It may be overwritten to set all the particle first values.
  80655. * The SPS doesn't call this function, you may have to call it by your own.
  80656. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  80657. */
  80658. initParticles(): void;
  80659. /**
  80660. * This function does nothing. It may be overwritten to recycle a particle.
  80661. * The SPS doesn't call this function, you may have to call it by your own.
  80662. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  80663. * @param particle The particle to recycle
  80664. * @returns the recycled particle
  80665. */
  80666. recycleParticle(particle: SolidParticle): SolidParticle;
  80667. /**
  80668. * Updates a particle : this function should be overwritten by the user.
  80669. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  80670. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  80671. * @example : just set a particle position or velocity and recycle conditions
  80672. * @param particle The particle to update
  80673. * @returns the updated particle
  80674. */
  80675. updateParticle(particle: SolidParticle): SolidParticle;
  80676. /**
  80677. * Updates a vertex of a particle : it can be overwritten by the user.
  80678. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  80679. * @param particle the current particle
  80680. * @param vertex the current index of the current particle
  80681. * @param pt the index of the current vertex in the particle shape
  80682. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  80683. * @example : just set a vertex particle position
  80684. * @returns the updated vertex
  80685. */
  80686. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  80687. /**
  80688. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  80689. * This does nothing and may be overwritten by the user.
  80690. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  80691. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  80692. * @param update the boolean update value actually passed to setParticles()
  80693. */
  80694. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  80695. /**
  80696. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  80697. * This will be passed three parameters.
  80698. * This does nothing and may be overwritten by the user.
  80699. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  80700. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  80701. * @param update the boolean update value actually passed to setParticles()
  80702. */
  80703. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  80704. }
  80705. }
  80706. declare module BABYLON {
  80707. /**
  80708. * Represents one particle of a solid particle system.
  80709. */
  80710. export class SolidParticle {
  80711. /**
  80712. * particle global index
  80713. */
  80714. idx: number;
  80715. /**
  80716. * The color of the particle
  80717. */
  80718. color: Nullable<Color4>;
  80719. /**
  80720. * The world space position of the particle.
  80721. */
  80722. position: Vector3;
  80723. /**
  80724. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  80725. */
  80726. rotation: Vector3;
  80727. /**
  80728. * The world space rotation quaternion of the particle.
  80729. */
  80730. rotationQuaternion: Nullable<Quaternion>;
  80731. /**
  80732. * The scaling of the particle.
  80733. */
  80734. scaling: Vector3;
  80735. /**
  80736. * The uvs of the particle.
  80737. */
  80738. uvs: Vector4;
  80739. /**
  80740. * The current speed of the particle.
  80741. */
  80742. velocity: Vector3;
  80743. /**
  80744. * The pivot point in the particle local space.
  80745. */
  80746. pivot: Vector3;
  80747. /**
  80748. * Must the particle be translated from its pivot point in its local space ?
  80749. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  80750. * Default : false
  80751. */
  80752. translateFromPivot: boolean;
  80753. /**
  80754. * Is the particle active or not ?
  80755. */
  80756. alive: boolean;
  80757. /**
  80758. * Is the particle visible or not ?
  80759. */
  80760. isVisible: boolean;
  80761. /**
  80762. * Index of this particle in the global "positions" array (Internal use)
  80763. * @hidden
  80764. */
  80765. _pos: number;
  80766. /**
  80767. * @hidden Index of this particle in the global "indices" array (Internal use)
  80768. */
  80769. _ind: number;
  80770. /**
  80771. * @hidden ModelShape of this particle (Internal use)
  80772. */
  80773. _model: ModelShape;
  80774. /**
  80775. * ModelShape id of this particle
  80776. */
  80777. shapeId: number;
  80778. /**
  80779. * Index of the particle in its shape id (Internal use)
  80780. */
  80781. idxInShape: number;
  80782. /**
  80783. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  80784. */
  80785. _modelBoundingInfo: BoundingInfo;
  80786. /**
  80787. * @hidden Particle BoundingInfo object (Internal use)
  80788. */
  80789. _boundingInfo: BoundingInfo;
  80790. /**
  80791. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  80792. */
  80793. _sps: SolidParticleSystem;
  80794. /**
  80795. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  80796. */
  80797. _stillInvisible: boolean;
  80798. /**
  80799. * @hidden Last computed particle rotation matrix
  80800. */
  80801. _rotationMatrix: number[];
  80802. /**
  80803. * Parent particle Id, if any.
  80804. * Default null.
  80805. */
  80806. parentId: Nullable<number>;
  80807. /**
  80808. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  80809. * The possible values are :
  80810. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  80811. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  80812. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  80813. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  80814. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  80815. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  80816. * */
  80817. cullingStrategy: number;
  80818. /**
  80819. * @hidden Internal global position in the SPS.
  80820. */
  80821. _globalPosition: Vector3;
  80822. /**
  80823. * Creates a Solid Particle object.
  80824. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  80825. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  80826. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  80827. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  80828. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  80829. * @param shapeId (integer) is the model shape identifier in the SPS.
  80830. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  80831. * @param sps defines the sps it is associated to
  80832. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  80833. */
  80834. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  80835. /**
  80836. * Legacy support, changed scale to scaling
  80837. */
  80838. /**
  80839. * Legacy support, changed scale to scaling
  80840. */
  80841. scale: Vector3;
  80842. /**
  80843. * Legacy support, changed quaternion to rotationQuaternion
  80844. */
  80845. /**
  80846. * Legacy support, changed quaternion to rotationQuaternion
  80847. */
  80848. quaternion: Nullable<Quaternion>;
  80849. /**
  80850. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  80851. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  80852. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  80853. * @returns true if it intersects
  80854. */
  80855. intersectsMesh(target: Mesh | SolidParticle): boolean;
  80856. /**
  80857. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  80858. * A particle is in the frustum if its bounding box intersects the frustum
  80859. * @param frustumPlanes defines the frustum to test
  80860. * @returns true if the particle is in the frustum planes
  80861. */
  80862. isInFrustum(frustumPlanes: Plane[]): boolean;
  80863. /**
  80864. * get the rotation matrix of the particle
  80865. * @hidden
  80866. */
  80867. getRotationMatrix(m: Matrix): void;
  80868. }
  80869. /**
  80870. * Represents the shape of the model used by one particle of a solid particle system.
  80871. * SPS internal tool, don't use it manually.
  80872. */
  80873. export class ModelShape {
  80874. /**
  80875. * The shape id
  80876. * @hidden
  80877. */
  80878. shapeID: number;
  80879. /**
  80880. * flat array of model positions (internal use)
  80881. * @hidden
  80882. */
  80883. _shape: Vector3[];
  80884. /**
  80885. * flat array of model UVs (internal use)
  80886. * @hidden
  80887. */
  80888. _shapeUV: number[];
  80889. /**
  80890. * length of the shape in the model indices array (internal use)
  80891. * @hidden
  80892. */
  80893. _indicesLength: number;
  80894. /**
  80895. * Custom position function (internal use)
  80896. * @hidden
  80897. */
  80898. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  80899. /**
  80900. * Custom vertex function (internal use)
  80901. * @hidden
  80902. */
  80903. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  80904. /**
  80905. * 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.
  80906. * SPS internal tool, don't use it manually.
  80907. * @hidden
  80908. */
  80909. 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>);
  80910. }
  80911. /**
  80912. * Represents a Depth Sorted Particle in the solid particle system.
  80913. */
  80914. export class DepthSortedParticle {
  80915. /**
  80916. * Index of the particle in the "indices" array
  80917. */
  80918. ind: number;
  80919. /**
  80920. * Length of the particle shape in the "indices" array
  80921. */
  80922. indicesLength: number;
  80923. /**
  80924. * Squared distance from the particle to the camera
  80925. */
  80926. sqDistance: number;
  80927. }
  80928. }
  80929. declare module BABYLON {
  80930. /**
  80931. * Class used to store all common mesh properties
  80932. */
  80933. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  80934. /** No occlusion */
  80935. static OCCLUSION_TYPE_NONE: number;
  80936. /** Occlusion set to optimisitic */
  80937. static OCCLUSION_TYPE_OPTIMISTIC: number;
  80938. /** Occlusion set to strict */
  80939. static OCCLUSION_TYPE_STRICT: number;
  80940. /** Use an accurante occlusion algorithm */
  80941. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  80942. /** Use a conservative occlusion algorithm */
  80943. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  80944. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  80945. * Test order :
  80946. * Is the bounding sphere outside the frustum ?
  80947. * If not, are the bounding box vertices outside the frustum ?
  80948. * It not, then the cullable object is in the frustum.
  80949. */
  80950. static readonly CULLINGSTRATEGY_STANDARD: number;
  80951. /** Culling strategy : Bounding Sphere Only.
  80952. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  80953. * It's also less accurate than the standard because some not visible objects can still be selected.
  80954. * Test : is the bounding sphere outside the frustum ?
  80955. * If not, then the cullable object is in the frustum.
  80956. */
  80957. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  80958. /** Culling strategy : Optimistic Inclusion.
  80959. * This in an inclusion test first, then the standard exclusion test.
  80960. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  80961. * 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.
  80962. * Anyway, it's as accurate as the standard strategy.
  80963. * Test :
  80964. * Is the cullable object bounding sphere center in the frustum ?
  80965. * If not, apply the default culling strategy.
  80966. */
  80967. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  80968. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  80969. * This in an inclusion test first, then the bounding sphere only exclusion test.
  80970. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  80971. * 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.
  80972. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  80973. * Test :
  80974. * Is the cullable object bounding sphere center in the frustum ?
  80975. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  80976. */
  80977. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  80978. /**
  80979. * No billboard
  80980. */
  80981. static readonly BILLBOARDMODE_NONE: number;
  80982. /** Billboard on X axis */
  80983. static readonly BILLBOARDMODE_X: number;
  80984. /** Billboard on Y axis */
  80985. static readonly BILLBOARDMODE_Y: number;
  80986. /** Billboard on Z axis */
  80987. static readonly BILLBOARDMODE_Z: number;
  80988. /** Billboard on all axes */
  80989. static readonly BILLBOARDMODE_ALL: number;
  80990. private _facetData;
  80991. /**
  80992. * The culling strategy to use to check whether the mesh must be rendered or not.
  80993. * This value can be changed at any time and will be used on the next render mesh selection.
  80994. * The possible values are :
  80995. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  80996. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  80997. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  80998. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  80999. * Please read each static variable documentation to get details about the culling process.
  81000. * */
  81001. cullingStrategy: number;
  81002. /**
  81003. * Gets the number of facets in the mesh
  81004. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  81005. */
  81006. readonly facetNb: number;
  81007. /**
  81008. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  81009. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  81010. */
  81011. partitioningSubdivisions: number;
  81012. /**
  81013. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  81014. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  81015. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  81016. */
  81017. partitioningBBoxRatio: number;
  81018. /**
  81019. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  81020. * Works only for updatable meshes.
  81021. * Doesn't work with multi-materials
  81022. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  81023. */
  81024. mustDepthSortFacets: boolean;
  81025. /**
  81026. * The location (Vector3) where the facet depth sort must be computed from.
  81027. * By default, the active camera position.
  81028. * Used only when facet depth sort is enabled
  81029. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  81030. */
  81031. facetDepthSortFrom: Vector3;
  81032. /**
  81033. * gets a boolean indicating if facetData is enabled
  81034. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  81035. */
  81036. readonly isFacetDataEnabled: boolean;
  81037. /** @hidden */
  81038. _updateNonUniformScalingState(value: boolean): boolean;
  81039. /**
  81040. * An event triggered when this mesh collides with another one
  81041. */
  81042. onCollideObservable: Observable<AbstractMesh>;
  81043. private _onCollideObserver;
  81044. /** Set a function to call when this mesh collides with another one */
  81045. onCollide: () => void;
  81046. /**
  81047. * An event triggered when the collision's position changes
  81048. */
  81049. onCollisionPositionChangeObservable: Observable<Vector3>;
  81050. private _onCollisionPositionChangeObserver;
  81051. /** Set a function to call when the collision's position changes */
  81052. onCollisionPositionChange: () => void;
  81053. /**
  81054. * An event triggered when material is changed
  81055. */
  81056. onMaterialChangedObservable: Observable<AbstractMesh>;
  81057. /**
  81058. * Gets or sets the orientation for POV movement & rotation
  81059. */
  81060. definedFacingForward: boolean;
  81061. /** @hidden */
  81062. _occlusionQuery: Nullable<WebGLQuery>;
  81063. private _visibility;
  81064. /**
  81065. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  81066. */
  81067. /**
  81068. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  81069. */
  81070. visibility: number;
  81071. /** Gets or sets the alpha index used to sort transparent meshes
  81072. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  81073. */
  81074. alphaIndex: number;
  81075. /**
  81076. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  81077. */
  81078. isVisible: boolean;
  81079. /**
  81080. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  81081. */
  81082. isPickable: boolean;
  81083. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  81084. showSubMeshesBoundingBox: boolean;
  81085. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  81086. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  81087. */
  81088. isBlocker: boolean;
  81089. /**
  81090. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  81091. */
  81092. enablePointerMoveEvents: boolean;
  81093. /**
  81094. * Specifies the rendering group id for this mesh (0 by default)
  81095. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  81096. */
  81097. renderingGroupId: number;
  81098. private _material;
  81099. /** Gets or sets current material */
  81100. material: Nullable<Material>;
  81101. private _receiveShadows;
  81102. /**
  81103. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  81104. * @see http://doc.babylonjs.com/babylon101/shadows
  81105. */
  81106. receiveShadows: boolean;
  81107. /** Defines color to use when rendering outline */
  81108. outlineColor: Color3;
  81109. /** Define width to use when rendering outline */
  81110. outlineWidth: number;
  81111. /** Defines color to use when rendering overlay */
  81112. overlayColor: Color3;
  81113. /** Defines alpha to use when rendering overlay */
  81114. overlayAlpha: number;
  81115. private _hasVertexAlpha;
  81116. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  81117. hasVertexAlpha: boolean;
  81118. private _useVertexColors;
  81119. /** 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) */
  81120. useVertexColors: boolean;
  81121. private _computeBonesUsingShaders;
  81122. /**
  81123. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  81124. */
  81125. computeBonesUsingShaders: boolean;
  81126. private _numBoneInfluencers;
  81127. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  81128. numBoneInfluencers: number;
  81129. private _applyFog;
  81130. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  81131. applyFog: boolean;
  81132. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  81133. useOctreeForRenderingSelection: boolean;
  81134. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  81135. useOctreeForPicking: boolean;
  81136. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  81137. useOctreeForCollisions: boolean;
  81138. private _layerMask;
  81139. /**
  81140. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  81141. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  81142. */
  81143. layerMask: number;
  81144. /**
  81145. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  81146. */
  81147. alwaysSelectAsActiveMesh: boolean;
  81148. /**
  81149. * Gets or sets the current action manager
  81150. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  81151. */
  81152. actionManager: Nullable<AbstractActionManager>;
  81153. private _checkCollisions;
  81154. private _collisionMask;
  81155. private _collisionGroup;
  81156. /**
  81157. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  81158. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  81159. */
  81160. ellipsoid: Vector3;
  81161. /**
  81162. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  81163. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  81164. */
  81165. ellipsoidOffset: Vector3;
  81166. private _collider;
  81167. private _oldPositionForCollisions;
  81168. private _diffPositionForCollisions;
  81169. /**
  81170. * Gets or sets a collision mask used to mask collisions (default is -1).
  81171. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  81172. */
  81173. collisionMask: number;
  81174. /**
  81175. * Gets or sets the current collision group mask (-1 by default).
  81176. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  81177. */
  81178. collisionGroup: number;
  81179. /**
  81180. * Defines edge width used when edgesRenderer is enabled
  81181. * @see https://www.babylonjs-playground.com/#10OJSG#13
  81182. */
  81183. edgesWidth: number;
  81184. /**
  81185. * Defines edge color used when edgesRenderer is enabled
  81186. * @see https://www.babylonjs-playground.com/#10OJSG#13
  81187. */
  81188. edgesColor: Color4;
  81189. /** @hidden */
  81190. _edgesRenderer: Nullable<IEdgesRenderer>;
  81191. /** @hidden */
  81192. _masterMesh: Nullable<AbstractMesh>;
  81193. /** @hidden */
  81194. _boundingInfo: Nullable<BoundingInfo>;
  81195. /** @hidden */
  81196. _renderId: number;
  81197. /**
  81198. * Gets or sets the list of subMeshes
  81199. * @see http://doc.babylonjs.com/how_to/multi_materials
  81200. */
  81201. subMeshes: SubMesh[];
  81202. /** @hidden */
  81203. _intersectionsInProgress: AbstractMesh[];
  81204. /** @hidden */
  81205. _unIndexed: boolean;
  81206. /** @hidden */
  81207. _lightSources: Light[];
  81208. /** @hidden */
  81209. readonly _positions: Nullable<Vector3[]>;
  81210. /** @hidden */
  81211. _waitingActions: any;
  81212. /** @hidden */
  81213. _waitingFreezeWorldMatrix: Nullable<boolean>;
  81214. private _skeleton;
  81215. /** @hidden */
  81216. _bonesTransformMatrices: Nullable<Float32Array>;
  81217. /**
  81218. * Gets or sets a skeleton to apply skining transformations
  81219. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  81220. */
  81221. skeleton: Nullable<Skeleton>;
  81222. /**
  81223. * An event triggered when the mesh is rebuilt.
  81224. */
  81225. onRebuildObservable: Observable<AbstractMesh>;
  81226. /**
  81227. * Creates a new AbstractMesh
  81228. * @param name defines the name of the mesh
  81229. * @param scene defines the hosting scene
  81230. */
  81231. constructor(name: string, scene?: Nullable<Scene>);
  81232. /**
  81233. * Returns the string "AbstractMesh"
  81234. * @returns "AbstractMesh"
  81235. */
  81236. getClassName(): string;
  81237. /**
  81238. * Gets a string representation of the current mesh
  81239. * @param fullDetails defines a boolean indicating if full details must be included
  81240. * @returns a string representation of the current mesh
  81241. */
  81242. toString(fullDetails?: boolean): string;
  81243. /** @hidden */
  81244. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  81245. /** @hidden */
  81246. _rebuild(): void;
  81247. /** @hidden */
  81248. _resyncLightSources(): void;
  81249. /** @hidden */
  81250. _resyncLighSource(light: Light): void;
  81251. /** @hidden */
  81252. _unBindEffect(): void;
  81253. /** @hidden */
  81254. _removeLightSource(light: Light): void;
  81255. private _markSubMeshesAsDirty;
  81256. /** @hidden */
  81257. _markSubMeshesAsLightDirty(): void;
  81258. /** @hidden */
  81259. _markSubMeshesAsAttributesDirty(): void;
  81260. /** @hidden */
  81261. _markSubMeshesAsMiscDirty(): void;
  81262. /**
  81263. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  81264. */
  81265. scaling: Vector3;
  81266. /**
  81267. * Returns true if the mesh is blocked. Implemented by child classes
  81268. */
  81269. readonly isBlocked: boolean;
  81270. /**
  81271. * Returns the mesh itself by default. Implemented by child classes
  81272. * @param camera defines the camera to use to pick the right LOD level
  81273. * @returns the currentAbstractMesh
  81274. */
  81275. getLOD(camera: Camera): Nullable<AbstractMesh>;
  81276. /**
  81277. * Returns 0 by default. Implemented by child classes
  81278. * @returns an integer
  81279. */
  81280. getTotalVertices(): number;
  81281. /**
  81282. * Returns a positive integer : the total number of indices in this mesh geometry.
  81283. * @returns the numner of indices or zero if the mesh has no geometry.
  81284. */
  81285. getTotalIndices(): number;
  81286. /**
  81287. * Returns null by default. Implemented by child classes
  81288. * @returns null
  81289. */
  81290. getIndices(): Nullable<IndicesArray>;
  81291. /**
  81292. * Returns the array of the requested vertex data kind. Implemented by child classes
  81293. * @param kind defines the vertex data kind to use
  81294. * @returns null
  81295. */
  81296. getVerticesData(kind: string): Nullable<FloatArray>;
  81297. /**
  81298. * Sets the vertex data of the mesh geometry for the requested `kind`.
  81299. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  81300. * Note that a new underlying VertexBuffer object is created each call.
  81301. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  81302. * @param kind defines vertex data kind:
  81303. * * VertexBuffer.PositionKind
  81304. * * VertexBuffer.UVKind
  81305. * * VertexBuffer.UV2Kind
  81306. * * VertexBuffer.UV3Kind
  81307. * * VertexBuffer.UV4Kind
  81308. * * VertexBuffer.UV5Kind
  81309. * * VertexBuffer.UV6Kind
  81310. * * VertexBuffer.ColorKind
  81311. * * VertexBuffer.MatricesIndicesKind
  81312. * * VertexBuffer.MatricesIndicesExtraKind
  81313. * * VertexBuffer.MatricesWeightsKind
  81314. * * VertexBuffer.MatricesWeightsExtraKind
  81315. * @param data defines the data source
  81316. * @param updatable defines if the data must be flagged as updatable (or static)
  81317. * @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
  81318. * @returns the current mesh
  81319. */
  81320. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  81321. /**
  81322. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  81323. * If the mesh has no geometry, it is simply returned as it is.
  81324. * @param kind defines vertex data kind:
  81325. * * VertexBuffer.PositionKind
  81326. * * VertexBuffer.UVKind
  81327. * * VertexBuffer.UV2Kind
  81328. * * VertexBuffer.UV3Kind
  81329. * * VertexBuffer.UV4Kind
  81330. * * VertexBuffer.UV5Kind
  81331. * * VertexBuffer.UV6Kind
  81332. * * VertexBuffer.ColorKind
  81333. * * VertexBuffer.MatricesIndicesKind
  81334. * * VertexBuffer.MatricesIndicesExtraKind
  81335. * * VertexBuffer.MatricesWeightsKind
  81336. * * VertexBuffer.MatricesWeightsExtraKind
  81337. * @param data defines the data source
  81338. * @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
  81339. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  81340. * @returns the current mesh
  81341. */
  81342. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  81343. /**
  81344. * Sets the mesh indices,
  81345. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  81346. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  81347. * @param totalVertices Defines the total number of vertices
  81348. * @returns the current mesh
  81349. */
  81350. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  81351. /**
  81352. * Gets a boolean indicating if specific vertex data is present
  81353. * @param kind defines the vertex data kind to use
  81354. * @returns true is data kind is present
  81355. */
  81356. isVerticesDataPresent(kind: string): boolean;
  81357. /**
  81358. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  81359. * @returns a BoundingInfo
  81360. */
  81361. getBoundingInfo(): BoundingInfo;
  81362. /**
  81363. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  81364. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box
  81365. * @returns the current mesh
  81366. */
  81367. normalizeToUnitCube(includeDescendants?: boolean): AbstractMesh;
  81368. /**
  81369. * Overwrite the current bounding info
  81370. * @param boundingInfo defines the new bounding info
  81371. * @returns the current mesh
  81372. */
  81373. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  81374. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  81375. readonly useBones: boolean;
  81376. /** @hidden */
  81377. _preActivate(): void;
  81378. /** @hidden */
  81379. _preActivateForIntermediateRendering(renderId: number): void;
  81380. /** @hidden */
  81381. _activate(renderId: number): void;
  81382. /**
  81383. * Gets the current world matrix
  81384. * @returns a Matrix
  81385. */
  81386. getWorldMatrix(): Matrix;
  81387. /** @hidden */
  81388. _getWorldMatrixDeterminant(): number;
  81389. /**
  81390. * Perform relative position change from the point of view of behind the front of the mesh.
  81391. * This is performed taking into account the meshes current rotation, so you do not have to care.
  81392. * Supports definition of mesh facing forward or backward
  81393. * @param amountRight defines the distance on the right axis
  81394. * @param amountUp defines the distance on the up axis
  81395. * @param amountForward defines the distance on the forward axis
  81396. * @returns the current mesh
  81397. */
  81398. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  81399. /**
  81400. * Calculate relative position change from the point of view of behind the front of the mesh.
  81401. * This is performed taking into account the meshes current rotation, so you do not have to care.
  81402. * Supports definition of mesh facing forward or backward
  81403. * @param amountRight defines the distance on the right axis
  81404. * @param amountUp defines the distance on the up axis
  81405. * @param amountForward defines the distance on the forward axis
  81406. * @returns the new displacement vector
  81407. */
  81408. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  81409. /**
  81410. * Perform relative rotation change from the point of view of behind the front of the mesh.
  81411. * Supports definition of mesh facing forward or backward
  81412. * @param flipBack defines the flip
  81413. * @param twirlClockwise defines the twirl
  81414. * @param tiltRight defines the tilt
  81415. * @returns the current mesh
  81416. */
  81417. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  81418. /**
  81419. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  81420. * Supports definition of mesh facing forward or backward.
  81421. * @param flipBack defines the flip
  81422. * @param twirlClockwise defines the twirl
  81423. * @param tiltRight defines the tilt
  81424. * @returns the new rotation vector
  81425. */
  81426. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  81427. /**
  81428. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  81429. * @param includeDescendants Include bounding info from descendants as well (true by default)
  81430. * @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
  81431. * @returns the new bounding vectors
  81432. */
  81433. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  81434. min: Vector3;
  81435. max: Vector3;
  81436. };
  81437. /**
  81438. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  81439. * This means the mesh underlying bounding box and sphere are recomputed.
  81440. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  81441. * @returns the current mesh
  81442. */
  81443. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  81444. /** @hidden */
  81445. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  81446. /** @hidden */
  81447. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  81448. /** @hidden */
  81449. _updateBoundingInfo(): AbstractMesh;
  81450. /** @hidden */
  81451. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  81452. /** @hidden */
  81453. protected _afterComputeWorldMatrix(): void;
  81454. /**
  81455. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  81456. * A mesh is in the frustum if its bounding box intersects the frustum
  81457. * @param frustumPlanes defines the frustum to test
  81458. * @returns true if the mesh is in the frustum planes
  81459. */
  81460. isInFrustum(frustumPlanes: Plane[]): boolean;
  81461. /**
  81462. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  81463. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  81464. * @param frustumPlanes defines the frustum to test
  81465. * @returns true if the mesh is completely in the frustum planes
  81466. */
  81467. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  81468. /**
  81469. * True if the mesh intersects another mesh or a SolidParticle object
  81470. * @param mesh defines a target mesh or SolidParticle to test
  81471. * @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)
  81472. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  81473. * @returns true if there is an intersection
  81474. */
  81475. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  81476. /**
  81477. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  81478. * @param point defines the point to test
  81479. * @returns true if there is an intersection
  81480. */
  81481. intersectsPoint(point: Vector3): boolean;
  81482. /**
  81483. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  81484. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  81485. */
  81486. checkCollisions: boolean;
  81487. /**
  81488. * Gets Collider object used to compute collisions (not physics)
  81489. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  81490. */
  81491. readonly collider: Collider;
  81492. /**
  81493. * Move the mesh using collision engine
  81494. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  81495. * @param displacement defines the requested displacement vector
  81496. * @returns the current mesh
  81497. */
  81498. moveWithCollisions(displacement: Vector3): AbstractMesh;
  81499. private _onCollisionPositionChange;
  81500. /** @hidden */
  81501. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  81502. /** @hidden */
  81503. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  81504. /** @hidden */
  81505. _checkCollision(collider: Collider): AbstractMesh;
  81506. /** @hidden */
  81507. _generatePointsArray(): boolean;
  81508. /**
  81509. * Checks if the passed Ray intersects with the mesh
  81510. * @param ray defines the ray to use
  81511. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  81512. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  81513. * @returns the picking info
  81514. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  81515. */
  81516. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  81517. /**
  81518. * Clones the current mesh
  81519. * @param name defines the mesh name
  81520. * @param newParent defines the new mesh parent
  81521. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  81522. * @returns the new mesh
  81523. */
  81524. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  81525. /**
  81526. * Disposes all the submeshes of the current meshnp
  81527. * @returns the current mesh
  81528. */
  81529. releaseSubMeshes(): AbstractMesh;
  81530. /**
  81531. * Releases resources associated with this abstract mesh.
  81532. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  81533. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  81534. */
  81535. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  81536. /**
  81537. * Adds the passed mesh as a child to the current mesh
  81538. * @param mesh defines the child mesh
  81539. * @returns the current mesh
  81540. */
  81541. addChild(mesh: AbstractMesh): AbstractMesh;
  81542. /**
  81543. * Removes the passed mesh from the current mesh children list
  81544. * @param mesh defines the child mesh
  81545. * @returns the current mesh
  81546. */
  81547. removeChild(mesh: AbstractMesh): AbstractMesh;
  81548. /** @hidden */
  81549. private _initFacetData;
  81550. /**
  81551. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  81552. * This method can be called within the render loop.
  81553. * 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
  81554. * @returns the current mesh
  81555. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81556. */
  81557. updateFacetData(): AbstractMesh;
  81558. /**
  81559. * Returns the facetLocalNormals array.
  81560. * The normals are expressed in the mesh local spac
  81561. * @returns an array of Vector3
  81562. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81563. */
  81564. getFacetLocalNormals(): Vector3[];
  81565. /**
  81566. * Returns the facetLocalPositions array.
  81567. * The facet positions are expressed in the mesh local space
  81568. * @returns an array of Vector3
  81569. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81570. */
  81571. getFacetLocalPositions(): Vector3[];
  81572. /**
  81573. * Returns the facetLocalPartioning array
  81574. * @returns an array of array of numbers
  81575. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81576. */
  81577. getFacetLocalPartitioning(): number[][];
  81578. /**
  81579. * Returns the i-th facet position in the world system.
  81580. * This method allocates a new Vector3 per call
  81581. * @param i defines the facet index
  81582. * @returns a new Vector3
  81583. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81584. */
  81585. getFacetPosition(i: number): Vector3;
  81586. /**
  81587. * Sets the reference Vector3 with the i-th facet position in the world system
  81588. * @param i defines the facet index
  81589. * @param ref defines the target vector
  81590. * @returns the current mesh
  81591. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81592. */
  81593. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  81594. /**
  81595. * Returns the i-th facet normal in the world system.
  81596. * This method allocates a new Vector3 per call
  81597. * @param i defines the facet index
  81598. * @returns a new Vector3
  81599. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81600. */
  81601. getFacetNormal(i: number): Vector3;
  81602. /**
  81603. * Sets the reference Vector3 with the i-th facet normal in the world system
  81604. * @param i defines the facet index
  81605. * @param ref defines the target vector
  81606. * @returns the current mesh
  81607. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81608. */
  81609. getFacetNormalToRef(i: number, ref: Vector3): this;
  81610. /**
  81611. * 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)
  81612. * @param x defines x coordinate
  81613. * @param y defines y coordinate
  81614. * @param z defines z coordinate
  81615. * @returns the array of facet indexes
  81616. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81617. */
  81618. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  81619. /**
  81620. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  81621. * @param projected sets as the (x,y,z) world projection on the facet
  81622. * @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
  81623. * @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
  81624. * @param x defines x coordinate
  81625. * @param y defines y coordinate
  81626. * @param z defines z coordinate
  81627. * @returns the face index if found (or null instead)
  81628. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81629. */
  81630. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  81631. /**
  81632. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  81633. * @param projected sets as the (x,y,z) local projection on the facet
  81634. * @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
  81635. * @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
  81636. * @param x defines x coordinate
  81637. * @param y defines y coordinate
  81638. * @param z defines z coordinate
  81639. * @returns the face index if found (or null instead)
  81640. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81641. */
  81642. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  81643. /**
  81644. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  81645. * @returns the parameters
  81646. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81647. */
  81648. getFacetDataParameters(): any;
  81649. /**
  81650. * Disables the feature FacetData and frees the related memory
  81651. * @returns the current mesh
  81652. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81653. */
  81654. disableFacetData(): AbstractMesh;
  81655. /**
  81656. * Updates the AbstractMesh indices array
  81657. * @param indices defines the data source
  81658. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  81659. * @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)
  81660. * @returns the current mesh
  81661. */
  81662. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  81663. /**
  81664. * Creates new normals data for the mesh
  81665. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  81666. * @returns the current mesh
  81667. */
  81668. createNormals(updatable: boolean): AbstractMesh;
  81669. /**
  81670. * Align the mesh with a normal
  81671. * @param normal defines the normal to use
  81672. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  81673. * @returns the current mesh
  81674. */
  81675. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  81676. /** @hidden */
  81677. _checkOcclusionQuery(): boolean;
  81678. }
  81679. }
  81680. declare module BABYLON {
  81681. /**
  81682. * Interface used to define ActionEvent
  81683. */
  81684. export interface IActionEvent {
  81685. /** The mesh or sprite that triggered the action */
  81686. source: any;
  81687. /** The X mouse cursor position at the time of the event */
  81688. pointerX: number;
  81689. /** The Y mouse cursor position at the time of the event */
  81690. pointerY: number;
  81691. /** The mesh that is currently pointed at (can be null) */
  81692. meshUnderPointer: Nullable<AbstractMesh>;
  81693. /** the original (browser) event that triggered the ActionEvent */
  81694. sourceEvent?: any;
  81695. /** additional data for the event */
  81696. additionalData?: any;
  81697. }
  81698. /**
  81699. * ActionEvent is the event being sent when an action is triggered.
  81700. */
  81701. export class ActionEvent implements IActionEvent {
  81702. /** The mesh or sprite that triggered the action */
  81703. source: any;
  81704. /** The X mouse cursor position at the time of the event */
  81705. pointerX: number;
  81706. /** The Y mouse cursor position at the time of the event */
  81707. pointerY: number;
  81708. /** The mesh that is currently pointed at (can be null) */
  81709. meshUnderPointer: Nullable<AbstractMesh>;
  81710. /** the original (browser) event that triggered the ActionEvent */
  81711. sourceEvent?: any;
  81712. /** additional data for the event */
  81713. additionalData?: any;
  81714. /**
  81715. * Creates a new ActionEvent
  81716. * @param source The mesh or sprite that triggered the action
  81717. * @param pointerX The X mouse cursor position at the time of the event
  81718. * @param pointerY The Y mouse cursor position at the time of the event
  81719. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  81720. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  81721. * @param additionalData additional data for the event
  81722. */
  81723. constructor(
  81724. /** The mesh or sprite that triggered the action */
  81725. source: any,
  81726. /** The X mouse cursor position at the time of the event */
  81727. pointerX: number,
  81728. /** The Y mouse cursor position at the time of the event */
  81729. pointerY: number,
  81730. /** The mesh that is currently pointed at (can be null) */
  81731. meshUnderPointer: Nullable<AbstractMesh>,
  81732. /** the original (browser) event that triggered the ActionEvent */
  81733. sourceEvent?: any,
  81734. /** additional data for the event */
  81735. additionalData?: any);
  81736. /**
  81737. * Helper function to auto-create an ActionEvent from a source mesh.
  81738. * @param source The source mesh that triggered the event
  81739. * @param evt The original (browser) event
  81740. * @param additionalData additional data for the event
  81741. * @returns the new ActionEvent
  81742. */
  81743. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  81744. /**
  81745. * Helper function to auto-create an ActionEvent from a source sprite
  81746. * @param source The source sprite that triggered the event
  81747. * @param scene Scene associated with the sprite
  81748. * @param evt The original (browser) event
  81749. * @param additionalData additional data for the event
  81750. * @returns the new ActionEvent
  81751. */
  81752. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  81753. /**
  81754. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  81755. * @param scene the scene where the event occurred
  81756. * @param evt The original (browser) event
  81757. * @returns the new ActionEvent
  81758. */
  81759. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  81760. /**
  81761. * Helper function to auto-create an ActionEvent from a primitive
  81762. * @param prim defines the target primitive
  81763. * @param pointerPos defines the pointer position
  81764. * @param evt The original (browser) event
  81765. * @param additionalData additional data for the event
  81766. * @returns the new ActionEvent
  81767. */
  81768. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  81769. }
  81770. }
  81771. declare module BABYLON {
  81772. /**
  81773. * Abstract class used to decouple action Manager from scene and meshes.
  81774. * Do not instantiate.
  81775. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  81776. */
  81777. export abstract class AbstractActionManager implements IDisposable {
  81778. /** Gets the list of active triggers */
  81779. static Triggers: {
  81780. [key: string]: number;
  81781. };
  81782. /** Gets the cursor to use when hovering items */
  81783. hoverCursor: string;
  81784. /** Gets the list of actions */
  81785. actions: IAction[];
  81786. /**
  81787. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  81788. */
  81789. isRecursive: boolean;
  81790. /**
  81791. * Releases all associated resources
  81792. */
  81793. abstract dispose(): void;
  81794. /**
  81795. * Does this action manager has pointer triggers
  81796. */
  81797. abstract readonly hasPointerTriggers: boolean;
  81798. /**
  81799. * Does this action manager has pick triggers
  81800. */
  81801. abstract readonly hasPickTriggers: boolean;
  81802. /**
  81803. * Process a specific trigger
  81804. * @param trigger defines the trigger to process
  81805. * @param evt defines the event details to be processed
  81806. */
  81807. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  81808. /**
  81809. * Does this action manager handles actions of any of the given triggers
  81810. * @param triggers defines the triggers to be tested
  81811. * @return a boolean indicating whether one (or more) of the triggers is handled
  81812. */
  81813. abstract hasSpecificTriggers(triggers: number[]): boolean;
  81814. /**
  81815. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  81816. * speed.
  81817. * @param triggerA defines the trigger to be tested
  81818. * @param triggerB defines the trigger to be tested
  81819. * @return a boolean indicating whether one (or more) of the triggers is handled
  81820. */
  81821. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  81822. /**
  81823. * Does this action manager handles actions of a given trigger
  81824. * @param trigger defines the trigger to be tested
  81825. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  81826. * @return whether the trigger is handled
  81827. */
  81828. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  81829. /**
  81830. * Serialize this manager to a JSON object
  81831. * @param name defines the property name to store this manager
  81832. * @returns a JSON representation of this manager
  81833. */
  81834. abstract serialize(name: string): any;
  81835. /**
  81836. * Registers an action to this action manager
  81837. * @param action defines the action to be registered
  81838. * @return the action amended (prepared) after registration
  81839. */
  81840. abstract registerAction(action: IAction): Nullable<IAction>;
  81841. /**
  81842. * Unregisters an action to this action manager
  81843. * @param action defines the action to be unregistered
  81844. * @return a boolean indicating whether the action has been unregistered
  81845. */
  81846. abstract unregisterAction(action: IAction): Boolean;
  81847. /**
  81848. * Does exist one action manager with at least one trigger
  81849. **/
  81850. static readonly HasTriggers: boolean;
  81851. /**
  81852. * Does exist one action manager with at least one pick trigger
  81853. **/
  81854. static readonly HasPickTriggers: boolean;
  81855. /**
  81856. * Does exist one action manager that handles actions of a given trigger
  81857. * @param trigger defines the trigger to be tested
  81858. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  81859. **/
  81860. static HasSpecificTrigger(trigger: number): boolean;
  81861. }
  81862. }
  81863. declare module BABYLON {
  81864. /**
  81865. * Defines how a node can be built from a string name.
  81866. */
  81867. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  81868. /**
  81869. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  81870. */
  81871. export class Node implements IBehaviorAware<Node> {
  81872. /** @hidden */
  81873. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  81874. private static _NodeConstructors;
  81875. /**
  81876. * Add a new node constructor
  81877. * @param type defines the type name of the node to construct
  81878. * @param constructorFunc defines the constructor function
  81879. */
  81880. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  81881. /**
  81882. * Returns a node constructor based on type name
  81883. * @param type defines the type name
  81884. * @param name defines the new node name
  81885. * @param scene defines the hosting scene
  81886. * @param options defines optional options to transmit to constructors
  81887. * @returns the new constructor or null
  81888. */
  81889. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  81890. /**
  81891. * Gets or sets the name of the node
  81892. */
  81893. name: string;
  81894. /**
  81895. * Gets or sets the id of the node
  81896. */
  81897. id: string;
  81898. /**
  81899. * Gets or sets the unique id of the node
  81900. */
  81901. uniqueId: number;
  81902. /**
  81903. * Gets or sets a string used to store user defined state for the node
  81904. */
  81905. state: string;
  81906. /**
  81907. * Gets or sets an object used to store user defined information for the node
  81908. */
  81909. metadata: any;
  81910. /**
  81911. * For internal use only. Please do not use.
  81912. */
  81913. reservedDataStore: any;
  81914. /**
  81915. * Gets or sets a boolean used to define if the node must be serialized
  81916. */
  81917. doNotSerialize: boolean;
  81918. /** @hidden */
  81919. _isDisposed: boolean;
  81920. /**
  81921. * Gets a list of Animations associated with the node
  81922. */
  81923. animations: Animation[];
  81924. protected _ranges: {
  81925. [name: string]: Nullable<AnimationRange>;
  81926. };
  81927. /**
  81928. * Callback raised when the node is ready to be used
  81929. */
  81930. onReady: (node: Node) => void;
  81931. private _isEnabled;
  81932. private _isParentEnabled;
  81933. private _isReady;
  81934. /** @hidden */
  81935. _currentRenderId: number;
  81936. private _parentRenderId;
  81937. protected _childRenderId: number;
  81938. /** @hidden */
  81939. _waitingParentId: Nullable<string>;
  81940. /** @hidden */
  81941. _scene: Scene;
  81942. /** @hidden */
  81943. _cache: any;
  81944. private _parentNode;
  81945. private _children;
  81946. /** @hidden */
  81947. _worldMatrix: Matrix;
  81948. /** @hidden */
  81949. _worldMatrixDeterminant: number;
  81950. /** @hidden */
  81951. private _sceneRootNodesIndex;
  81952. /**
  81953. * Gets a boolean indicating if the node has been disposed
  81954. * @returns true if the node was disposed
  81955. */
  81956. isDisposed(): boolean;
  81957. /**
  81958. * Gets or sets the parent of the node
  81959. */
  81960. parent: Nullable<Node>;
  81961. private addToSceneRootNodes;
  81962. private removeFromSceneRootNodes;
  81963. private _animationPropertiesOverride;
  81964. /**
  81965. * Gets or sets the animation properties override
  81966. */
  81967. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  81968. /**
  81969. * Gets a string idenfifying the name of the class
  81970. * @returns "Node" string
  81971. */
  81972. getClassName(): string;
  81973. /** @hidden */
  81974. readonly _isNode: boolean;
  81975. /**
  81976. * An event triggered when the mesh is disposed
  81977. */
  81978. onDisposeObservable: Observable<Node>;
  81979. private _onDisposeObserver;
  81980. /**
  81981. * Sets a callback that will be raised when the node will be disposed
  81982. */
  81983. onDispose: () => void;
  81984. /**
  81985. * Creates a new Node
  81986. * @param name the name and id to be given to this node
  81987. * @param scene the scene this node will be added to
  81988. * @param addToRootNodes the node will be added to scene.rootNodes
  81989. */
  81990. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  81991. /**
  81992. * Gets the scene of the node
  81993. * @returns a scene
  81994. */
  81995. getScene(): Scene;
  81996. /**
  81997. * Gets the engine of the node
  81998. * @returns a Engine
  81999. */
  82000. getEngine(): Engine;
  82001. private _behaviors;
  82002. /**
  82003. * Attach a behavior to the node
  82004. * @see http://doc.babylonjs.com/features/behaviour
  82005. * @param behavior defines the behavior to attach
  82006. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  82007. * @returns the current Node
  82008. */
  82009. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  82010. /**
  82011. * Remove an attached behavior
  82012. * @see http://doc.babylonjs.com/features/behaviour
  82013. * @param behavior defines the behavior to attach
  82014. * @returns the current Node
  82015. */
  82016. removeBehavior(behavior: Behavior<Node>): Node;
  82017. /**
  82018. * Gets the list of attached behaviors
  82019. * @see http://doc.babylonjs.com/features/behaviour
  82020. */
  82021. readonly behaviors: Behavior<Node>[];
  82022. /**
  82023. * Gets an attached behavior by name
  82024. * @param name defines the name of the behavior to look for
  82025. * @see http://doc.babylonjs.com/features/behaviour
  82026. * @returns null if behavior was not found else the requested behavior
  82027. */
  82028. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  82029. /**
  82030. * Returns the latest update of the World matrix
  82031. * @returns a Matrix
  82032. */
  82033. getWorldMatrix(): Matrix;
  82034. /** @hidden */
  82035. _getWorldMatrixDeterminant(): number;
  82036. /**
  82037. * Returns directly the latest state of the mesh World matrix.
  82038. * A Matrix is returned.
  82039. */
  82040. readonly worldMatrixFromCache: Matrix;
  82041. /** @hidden */
  82042. _initCache(): void;
  82043. /** @hidden */
  82044. updateCache(force?: boolean): void;
  82045. /** @hidden */
  82046. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  82047. /** @hidden */
  82048. _updateCache(ignoreParentClass?: boolean): void;
  82049. /** @hidden */
  82050. _isSynchronized(): boolean;
  82051. /** @hidden */
  82052. _markSyncedWithParent(): void;
  82053. /** @hidden */
  82054. isSynchronizedWithParent(): boolean;
  82055. /** @hidden */
  82056. isSynchronized(): boolean;
  82057. /**
  82058. * Is this node ready to be used/rendered
  82059. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  82060. * @return true if the node is ready
  82061. */
  82062. isReady(completeCheck?: boolean): boolean;
  82063. /**
  82064. * Is this node enabled?
  82065. * 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
  82066. * @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
  82067. * @return whether this node (and its parent) is enabled
  82068. */
  82069. isEnabled(checkAncestors?: boolean): boolean;
  82070. /** @hidden */
  82071. protected _syncParentEnabledState(): void;
  82072. /**
  82073. * Set the enabled state of this node
  82074. * @param value defines the new enabled state
  82075. */
  82076. setEnabled(value: boolean): void;
  82077. /**
  82078. * Is this node a descendant of the given node?
  82079. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  82080. * @param ancestor defines the parent node to inspect
  82081. * @returns a boolean indicating if this node is a descendant of the given node
  82082. */
  82083. isDescendantOf(ancestor: Node): boolean;
  82084. /** @hidden */
  82085. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  82086. /**
  82087. * Will return all nodes that have this node as ascendant
  82088. * @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
  82089. * @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
  82090. * @return all children nodes of all types
  82091. */
  82092. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  82093. /**
  82094. * Get all child-meshes of this node
  82095. * @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)
  82096. * @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
  82097. * @returns an array of AbstractMesh
  82098. */
  82099. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  82100. /**
  82101. * Get all direct children of this node
  82102. * @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
  82103. * @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)
  82104. * @returns an array of Node
  82105. */
  82106. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  82107. /** @hidden */
  82108. _setReady(state: boolean): void;
  82109. /**
  82110. * Get an animation by name
  82111. * @param name defines the name of the animation to look for
  82112. * @returns null if not found else the requested animation
  82113. */
  82114. getAnimationByName(name: string): Nullable<Animation>;
  82115. /**
  82116. * Creates an animation range for this node
  82117. * @param name defines the name of the range
  82118. * @param from defines the starting key
  82119. * @param to defines the end key
  82120. */
  82121. createAnimationRange(name: string, from: number, to: number): void;
  82122. /**
  82123. * Delete a specific animation range
  82124. * @param name defines the name of the range to delete
  82125. * @param deleteFrames defines if animation frames from the range must be deleted as well
  82126. */
  82127. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  82128. /**
  82129. * Get an animation range by name
  82130. * @param name defines the name of the animation range to look for
  82131. * @returns null if not found else the requested animation range
  82132. */
  82133. getAnimationRange(name: string): Nullable<AnimationRange>;
  82134. /**
  82135. * Gets the list of all animation ranges defined on this node
  82136. * @returns an array
  82137. */
  82138. getAnimationRanges(): Nullable<AnimationRange>[];
  82139. /**
  82140. * Will start the animation sequence
  82141. * @param name defines the range frames for animation sequence
  82142. * @param loop defines if the animation should loop (false by default)
  82143. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  82144. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  82145. * @returns the object created for this animation. If range does not exist, it will return null
  82146. */
  82147. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  82148. /**
  82149. * Serialize animation ranges into a JSON compatible object
  82150. * @returns serialization object
  82151. */
  82152. serializeAnimationRanges(): any;
  82153. /**
  82154. * Computes the world matrix of the node
  82155. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  82156. * @returns the world matrix
  82157. */
  82158. computeWorldMatrix(force?: boolean): Matrix;
  82159. /**
  82160. * Releases resources associated with this node.
  82161. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  82162. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  82163. */
  82164. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  82165. /**
  82166. * Parse animation range data from a serialization object and store them into a given node
  82167. * @param node defines where to store the animation ranges
  82168. * @param parsedNode defines the serialization object to read data from
  82169. * @param scene defines the hosting scene
  82170. */
  82171. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  82172. }
  82173. }
  82174. declare module BABYLON {
  82175. /**
  82176. * Class used to store any kind of animation
  82177. */
  82178. export class Animation {
  82179. /**Name of the animation */
  82180. name: string;
  82181. /**Property to animate */
  82182. targetProperty: string;
  82183. /**The frames per second of the animation */
  82184. framePerSecond: number;
  82185. /**The data type of the animation */
  82186. dataType: number;
  82187. /**The loop mode of the animation */
  82188. loopMode?: number | undefined;
  82189. /**Specifies if blending should be enabled */
  82190. enableBlending?: boolean | undefined;
  82191. /**
  82192. * Use matrix interpolation instead of using direct key value when animating matrices
  82193. */
  82194. static AllowMatricesInterpolation: boolean;
  82195. /**
  82196. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  82197. */
  82198. static AllowMatrixDecomposeForInterpolation: boolean;
  82199. /**
  82200. * Stores the key frames of the animation
  82201. */
  82202. private _keys;
  82203. /**
  82204. * Stores the easing function of the animation
  82205. */
  82206. private _easingFunction;
  82207. /**
  82208. * @hidden Internal use only
  82209. */
  82210. _runtimeAnimations: RuntimeAnimation[];
  82211. /**
  82212. * The set of event that will be linked to this animation
  82213. */
  82214. private _events;
  82215. /**
  82216. * Stores an array of target property paths
  82217. */
  82218. targetPropertyPath: string[];
  82219. /**
  82220. * Stores the blending speed of the animation
  82221. */
  82222. blendingSpeed: number;
  82223. /**
  82224. * Stores the animation ranges for the animation
  82225. */
  82226. private _ranges;
  82227. /**
  82228. * @hidden Internal use
  82229. */
  82230. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  82231. /**
  82232. * Sets up an animation
  82233. * @param property The property to animate
  82234. * @param animationType The animation type to apply
  82235. * @param framePerSecond The frames per second of the animation
  82236. * @param easingFunction The easing function used in the animation
  82237. * @returns The created animation
  82238. */
  82239. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  82240. /**
  82241. * Create and start an animation on a node
  82242. * @param name defines the name of the global animation that will be run on all nodes
  82243. * @param node defines the root node where the animation will take place
  82244. * @param targetProperty defines property to animate
  82245. * @param framePerSecond defines the number of frame per second yo use
  82246. * @param totalFrame defines the number of frames in total
  82247. * @param from defines the initial value
  82248. * @param to defines the final value
  82249. * @param loopMode defines which loop mode you want to use (off by default)
  82250. * @param easingFunction defines the easing function to use (linear by default)
  82251. * @param onAnimationEnd defines the callback to call when animation end
  82252. * @returns the animatable created for this animation
  82253. */
  82254. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  82255. /**
  82256. * Create and start an animation on a node and its descendants
  82257. * @param name defines the name of the global animation that will be run on all nodes
  82258. * @param node defines the root node where the animation will take place
  82259. * @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
  82260. * @param targetProperty defines property to animate
  82261. * @param framePerSecond defines the number of frame per second to use
  82262. * @param totalFrame defines the number of frames in total
  82263. * @param from defines the initial value
  82264. * @param to defines the final value
  82265. * @param loopMode defines which loop mode you want to use (off by default)
  82266. * @param easingFunction defines the easing function to use (linear by default)
  82267. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  82268. * @returns the list of animatables created for all nodes
  82269. * @example https://www.babylonjs-playground.com/#MH0VLI
  82270. */
  82271. 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[]>;
  82272. /**
  82273. * Creates a new animation, merges it with the existing animations and starts it
  82274. * @param name Name of the animation
  82275. * @param node Node which contains the scene that begins the animations
  82276. * @param targetProperty Specifies which property to animate
  82277. * @param framePerSecond The frames per second of the animation
  82278. * @param totalFrame The total number of frames
  82279. * @param from The frame at the beginning of the animation
  82280. * @param to The frame at the end of the animation
  82281. * @param loopMode Specifies the loop mode of the animation
  82282. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  82283. * @param onAnimationEnd Callback to run once the animation is complete
  82284. * @returns Nullable animation
  82285. */
  82286. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  82287. /**
  82288. * Transition property of an host to the target Value
  82289. * @param property The property to transition
  82290. * @param targetValue The target Value of the property
  82291. * @param host The object where the property to animate belongs
  82292. * @param scene Scene used to run the animation
  82293. * @param frameRate Framerate (in frame/s) to use
  82294. * @param transition The transition type we want to use
  82295. * @param duration The duration of the animation, in milliseconds
  82296. * @param onAnimationEnd Callback trigger at the end of the animation
  82297. * @returns Nullable animation
  82298. */
  82299. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  82300. /**
  82301. * Return the array of runtime animations currently using this animation
  82302. */
  82303. readonly runtimeAnimations: RuntimeAnimation[];
  82304. /**
  82305. * Specifies if any of the runtime animations are currently running
  82306. */
  82307. readonly hasRunningRuntimeAnimations: boolean;
  82308. /**
  82309. * Initializes the animation
  82310. * @param name Name of the animation
  82311. * @param targetProperty Property to animate
  82312. * @param framePerSecond The frames per second of the animation
  82313. * @param dataType The data type of the animation
  82314. * @param loopMode The loop mode of the animation
  82315. * @param enableBlending Specifies if blending should be enabled
  82316. */
  82317. constructor(
  82318. /**Name of the animation */
  82319. name: string,
  82320. /**Property to animate */
  82321. targetProperty: string,
  82322. /**The frames per second of the animation */
  82323. framePerSecond: number,
  82324. /**The data type of the animation */
  82325. dataType: number,
  82326. /**The loop mode of the animation */
  82327. loopMode?: number | undefined,
  82328. /**Specifies if blending should be enabled */
  82329. enableBlending?: boolean | undefined);
  82330. /**
  82331. * Converts the animation to a string
  82332. * @param fullDetails support for multiple levels of logging within scene loading
  82333. * @returns String form of the animation
  82334. */
  82335. toString(fullDetails?: boolean): string;
  82336. /**
  82337. * Add an event to this animation
  82338. * @param event Event to add
  82339. */
  82340. addEvent(event: AnimationEvent): void;
  82341. /**
  82342. * Remove all events found at the given frame
  82343. * @param frame The frame to remove events from
  82344. */
  82345. removeEvents(frame: number): void;
  82346. /**
  82347. * Retrieves all the events from the animation
  82348. * @returns Events from the animation
  82349. */
  82350. getEvents(): AnimationEvent[];
  82351. /**
  82352. * Creates an animation range
  82353. * @param name Name of the animation range
  82354. * @param from Starting frame of the animation range
  82355. * @param to Ending frame of the animation
  82356. */
  82357. createRange(name: string, from: number, to: number): void;
  82358. /**
  82359. * Deletes an animation range by name
  82360. * @param name Name of the animation range to delete
  82361. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  82362. */
  82363. deleteRange(name: string, deleteFrames?: boolean): void;
  82364. /**
  82365. * Gets the animation range by name, or null if not defined
  82366. * @param name Name of the animation range
  82367. * @returns Nullable animation range
  82368. */
  82369. getRange(name: string): Nullable<AnimationRange>;
  82370. /**
  82371. * Gets the key frames from the animation
  82372. * @returns The key frames of the animation
  82373. */
  82374. getKeys(): Array<IAnimationKey>;
  82375. /**
  82376. * Gets the highest frame rate of the animation
  82377. * @returns Highest frame rate of the animation
  82378. */
  82379. getHighestFrame(): number;
  82380. /**
  82381. * Gets the easing function of the animation
  82382. * @returns Easing function of the animation
  82383. */
  82384. getEasingFunction(): IEasingFunction;
  82385. /**
  82386. * Sets the easing function of the animation
  82387. * @param easingFunction A custom mathematical formula for animation
  82388. */
  82389. setEasingFunction(easingFunction: EasingFunction): void;
  82390. /**
  82391. * Interpolates a scalar linearly
  82392. * @param startValue Start value of the animation curve
  82393. * @param endValue End value of the animation curve
  82394. * @param gradient Scalar amount to interpolate
  82395. * @returns Interpolated scalar value
  82396. */
  82397. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  82398. /**
  82399. * Interpolates a scalar cubically
  82400. * @param startValue Start value of the animation curve
  82401. * @param outTangent End tangent of the animation
  82402. * @param endValue End value of the animation curve
  82403. * @param inTangent Start tangent of the animation curve
  82404. * @param gradient Scalar amount to interpolate
  82405. * @returns Interpolated scalar value
  82406. */
  82407. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  82408. /**
  82409. * Interpolates a quaternion using a spherical linear interpolation
  82410. * @param startValue Start value of the animation curve
  82411. * @param endValue End value of the animation curve
  82412. * @param gradient Scalar amount to interpolate
  82413. * @returns Interpolated quaternion value
  82414. */
  82415. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  82416. /**
  82417. * Interpolates a quaternion cubically
  82418. * @param startValue Start value of the animation curve
  82419. * @param outTangent End tangent of the animation curve
  82420. * @param endValue End value of the animation curve
  82421. * @param inTangent Start tangent of the animation curve
  82422. * @param gradient Scalar amount to interpolate
  82423. * @returns Interpolated quaternion value
  82424. */
  82425. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  82426. /**
  82427. * Interpolates a Vector3 linearl
  82428. * @param startValue Start value of the animation curve
  82429. * @param endValue End value of the animation curve
  82430. * @param gradient Scalar amount to interpolate
  82431. * @returns Interpolated scalar value
  82432. */
  82433. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  82434. /**
  82435. * Interpolates a Vector3 cubically
  82436. * @param startValue Start value of the animation curve
  82437. * @param outTangent End tangent of the animation
  82438. * @param endValue End value of the animation curve
  82439. * @param inTangent Start tangent of the animation curve
  82440. * @param gradient Scalar amount to interpolate
  82441. * @returns InterpolatedVector3 value
  82442. */
  82443. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  82444. /**
  82445. * Interpolates a Vector2 linearly
  82446. * @param startValue Start value of the animation curve
  82447. * @param endValue End value of the animation curve
  82448. * @param gradient Scalar amount to interpolate
  82449. * @returns Interpolated Vector2 value
  82450. */
  82451. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  82452. /**
  82453. * Interpolates a Vector2 cubically
  82454. * @param startValue Start value of the animation curve
  82455. * @param outTangent End tangent of the animation
  82456. * @param endValue End value of the animation curve
  82457. * @param inTangent Start tangent of the animation curve
  82458. * @param gradient Scalar amount to interpolate
  82459. * @returns Interpolated Vector2 value
  82460. */
  82461. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  82462. /**
  82463. * Interpolates a size linearly
  82464. * @param startValue Start value of the animation curve
  82465. * @param endValue End value of the animation curve
  82466. * @param gradient Scalar amount to interpolate
  82467. * @returns Interpolated Size value
  82468. */
  82469. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  82470. /**
  82471. * Interpolates a Color3 linearly
  82472. * @param startValue Start value of the animation curve
  82473. * @param endValue End value of the animation curve
  82474. * @param gradient Scalar amount to interpolate
  82475. * @returns Interpolated Color3 value
  82476. */
  82477. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  82478. /**
  82479. * @hidden Internal use only
  82480. */
  82481. _getKeyValue(value: any): any;
  82482. /**
  82483. * @hidden Internal use only
  82484. */
  82485. _interpolate(currentFrame: number, repeatCount: number, workValue?: any, loopMode?: number, offsetValue?: any, highLimitValue?: any): any;
  82486. /**
  82487. * Defines the function to use to interpolate matrices
  82488. * @param startValue defines the start matrix
  82489. * @param endValue defines the end matrix
  82490. * @param gradient defines the gradient between both matrices
  82491. * @param result defines an optional target matrix where to store the interpolation
  82492. * @returns the interpolated matrix
  82493. */
  82494. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  82495. /**
  82496. * Makes a copy of the animation
  82497. * @returns Cloned animation
  82498. */
  82499. clone(): Animation;
  82500. /**
  82501. * Sets the key frames of the animation
  82502. * @param values The animation key frames to set
  82503. */
  82504. setKeys(values: Array<IAnimationKey>): void;
  82505. /**
  82506. * Serializes the animation to an object
  82507. * @returns Serialized object
  82508. */
  82509. serialize(): any;
  82510. /**
  82511. * Float animation type
  82512. */
  82513. private static _ANIMATIONTYPE_FLOAT;
  82514. /**
  82515. * Vector3 animation type
  82516. */
  82517. private static _ANIMATIONTYPE_VECTOR3;
  82518. /**
  82519. * Quaternion animation type
  82520. */
  82521. private static _ANIMATIONTYPE_QUATERNION;
  82522. /**
  82523. * Matrix animation type
  82524. */
  82525. private static _ANIMATIONTYPE_MATRIX;
  82526. /**
  82527. * Color3 animation type
  82528. */
  82529. private static _ANIMATIONTYPE_COLOR3;
  82530. /**
  82531. * Vector2 animation type
  82532. */
  82533. private static _ANIMATIONTYPE_VECTOR2;
  82534. /**
  82535. * Size animation type
  82536. */
  82537. private static _ANIMATIONTYPE_SIZE;
  82538. /**
  82539. * Relative Loop Mode
  82540. */
  82541. private static _ANIMATIONLOOPMODE_RELATIVE;
  82542. /**
  82543. * Cycle Loop Mode
  82544. */
  82545. private static _ANIMATIONLOOPMODE_CYCLE;
  82546. /**
  82547. * Constant Loop Mode
  82548. */
  82549. private static _ANIMATIONLOOPMODE_CONSTANT;
  82550. /**
  82551. * Get the float animation type
  82552. */
  82553. static readonly ANIMATIONTYPE_FLOAT: number;
  82554. /**
  82555. * Get the Vector3 animation type
  82556. */
  82557. static readonly ANIMATIONTYPE_VECTOR3: number;
  82558. /**
  82559. * Get the Vector2 animation type
  82560. */
  82561. static readonly ANIMATIONTYPE_VECTOR2: number;
  82562. /**
  82563. * Get the Size animation type
  82564. */
  82565. static readonly ANIMATIONTYPE_SIZE: number;
  82566. /**
  82567. * Get the Quaternion animation type
  82568. */
  82569. static readonly ANIMATIONTYPE_QUATERNION: number;
  82570. /**
  82571. * Get the Matrix animation type
  82572. */
  82573. static readonly ANIMATIONTYPE_MATRIX: number;
  82574. /**
  82575. * Get the Color3 animation type
  82576. */
  82577. static readonly ANIMATIONTYPE_COLOR3: number;
  82578. /**
  82579. * Get the Relative Loop Mode
  82580. */
  82581. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  82582. /**
  82583. * Get the Cycle Loop Mode
  82584. */
  82585. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  82586. /**
  82587. * Get the Constant Loop Mode
  82588. */
  82589. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  82590. /** @hidden */
  82591. static _UniversalLerp(left: any, right: any, amount: number): any;
  82592. /**
  82593. * Parses an animation object and creates an animation
  82594. * @param parsedAnimation Parsed animation object
  82595. * @returns Animation object
  82596. */
  82597. static Parse(parsedAnimation: any): Animation;
  82598. /**
  82599. * Appends the serialized animations from the source animations
  82600. * @param source Source containing the animations
  82601. * @param destination Target to store the animations
  82602. */
  82603. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  82604. }
  82605. }
  82606. declare module BABYLON {
  82607. /**
  82608. * Base class of all the textures in babylon.
  82609. * It groups all the common properties the materials, post process, lights... might need
  82610. * in order to make a correct use of the texture.
  82611. */
  82612. export class BaseTexture implements IAnimatable {
  82613. /**
  82614. * Default anisotropic filtering level for the application.
  82615. * It is set to 4 as a good tradeoff between perf and quality.
  82616. */
  82617. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  82618. /**
  82619. * Gets or sets the unique id of the texture
  82620. */
  82621. uniqueId: number;
  82622. /**
  82623. * Define the name of the texture.
  82624. */
  82625. name: string;
  82626. /**
  82627. * Gets or sets an object used to store user defined information.
  82628. */
  82629. metadata: any;
  82630. /**
  82631. * For internal use only. Please do not use.
  82632. */
  82633. reservedDataStore: any;
  82634. private _hasAlpha;
  82635. /**
  82636. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  82637. */
  82638. hasAlpha: boolean;
  82639. /**
  82640. * Defines if the alpha value should be determined via the rgb values.
  82641. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  82642. */
  82643. getAlphaFromRGB: boolean;
  82644. /**
  82645. * Intensity or strength of the texture.
  82646. * It is commonly used by materials to fine tune the intensity of the texture
  82647. */
  82648. level: number;
  82649. /**
  82650. * Define the UV chanel to use starting from 0 and defaulting to 0.
  82651. * This is part of the texture as textures usually maps to one uv set.
  82652. */
  82653. coordinatesIndex: number;
  82654. private _coordinatesMode;
  82655. /**
  82656. * How a texture is mapped.
  82657. *
  82658. * | Value | Type | Description |
  82659. * | ----- | ----------------------------------- | ----------- |
  82660. * | 0 | EXPLICIT_MODE | |
  82661. * | 1 | SPHERICAL_MODE | |
  82662. * | 2 | PLANAR_MODE | |
  82663. * | 3 | CUBIC_MODE | |
  82664. * | 4 | PROJECTION_MODE | |
  82665. * | 5 | SKYBOX_MODE | |
  82666. * | 6 | INVCUBIC_MODE | |
  82667. * | 7 | EQUIRECTANGULAR_MODE | |
  82668. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  82669. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  82670. */
  82671. coordinatesMode: number;
  82672. /**
  82673. * | Value | Type | Description |
  82674. * | ----- | ------------------ | ----------- |
  82675. * | 0 | CLAMP_ADDRESSMODE | |
  82676. * | 1 | WRAP_ADDRESSMODE | |
  82677. * | 2 | MIRROR_ADDRESSMODE | |
  82678. */
  82679. wrapU: number;
  82680. /**
  82681. * | Value | Type | Description |
  82682. * | ----- | ------------------ | ----------- |
  82683. * | 0 | CLAMP_ADDRESSMODE | |
  82684. * | 1 | WRAP_ADDRESSMODE | |
  82685. * | 2 | MIRROR_ADDRESSMODE | |
  82686. */
  82687. wrapV: number;
  82688. /**
  82689. * | Value | Type | Description |
  82690. * | ----- | ------------------ | ----------- |
  82691. * | 0 | CLAMP_ADDRESSMODE | |
  82692. * | 1 | WRAP_ADDRESSMODE | |
  82693. * | 2 | MIRROR_ADDRESSMODE | |
  82694. */
  82695. wrapR: number;
  82696. /**
  82697. * With compliant hardware and browser (supporting anisotropic filtering)
  82698. * this defines the level of anisotropic filtering in the texture.
  82699. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  82700. */
  82701. anisotropicFilteringLevel: number;
  82702. /**
  82703. * Define if the texture is a cube texture or if false a 2d texture.
  82704. */
  82705. isCube: boolean;
  82706. /**
  82707. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  82708. */
  82709. is3D: boolean;
  82710. /**
  82711. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  82712. * HDR texture are usually stored in linear space.
  82713. * This only impacts the PBR and Background materials
  82714. */
  82715. gammaSpace: boolean;
  82716. /**
  82717. * Gets whether or not the texture contains RGBD data.
  82718. */
  82719. readonly isRGBD: boolean;
  82720. /**
  82721. * Is Z inverted in the texture (useful in a cube texture).
  82722. */
  82723. invertZ: boolean;
  82724. /**
  82725. * Are mip maps generated for this texture or not.
  82726. */
  82727. readonly noMipmap: boolean;
  82728. /**
  82729. * @hidden
  82730. */
  82731. lodLevelInAlpha: boolean;
  82732. /**
  82733. * With prefiltered texture, defined the offset used during the prefiltering steps.
  82734. */
  82735. lodGenerationOffset: number;
  82736. /**
  82737. * With prefiltered texture, defined the scale used during the prefiltering steps.
  82738. */
  82739. lodGenerationScale: number;
  82740. /**
  82741. * Define if the texture is a render target.
  82742. */
  82743. isRenderTarget: boolean;
  82744. /**
  82745. * Define the unique id of the texture in the scene.
  82746. */
  82747. readonly uid: string;
  82748. /**
  82749. * Return a string representation of the texture.
  82750. * @returns the texture as a string
  82751. */
  82752. toString(): string;
  82753. /**
  82754. * Get the class name of the texture.
  82755. * @returns "BaseTexture"
  82756. */
  82757. getClassName(): string;
  82758. /**
  82759. * Define the list of animation attached to the texture.
  82760. */
  82761. animations: Animation[];
  82762. /**
  82763. * An event triggered when the texture is disposed.
  82764. */
  82765. onDisposeObservable: Observable<BaseTexture>;
  82766. private _onDisposeObserver;
  82767. /**
  82768. * Callback triggered when the texture has been disposed.
  82769. * Kept for back compatibility, you can use the onDisposeObservable instead.
  82770. */
  82771. onDispose: () => void;
  82772. /**
  82773. * Define the current state of the loading sequence when in delayed load mode.
  82774. */
  82775. delayLoadState: number;
  82776. private _scene;
  82777. /** @hidden */
  82778. _texture: Nullable<InternalTexture>;
  82779. private _uid;
  82780. /**
  82781. * Define if the texture is preventinga material to render or not.
  82782. * If not and the texture is not ready, the engine will use a default black texture instead.
  82783. */
  82784. readonly isBlocking: boolean;
  82785. /**
  82786. * Instantiates a new BaseTexture.
  82787. * Base class of all the textures in babylon.
  82788. * It groups all the common properties the materials, post process, lights... might need
  82789. * in order to make a correct use of the texture.
  82790. * @param scene Define the scene the texture blongs to
  82791. */
  82792. constructor(scene: Nullable<Scene>);
  82793. /**
  82794. * Get the scene the texture belongs to.
  82795. * @returns the scene or null if undefined
  82796. */
  82797. getScene(): Nullable<Scene>;
  82798. /**
  82799. * Get the texture transform matrix used to offset tile the texture for istance.
  82800. * @returns the transformation matrix
  82801. */
  82802. getTextureMatrix(): Matrix;
  82803. /**
  82804. * Get the texture reflection matrix used to rotate/transform the reflection.
  82805. * @returns the reflection matrix
  82806. */
  82807. getReflectionTextureMatrix(): Matrix;
  82808. /**
  82809. * Get the underlying lower level texture from Babylon.
  82810. * @returns the insternal texture
  82811. */
  82812. getInternalTexture(): Nullable<InternalTexture>;
  82813. /**
  82814. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  82815. * @returns true if ready or not blocking
  82816. */
  82817. isReadyOrNotBlocking(): boolean;
  82818. /**
  82819. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  82820. * @returns true if fully ready
  82821. */
  82822. isReady(): boolean;
  82823. private _cachedSize;
  82824. /**
  82825. * Get the size of the texture.
  82826. * @returns the texture size.
  82827. */
  82828. getSize(): ISize;
  82829. /**
  82830. * Get the base size of the texture.
  82831. * It can be different from the size if the texture has been resized for POT for instance
  82832. * @returns the base size
  82833. */
  82834. getBaseSize(): ISize;
  82835. /**
  82836. * Update the sampling mode of the texture.
  82837. * Default is Trilinear mode.
  82838. *
  82839. * | Value | Type | Description |
  82840. * | ----- | ------------------ | ----------- |
  82841. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  82842. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  82843. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  82844. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  82845. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  82846. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  82847. * | 7 | NEAREST_LINEAR | |
  82848. * | 8 | NEAREST_NEAREST | |
  82849. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  82850. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  82851. * | 11 | LINEAR_LINEAR | |
  82852. * | 12 | LINEAR_NEAREST | |
  82853. *
  82854. * > _mag_: magnification filter (close to the viewer)
  82855. * > _min_: minification filter (far from the viewer)
  82856. * > _mip_: filter used between mip map levels
  82857. *@param samplingMode Define the new sampling mode of the texture
  82858. */
  82859. updateSamplingMode(samplingMode: number): void;
  82860. /**
  82861. * Scales the texture if is `canRescale()`
  82862. * @param ratio the resize factor we want to use to rescale
  82863. */
  82864. scale(ratio: number): void;
  82865. /**
  82866. * Get if the texture can rescale.
  82867. */
  82868. readonly canRescale: boolean;
  82869. /** @hidden */
  82870. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  82871. /** @hidden */
  82872. _rebuild(): void;
  82873. /**
  82874. * Triggers the load sequence in delayed load mode.
  82875. */
  82876. delayLoad(): void;
  82877. /**
  82878. * Clones the texture.
  82879. * @returns the cloned texture
  82880. */
  82881. clone(): Nullable<BaseTexture>;
  82882. /**
  82883. * Get the texture underlying type (INT, FLOAT...)
  82884. */
  82885. readonly textureType: number;
  82886. /**
  82887. * Get the texture underlying format (RGB, RGBA...)
  82888. */
  82889. readonly textureFormat: number;
  82890. /**
  82891. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  82892. * This will returns an RGBA array buffer containing either in values (0-255) or
  82893. * float values (0-1) depending of the underlying buffer type.
  82894. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  82895. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  82896. * @param buffer defines a user defined buffer to fill with data (can be null)
  82897. * @returns The Array buffer containing the pixels data.
  82898. */
  82899. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  82900. /**
  82901. * Release and destroy the underlying lower level texture aka internalTexture.
  82902. */
  82903. releaseInternalTexture(): void;
  82904. /**
  82905. * Get the polynomial representation of the texture data.
  82906. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  82907. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  82908. */
  82909. sphericalPolynomial: Nullable<SphericalPolynomial>;
  82910. /** @hidden */
  82911. readonly _lodTextureHigh: Nullable<BaseTexture>;
  82912. /** @hidden */
  82913. readonly _lodTextureMid: Nullable<BaseTexture>;
  82914. /** @hidden */
  82915. readonly _lodTextureLow: Nullable<BaseTexture>;
  82916. /**
  82917. * Dispose the texture and release its associated resources.
  82918. */
  82919. dispose(): void;
  82920. /**
  82921. * Serialize the texture into a JSON representation that can be parsed later on.
  82922. * @returns the JSON representation of the texture
  82923. */
  82924. serialize(): any;
  82925. /**
  82926. * Helper function to be called back once a list of texture contains only ready textures.
  82927. * @param textures Define the list of textures to wait for
  82928. * @param callback Define the callback triggered once the entire list will be ready
  82929. */
  82930. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  82931. }
  82932. }
  82933. declare module BABYLON {
  82934. /**
  82935. * Uniform buffer objects.
  82936. *
  82937. * Handles blocks of uniform on the GPU.
  82938. *
  82939. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  82940. *
  82941. * For more information, please refer to :
  82942. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  82943. */
  82944. export class UniformBuffer {
  82945. private _engine;
  82946. private _buffer;
  82947. private _data;
  82948. private _bufferData;
  82949. private _dynamic?;
  82950. private _uniformLocations;
  82951. private _uniformSizes;
  82952. private _uniformLocationPointer;
  82953. private _needSync;
  82954. private _noUBO;
  82955. private _currentEffect;
  82956. private static _MAX_UNIFORM_SIZE;
  82957. private static _tempBuffer;
  82958. /**
  82959. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  82960. * This is dynamic to allow compat with webgl 1 and 2.
  82961. * You will need to pass the name of the uniform as well as the value.
  82962. */
  82963. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  82964. /**
  82965. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  82966. * This is dynamic to allow compat with webgl 1 and 2.
  82967. * You will need to pass the name of the uniform as well as the value.
  82968. */
  82969. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  82970. /**
  82971. * Lambda to Update a single float in a uniform buffer.
  82972. * This is dynamic to allow compat with webgl 1 and 2.
  82973. * You will need to pass the name of the uniform as well as the value.
  82974. */
  82975. updateFloat: (name: string, x: number) => void;
  82976. /**
  82977. * Lambda to Update a vec2 of float in a uniform buffer.
  82978. * This is dynamic to allow compat with webgl 1 and 2.
  82979. * You will need to pass the name of the uniform as well as the value.
  82980. */
  82981. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  82982. /**
  82983. * Lambda to Update a vec3 of float in a uniform buffer.
  82984. * This is dynamic to allow compat with webgl 1 and 2.
  82985. * You will need to pass the name of the uniform as well as the value.
  82986. */
  82987. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  82988. /**
  82989. * Lambda to Update a vec4 of float in a uniform buffer.
  82990. * This is dynamic to allow compat with webgl 1 and 2.
  82991. * You will need to pass the name of the uniform as well as the value.
  82992. */
  82993. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  82994. /**
  82995. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  82996. * This is dynamic to allow compat with webgl 1 and 2.
  82997. * You will need to pass the name of the uniform as well as the value.
  82998. */
  82999. updateMatrix: (name: string, mat: Matrix) => void;
  83000. /**
  83001. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  83002. * This is dynamic to allow compat with webgl 1 and 2.
  83003. * You will need to pass the name of the uniform as well as the value.
  83004. */
  83005. updateVector3: (name: string, vector: Vector3) => void;
  83006. /**
  83007. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  83008. * This is dynamic to allow compat with webgl 1 and 2.
  83009. * You will need to pass the name of the uniform as well as the value.
  83010. */
  83011. updateVector4: (name: string, vector: Vector4) => void;
  83012. /**
  83013. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  83014. * This is dynamic to allow compat with webgl 1 and 2.
  83015. * You will need to pass the name of the uniform as well as the value.
  83016. */
  83017. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  83018. /**
  83019. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  83020. * This is dynamic to allow compat with webgl 1 and 2.
  83021. * You will need to pass the name of the uniform as well as the value.
  83022. */
  83023. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  83024. /**
  83025. * Instantiates a new Uniform buffer objects.
  83026. *
  83027. * Handles blocks of uniform on the GPU.
  83028. *
  83029. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  83030. *
  83031. * For more information, please refer to :
  83032. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  83033. * @param engine Define the engine the buffer is associated with
  83034. * @param data Define the data contained in the buffer
  83035. * @param dynamic Define if the buffer is updatable
  83036. */
  83037. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  83038. /**
  83039. * Indicates if the buffer is using the WebGL2 UBO implementation,
  83040. * or just falling back on setUniformXXX calls.
  83041. */
  83042. readonly useUbo: boolean;
  83043. /**
  83044. * Indicates if the WebGL underlying uniform buffer is in sync
  83045. * with the javascript cache data.
  83046. */
  83047. readonly isSync: boolean;
  83048. /**
  83049. * Indicates if the WebGL underlying uniform buffer is dynamic.
  83050. * Also, a dynamic UniformBuffer will disable cache verification and always
  83051. * update the underlying WebGL uniform buffer to the GPU.
  83052. * @returns if Dynamic, otherwise false
  83053. */
  83054. isDynamic(): boolean;
  83055. /**
  83056. * The data cache on JS side.
  83057. * @returns the underlying data as a float array
  83058. */
  83059. getData(): Float32Array;
  83060. /**
  83061. * The underlying WebGL Uniform buffer.
  83062. * @returns the webgl buffer
  83063. */
  83064. getBuffer(): Nullable<WebGLBuffer>;
  83065. /**
  83066. * std140 layout specifies how to align data within an UBO structure.
  83067. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  83068. * for specs.
  83069. */
  83070. private _fillAlignment;
  83071. /**
  83072. * Adds an uniform in the buffer.
  83073. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  83074. * for the layout to be correct !
  83075. * @param name Name of the uniform, as used in the uniform block in the shader.
  83076. * @param size Data size, or data directly.
  83077. */
  83078. addUniform(name: string, size: number | number[]): void;
  83079. /**
  83080. * Adds a Matrix 4x4 to the uniform buffer.
  83081. * @param name Name of the uniform, as used in the uniform block in the shader.
  83082. * @param mat A 4x4 matrix.
  83083. */
  83084. addMatrix(name: string, mat: Matrix): void;
  83085. /**
  83086. * Adds a vec2 to the uniform buffer.
  83087. * @param name Name of the uniform, as used in the uniform block in the shader.
  83088. * @param x Define the x component value of the vec2
  83089. * @param y Define the y component value of the vec2
  83090. */
  83091. addFloat2(name: string, x: number, y: number): void;
  83092. /**
  83093. * Adds a vec3 to the uniform buffer.
  83094. * @param name Name of the uniform, as used in the uniform block in the shader.
  83095. * @param x Define the x component value of the vec3
  83096. * @param y Define the y component value of the vec3
  83097. * @param z Define the z component value of the vec3
  83098. */
  83099. addFloat3(name: string, x: number, y: number, z: number): void;
  83100. /**
  83101. * Adds a vec3 to the uniform buffer.
  83102. * @param name Name of the uniform, as used in the uniform block in the shader.
  83103. * @param color Define the vec3 from a Color
  83104. */
  83105. addColor3(name: string, color: Color3): void;
  83106. /**
  83107. * Adds a vec4 to the uniform buffer.
  83108. * @param name Name of the uniform, as used in the uniform block in the shader.
  83109. * @param color Define the rgb components from a Color
  83110. * @param alpha Define the a component of the vec4
  83111. */
  83112. addColor4(name: string, color: Color3, alpha: number): void;
  83113. /**
  83114. * Adds a vec3 to the uniform buffer.
  83115. * @param name Name of the uniform, as used in the uniform block in the shader.
  83116. * @param vector Define the vec3 components from a Vector
  83117. */
  83118. addVector3(name: string, vector: Vector3): void;
  83119. /**
  83120. * Adds a Matrix 3x3 to the uniform buffer.
  83121. * @param name Name of the uniform, as used in the uniform block in the shader.
  83122. */
  83123. addMatrix3x3(name: string): void;
  83124. /**
  83125. * Adds a Matrix 2x2 to the uniform buffer.
  83126. * @param name Name of the uniform, as used in the uniform block in the shader.
  83127. */
  83128. addMatrix2x2(name: string): void;
  83129. /**
  83130. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  83131. */
  83132. create(): void;
  83133. /** @hidden */
  83134. _rebuild(): void;
  83135. /**
  83136. * Updates the WebGL Uniform Buffer on the GPU.
  83137. * If the `dynamic` flag is set to true, no cache comparison is done.
  83138. * Otherwise, the buffer will be updated only if the cache differs.
  83139. */
  83140. update(): void;
  83141. /**
  83142. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  83143. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  83144. * @param data Define the flattened data
  83145. * @param size Define the size of the data.
  83146. */
  83147. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  83148. private _updateMatrix3x3ForUniform;
  83149. private _updateMatrix3x3ForEffect;
  83150. private _updateMatrix2x2ForEffect;
  83151. private _updateMatrix2x2ForUniform;
  83152. private _updateFloatForEffect;
  83153. private _updateFloatForUniform;
  83154. private _updateFloat2ForEffect;
  83155. private _updateFloat2ForUniform;
  83156. private _updateFloat3ForEffect;
  83157. private _updateFloat3ForUniform;
  83158. private _updateFloat4ForEffect;
  83159. private _updateFloat4ForUniform;
  83160. private _updateMatrixForEffect;
  83161. private _updateMatrixForUniform;
  83162. private _updateVector3ForEffect;
  83163. private _updateVector3ForUniform;
  83164. private _updateVector4ForEffect;
  83165. private _updateVector4ForUniform;
  83166. private _updateColor3ForEffect;
  83167. private _updateColor3ForUniform;
  83168. private _updateColor4ForEffect;
  83169. private _updateColor4ForUniform;
  83170. /**
  83171. * Sets a sampler uniform on the effect.
  83172. * @param name Define the name of the sampler.
  83173. * @param texture Define the texture to set in the sampler
  83174. */
  83175. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  83176. /**
  83177. * Directly updates the value of the uniform in the cache AND on the GPU.
  83178. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  83179. * @param data Define the flattened data
  83180. */
  83181. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  83182. /**
  83183. * Binds this uniform buffer to an effect.
  83184. * @param effect Define the effect to bind the buffer to
  83185. * @param name Name of the uniform block in the shader.
  83186. */
  83187. bindToEffect(effect: Effect, name: string): void;
  83188. /**
  83189. * Disposes the uniform buffer.
  83190. */
  83191. dispose(): void;
  83192. }
  83193. }
  83194. declare module BABYLON {
  83195. /**
  83196. * This represents the required contract to create a new type of texture loader.
  83197. */
  83198. export interface IInternalTextureLoader {
  83199. /**
  83200. * Defines wether the loader supports cascade loading the different faces.
  83201. */
  83202. supportCascades: boolean;
  83203. /**
  83204. * This returns if the loader support the current file information.
  83205. * @param extension defines the file extension of the file being loaded
  83206. * @param textureFormatInUse defines the current compressed format in use iun the engine
  83207. * @param fallback defines the fallback internal texture if any
  83208. * @param isBase64 defines whether the texture is encoded as a base64
  83209. * @param isBuffer defines whether the texture data are stored as a buffer
  83210. * @returns true if the loader can load the specified file
  83211. */
  83212. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  83213. /**
  83214. * Transform the url before loading if required.
  83215. * @param rootUrl the url of the texture
  83216. * @param textureFormatInUse defines the current compressed format in use iun the engine
  83217. * @returns the transformed texture
  83218. */
  83219. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  83220. /**
  83221. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  83222. * @param rootUrl the url of the texture
  83223. * @param textureFormatInUse defines the current compressed format in use iun the engine
  83224. * @returns the fallback texture
  83225. */
  83226. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  83227. /**
  83228. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  83229. * @param data contains the texture data
  83230. * @param texture defines the BabylonJS internal texture
  83231. * @param createPolynomials will be true if polynomials have been requested
  83232. * @param onLoad defines the callback to trigger once the texture is ready
  83233. * @param onError defines the callback to trigger in case of error
  83234. */
  83235. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  83236. /**
  83237. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  83238. * @param data contains the texture data
  83239. * @param texture defines the BabylonJS internal texture
  83240. * @param callback defines the method to call once ready to upload
  83241. */
  83242. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  83243. }
  83244. }
  83245. declare module BABYLON {
  83246. /**
  83247. * Creation options of the multi render target texture.
  83248. */
  83249. export interface IMultiRenderTargetOptions {
  83250. /**
  83251. * Define if the texture needs to create mip maps after render.
  83252. */
  83253. generateMipMaps?: boolean;
  83254. /**
  83255. * Define the types of all the draw buffers we want to create
  83256. */
  83257. types?: number[];
  83258. /**
  83259. * Define the sampling modes of all the draw buffers we want to create
  83260. */
  83261. samplingModes?: number[];
  83262. /**
  83263. * Define if a depth buffer is required
  83264. */
  83265. generateDepthBuffer?: boolean;
  83266. /**
  83267. * Define if a stencil buffer is required
  83268. */
  83269. generateStencilBuffer?: boolean;
  83270. /**
  83271. * Define if a depth texture is required instead of a depth buffer
  83272. */
  83273. generateDepthTexture?: boolean;
  83274. /**
  83275. * Define the number of desired draw buffers
  83276. */
  83277. textureCount?: number;
  83278. /**
  83279. * Define if aspect ratio should be adapted to the texture or stay the scene one
  83280. */
  83281. doNotChangeAspectRatio?: boolean;
  83282. /**
  83283. * Define the default type of the buffers we are creating
  83284. */
  83285. defaultType?: number;
  83286. }
  83287. /**
  83288. * A multi render target, like a render target provides the ability to render to a texture.
  83289. * Unlike the render target, it can render to several draw buffers in one draw.
  83290. * This is specially interesting in deferred rendering or for any effects requiring more than
  83291. * just one color from a single pass.
  83292. */
  83293. export class MultiRenderTarget extends RenderTargetTexture {
  83294. private _internalTextures;
  83295. private _textures;
  83296. private _multiRenderTargetOptions;
  83297. /**
  83298. * Get if draw buffers are currently supported by the used hardware and browser.
  83299. */
  83300. readonly isSupported: boolean;
  83301. /**
  83302. * Get the list of textures generated by the multi render target.
  83303. */
  83304. readonly textures: Texture[];
  83305. /**
  83306. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  83307. */
  83308. readonly depthTexture: Texture;
  83309. /**
  83310. * Set the wrapping mode on U of all the textures we are rendering to.
  83311. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  83312. */
  83313. wrapU: number;
  83314. /**
  83315. * Set the wrapping mode on V of all the textures we are rendering to.
  83316. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  83317. */
  83318. wrapV: number;
  83319. /**
  83320. * Instantiate a new multi render target texture.
  83321. * A multi render target, like a render target provides the ability to render to a texture.
  83322. * Unlike the render target, it can render to several draw buffers in one draw.
  83323. * This is specially interesting in deferred rendering or for any effects requiring more than
  83324. * just one color from a single pass.
  83325. * @param name Define the name of the texture
  83326. * @param size Define the size of the buffers to render to
  83327. * @param count Define the number of target we are rendering into
  83328. * @param scene Define the scene the texture belongs to
  83329. * @param options Define the options used to create the multi render target
  83330. */
  83331. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  83332. /** @hidden */
  83333. _rebuild(): void;
  83334. private _createInternalTextures;
  83335. private _createTextures;
  83336. /**
  83337. * Define the number of samples used if MSAA is enabled.
  83338. */
  83339. samples: number;
  83340. /**
  83341. * Resize all the textures in the multi render target.
  83342. * Be carrefull as it will recreate all the data in the new texture.
  83343. * @param size Define the new size
  83344. */
  83345. resize(size: any): void;
  83346. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  83347. /**
  83348. * Dispose the render targets and their associated resources
  83349. */
  83350. dispose(): void;
  83351. /**
  83352. * Release all the underlying texture used as draw buffers.
  83353. */
  83354. releaseInternalTextures(): void;
  83355. }
  83356. }
  83357. declare module BABYLON {
  83358. /**
  83359. * Class used to work with sound analyzer using fast fourier transform (FFT)
  83360. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  83361. */
  83362. export class Analyser {
  83363. /**
  83364. * Gets or sets the smoothing
  83365. * @ignorenaming
  83366. */
  83367. SMOOTHING: number;
  83368. /**
  83369. * Gets or sets the FFT table size
  83370. * @ignorenaming
  83371. */
  83372. FFT_SIZE: number;
  83373. /**
  83374. * Gets or sets the bar graph amplitude
  83375. * @ignorenaming
  83376. */
  83377. BARGRAPHAMPLITUDE: number;
  83378. /**
  83379. * Gets or sets the position of the debug canvas
  83380. * @ignorenaming
  83381. */
  83382. DEBUGCANVASPOS: {
  83383. x: number;
  83384. y: number;
  83385. };
  83386. /**
  83387. * Gets or sets the debug canvas size
  83388. * @ignorenaming
  83389. */
  83390. DEBUGCANVASSIZE: {
  83391. width: number;
  83392. height: number;
  83393. };
  83394. private _byteFreqs;
  83395. private _byteTime;
  83396. private _floatFreqs;
  83397. private _webAudioAnalyser;
  83398. private _debugCanvas;
  83399. private _debugCanvasContext;
  83400. private _scene;
  83401. private _registerFunc;
  83402. private _audioEngine;
  83403. /**
  83404. * Creates a new analyser
  83405. * @param scene defines hosting scene
  83406. */
  83407. constructor(scene: Scene);
  83408. /**
  83409. * Get the number of data values you will have to play with for the visualization
  83410. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  83411. * @returns a number
  83412. */
  83413. getFrequencyBinCount(): number;
  83414. /**
  83415. * Gets the current frequency data as a byte array
  83416. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  83417. * @returns a Uint8Array
  83418. */
  83419. getByteFrequencyData(): Uint8Array;
  83420. /**
  83421. * Gets the current waveform as a byte array
  83422. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  83423. * @returns a Uint8Array
  83424. */
  83425. getByteTimeDomainData(): Uint8Array;
  83426. /**
  83427. * Gets the current frequency data as a float array
  83428. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  83429. * @returns a Float32Array
  83430. */
  83431. getFloatFrequencyData(): Float32Array;
  83432. /**
  83433. * Renders the debug canvas
  83434. */
  83435. drawDebugCanvas(): void;
  83436. /**
  83437. * Stops rendering the debug canvas and removes it
  83438. */
  83439. stopDebugCanvas(): void;
  83440. /**
  83441. * Connects two audio nodes
  83442. * @param inputAudioNode defines first node to connect
  83443. * @param outputAudioNode defines second node to connect
  83444. */
  83445. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  83446. /**
  83447. * Releases all associated resources
  83448. */
  83449. dispose(): void;
  83450. }
  83451. }
  83452. declare module BABYLON {
  83453. /**
  83454. * This represents an audio engine and it is responsible
  83455. * to play, synchronize and analyse sounds throughout the application.
  83456. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  83457. */
  83458. export interface IAudioEngine extends IDisposable {
  83459. /**
  83460. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  83461. */
  83462. readonly canUseWebAudio: boolean;
  83463. /**
  83464. * Gets the current AudioContext if available.
  83465. */
  83466. readonly audioContext: Nullable<AudioContext>;
  83467. /**
  83468. * The master gain node defines the global audio volume of your audio engine.
  83469. */
  83470. readonly masterGain: GainNode;
  83471. /**
  83472. * Gets whether or not mp3 are supported by your browser.
  83473. */
  83474. readonly isMP3supported: boolean;
  83475. /**
  83476. * Gets whether or not ogg are supported by your browser.
  83477. */
  83478. readonly isOGGsupported: boolean;
  83479. /**
  83480. * Defines if Babylon should emit a warning if WebAudio is not supported.
  83481. * @ignoreNaming
  83482. */
  83483. WarnedWebAudioUnsupported: boolean;
  83484. /**
  83485. * Defines if the audio engine relies on a custom unlocked button.
  83486. * In this case, the embedded button will not be displayed.
  83487. */
  83488. useCustomUnlockedButton: boolean;
  83489. /**
  83490. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  83491. */
  83492. readonly unlocked: boolean;
  83493. /**
  83494. * Event raised when audio has been unlocked on the browser.
  83495. */
  83496. onAudioUnlockedObservable: Observable<AudioEngine>;
  83497. /**
  83498. * Event raised when audio has been locked on the browser.
  83499. */
  83500. onAudioLockedObservable: Observable<AudioEngine>;
  83501. /**
  83502. * Flags the audio engine in Locked state.
  83503. * This happens due to new browser policies preventing audio to autoplay.
  83504. */
  83505. lock(): void;
  83506. /**
  83507. * Unlocks the audio engine once a user action has been done on the dom.
  83508. * This is helpful to resume play once browser policies have been satisfied.
  83509. */
  83510. unlock(): void;
  83511. }
  83512. /**
  83513. * This represents the default audio engine used in babylon.
  83514. * It is responsible to play, synchronize and analyse sounds throughout the application.
  83515. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  83516. */
  83517. export class AudioEngine implements IAudioEngine {
  83518. private _audioContext;
  83519. private _audioContextInitialized;
  83520. private _muteButton;
  83521. private _hostElement;
  83522. /**
  83523. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  83524. */
  83525. canUseWebAudio: boolean;
  83526. /**
  83527. * The master gain node defines the global audio volume of your audio engine.
  83528. */
  83529. masterGain: GainNode;
  83530. /**
  83531. * Defines if Babylon should emit a warning if WebAudio is not supported.
  83532. * @ignoreNaming
  83533. */
  83534. WarnedWebAudioUnsupported: boolean;
  83535. /**
  83536. * Gets whether or not mp3 are supported by your browser.
  83537. */
  83538. isMP3supported: boolean;
  83539. /**
  83540. * Gets whether or not ogg are supported by your browser.
  83541. */
  83542. isOGGsupported: boolean;
  83543. /**
  83544. * Gets whether audio has been unlocked on the device.
  83545. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  83546. * a user interaction has happened.
  83547. */
  83548. unlocked: boolean;
  83549. /**
  83550. * Defines if the audio engine relies on a custom unlocked button.
  83551. * In this case, the embedded button will not be displayed.
  83552. */
  83553. useCustomUnlockedButton: boolean;
  83554. /**
  83555. * Event raised when audio has been unlocked on the browser.
  83556. */
  83557. onAudioUnlockedObservable: Observable<AudioEngine>;
  83558. /**
  83559. * Event raised when audio has been locked on the browser.
  83560. */
  83561. onAudioLockedObservable: Observable<AudioEngine>;
  83562. /**
  83563. * Gets the current AudioContext if available.
  83564. */
  83565. readonly audioContext: Nullable<AudioContext>;
  83566. private _connectedAnalyser;
  83567. /**
  83568. * Instantiates a new audio engine.
  83569. *
  83570. * There should be only one per page as some browsers restrict the number
  83571. * of audio contexts you can create.
  83572. * @param hostElement defines the host element where to display the mute icon if necessary
  83573. */
  83574. constructor(hostElement?: Nullable<HTMLElement>);
  83575. /**
  83576. * Flags the audio engine in Locked state.
  83577. * This happens due to new browser policies preventing audio to autoplay.
  83578. */
  83579. lock(): void;
  83580. /**
  83581. * Unlocks the audio engine once a user action has been done on the dom.
  83582. * This is helpful to resume play once browser policies have been satisfied.
  83583. */
  83584. unlock(): void;
  83585. private _resumeAudioContext;
  83586. private _initializeAudioContext;
  83587. private _tryToRun;
  83588. private _triggerRunningState;
  83589. private _triggerSuspendedState;
  83590. private _displayMuteButton;
  83591. private _moveButtonToTopLeft;
  83592. private _onResize;
  83593. private _hideMuteButton;
  83594. /**
  83595. * Destroy and release the resources associated with the audio ccontext.
  83596. */
  83597. dispose(): void;
  83598. /**
  83599. * Gets the global volume sets on the master gain.
  83600. * @returns the global volume if set or -1 otherwise
  83601. */
  83602. getGlobalVolume(): number;
  83603. /**
  83604. * Sets the global volume of your experience (sets on the master gain).
  83605. * @param newVolume Defines the new global volume of the application
  83606. */
  83607. setGlobalVolume(newVolume: number): void;
  83608. /**
  83609. * Connect the audio engine to an audio analyser allowing some amazing
  83610. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  83611. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  83612. * @param analyser The analyser to connect to the engine
  83613. */
  83614. connectToAnalyser(analyser: Analyser): void;
  83615. }
  83616. }
  83617. declare module BABYLON {
  83618. /**
  83619. * Interface used to present a loading screen while loading a scene
  83620. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  83621. */
  83622. export interface ILoadingScreen {
  83623. /**
  83624. * Function called to display the loading screen
  83625. */
  83626. displayLoadingUI: () => void;
  83627. /**
  83628. * Function called to hide the loading screen
  83629. */
  83630. hideLoadingUI: () => void;
  83631. /**
  83632. * Gets or sets the color to use for the background
  83633. */
  83634. loadingUIBackgroundColor: string;
  83635. /**
  83636. * Gets or sets the text to display while loading
  83637. */
  83638. loadingUIText: string;
  83639. }
  83640. /**
  83641. * Class used for the default loading screen
  83642. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  83643. */
  83644. export class DefaultLoadingScreen implements ILoadingScreen {
  83645. private _renderingCanvas;
  83646. private _loadingText;
  83647. private _loadingDivBackgroundColor;
  83648. private _loadingDiv;
  83649. private _loadingTextDiv;
  83650. /**
  83651. * Creates a new default loading screen
  83652. * @param _renderingCanvas defines the canvas used to render the scene
  83653. * @param _loadingText defines the default text to display
  83654. * @param _loadingDivBackgroundColor defines the default background color
  83655. */
  83656. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  83657. /**
  83658. * Function called to display the loading screen
  83659. */
  83660. displayLoadingUI(): void;
  83661. /**
  83662. * Function called to hide the loading screen
  83663. */
  83664. hideLoadingUI(): void;
  83665. /**
  83666. * Gets or sets the text to display while loading
  83667. */
  83668. loadingUIText: string;
  83669. /**
  83670. * Gets or sets the color to use for the background
  83671. */
  83672. loadingUIBackgroundColor: string;
  83673. private _resizeLoadingUI;
  83674. }
  83675. }
  83676. declare module BABYLON {
  83677. /**
  83678. * Settings for finer control over video usage
  83679. */
  83680. export interface VideoTextureSettings {
  83681. /**
  83682. * Applies `autoplay` to video, if specified
  83683. */
  83684. autoPlay?: boolean;
  83685. /**
  83686. * Applies `loop` to video, if specified
  83687. */
  83688. loop?: boolean;
  83689. /**
  83690. * Automatically updates internal texture from video at every frame in the render loop
  83691. */
  83692. autoUpdateTexture: boolean;
  83693. /**
  83694. * Image src displayed during the video loading or until the user interacts with the video.
  83695. */
  83696. poster?: string;
  83697. }
  83698. /**
  83699. * If you want to display a video in your scene, this is the special texture for that.
  83700. * This special texture works similar to other textures, with the exception of a few parameters.
  83701. * @see https://doc.babylonjs.com/how_to/video_texture
  83702. */
  83703. export class VideoTexture extends Texture {
  83704. /**
  83705. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  83706. */
  83707. readonly autoUpdateTexture: boolean;
  83708. /**
  83709. * The video instance used by the texture internally
  83710. */
  83711. readonly video: HTMLVideoElement;
  83712. private _onUserActionRequestedObservable;
  83713. /**
  83714. * Event triggerd when a dom action is required by the user to play the video.
  83715. * This happens due to recent changes in browser policies preventing video to auto start.
  83716. */
  83717. readonly onUserActionRequestedObservable: Observable<Texture>;
  83718. private _generateMipMaps;
  83719. private _engine;
  83720. private _stillImageCaptured;
  83721. private _displayingPosterTexture;
  83722. private _settings;
  83723. private _createInternalTextureOnEvent;
  83724. /**
  83725. * Creates a video texture.
  83726. * If you want to display a video in your scene, this is the special texture for that.
  83727. * This special texture works similar to other textures, with the exception of a few parameters.
  83728. * @see https://doc.babylonjs.com/how_to/video_texture
  83729. * @param name optional name, will detect from video source, if not defined
  83730. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  83731. * @param scene is obviously the current scene.
  83732. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  83733. * @param invertY is false by default but can be used to invert video on Y axis
  83734. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  83735. * @param settings allows finer control over video usage
  83736. */
  83737. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  83738. private _getName;
  83739. private _getVideo;
  83740. private _createInternalTexture;
  83741. private reset;
  83742. /**
  83743. * @hidden Internal method to initiate `update`.
  83744. */
  83745. _rebuild(): void;
  83746. /**
  83747. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  83748. */
  83749. update(): void;
  83750. /**
  83751. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  83752. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  83753. */
  83754. updateTexture(isVisible: boolean): void;
  83755. protected _updateInternalTexture: () => void;
  83756. /**
  83757. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  83758. * @param url New url.
  83759. */
  83760. updateURL(url: string): void;
  83761. /**
  83762. * Dispose the texture and release its associated resources.
  83763. */
  83764. dispose(): void;
  83765. /**
  83766. * Creates a video texture straight from a stream.
  83767. * @param scene Define the scene the texture should be created in
  83768. * @param stream Define the stream the texture should be created from
  83769. * @returns The created video texture as a promise
  83770. */
  83771. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  83772. /**
  83773. * Creates a video texture straight from your WebCam video feed.
  83774. * @param scene Define the scene the texture should be created in
  83775. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  83776. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  83777. * @returns The created video texture as a promise
  83778. */
  83779. static CreateFromWebCamAsync(scene: Scene, constraints: {
  83780. minWidth: number;
  83781. maxWidth: number;
  83782. minHeight: number;
  83783. maxHeight: number;
  83784. deviceId: string;
  83785. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  83786. /**
  83787. * Creates a video texture straight from your WebCam video feed.
  83788. * @param scene Define the scene the texture should be created in
  83789. * @param onReady Define a callback to triggered once the texture will be ready
  83790. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  83791. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  83792. */
  83793. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  83794. minWidth: number;
  83795. maxWidth: number;
  83796. minHeight: number;
  83797. maxHeight: number;
  83798. deviceId: string;
  83799. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  83800. }
  83801. }
  83802. declare module BABYLON {
  83803. /**
  83804. * Interface for attribute information associated with buffer instanciation
  83805. */
  83806. export class InstancingAttributeInfo {
  83807. /**
  83808. * Index/offset of the attribute in the vertex shader
  83809. */
  83810. index: number;
  83811. /**
  83812. * size of the attribute, 1, 2, 3 or 4
  83813. */
  83814. attributeSize: number;
  83815. /**
  83816. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  83817. * default is FLOAT
  83818. */
  83819. attribyteType: number;
  83820. /**
  83821. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  83822. */
  83823. normalized: boolean;
  83824. /**
  83825. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  83826. */
  83827. offset: number;
  83828. /**
  83829. * Name of the GLSL attribute, for debugging purpose only
  83830. */
  83831. attributeName: string;
  83832. }
  83833. /**
  83834. * Define options used to create a depth texture
  83835. */
  83836. export class DepthTextureCreationOptions {
  83837. /** Specifies whether or not a stencil should be allocated in the texture */
  83838. generateStencil?: boolean;
  83839. /** Specifies whether or not bilinear filtering is enable on the texture */
  83840. bilinearFiltering?: boolean;
  83841. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  83842. comparisonFunction?: number;
  83843. /** Specifies if the created texture is a cube texture */
  83844. isCube?: boolean;
  83845. }
  83846. /**
  83847. * Class used to describe the capabilities of the engine relatively to the current browser
  83848. */
  83849. export class EngineCapabilities {
  83850. /** Maximum textures units per fragment shader */
  83851. maxTexturesImageUnits: number;
  83852. /** Maximum texture units per vertex shader */
  83853. maxVertexTextureImageUnits: number;
  83854. /** Maximum textures units in the entire pipeline */
  83855. maxCombinedTexturesImageUnits: number;
  83856. /** Maximum texture size */
  83857. maxTextureSize: number;
  83858. /** Maximum cube texture size */
  83859. maxCubemapTextureSize: number;
  83860. /** Maximum render texture size */
  83861. maxRenderTextureSize: number;
  83862. /** Maximum number of vertex attributes */
  83863. maxVertexAttribs: number;
  83864. /** Maximum number of varyings */
  83865. maxVaryingVectors: number;
  83866. /** Maximum number of uniforms per vertex shader */
  83867. maxVertexUniformVectors: number;
  83868. /** Maximum number of uniforms per fragment shader */
  83869. maxFragmentUniformVectors: number;
  83870. /** Defines if standard derivates (dx/dy) are supported */
  83871. standardDerivatives: boolean;
  83872. /** Defines if s3tc texture compression is supported */
  83873. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  83874. /** Defines if pvrtc texture compression is supported */
  83875. pvrtc: any;
  83876. /** Defines if etc1 texture compression is supported */
  83877. etc1: any;
  83878. /** Defines if etc2 texture compression is supported */
  83879. etc2: any;
  83880. /** Defines if astc texture compression is supported */
  83881. astc: any;
  83882. /** Defines if float textures are supported */
  83883. textureFloat: boolean;
  83884. /** Defines if vertex array objects are supported */
  83885. vertexArrayObject: boolean;
  83886. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  83887. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  83888. /** Gets the maximum level of anisotropy supported */
  83889. maxAnisotropy: number;
  83890. /** Defines if instancing is supported */
  83891. instancedArrays: boolean;
  83892. /** Defines if 32 bits indices are supported */
  83893. uintIndices: boolean;
  83894. /** Defines if high precision shaders are supported */
  83895. highPrecisionShaderSupported: boolean;
  83896. /** Defines if depth reading in the fragment shader is supported */
  83897. fragmentDepthSupported: boolean;
  83898. /** Defines if float texture linear filtering is supported*/
  83899. textureFloatLinearFiltering: boolean;
  83900. /** Defines if rendering to float textures is supported */
  83901. textureFloatRender: boolean;
  83902. /** Defines if half float textures are supported*/
  83903. textureHalfFloat: boolean;
  83904. /** Defines if half float texture linear filtering is supported*/
  83905. textureHalfFloatLinearFiltering: boolean;
  83906. /** Defines if rendering to half float textures is supported */
  83907. textureHalfFloatRender: boolean;
  83908. /** Defines if textureLOD shader command is supported */
  83909. textureLOD: boolean;
  83910. /** Defines if draw buffers extension is supported */
  83911. drawBuffersExtension: boolean;
  83912. /** Defines if depth textures are supported */
  83913. depthTextureExtension: boolean;
  83914. /** Defines if float color buffer are supported */
  83915. colorBufferFloat: boolean;
  83916. /** Gets disjoint timer query extension (null if not supported) */
  83917. timerQuery: EXT_disjoint_timer_query;
  83918. /** Defines if timestamp can be used with timer query */
  83919. canUseTimestampForTimerQuery: boolean;
  83920. /** Function used to let the system compiles shaders in background */
  83921. parallelShaderCompile: {
  83922. MAX_SHADER_COMPILER_THREADS_KHR: number;
  83923. maxShaderCompilerThreadsKHR: (thread: number) => void;
  83924. COMPLETION_STATUS_KHR: number;
  83925. };
  83926. }
  83927. /** Interface defining initialization parameters for Engine class */
  83928. export interface EngineOptions extends WebGLContextAttributes {
  83929. /**
  83930. * Defines if the engine should no exceed a specified device ratio
  83931. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  83932. */
  83933. limitDeviceRatio?: number;
  83934. /**
  83935. * Defines if webvr should be enabled automatically
  83936. * @see http://doc.babylonjs.com/how_to/webvr_camera
  83937. */
  83938. autoEnableWebVR?: boolean;
  83939. /**
  83940. * Defines if webgl2 should be turned off even if supported
  83941. * @see http://doc.babylonjs.com/features/webgl2
  83942. */
  83943. disableWebGL2Support?: boolean;
  83944. /**
  83945. * Defines if webaudio should be initialized as well
  83946. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  83947. */
  83948. audioEngine?: boolean;
  83949. /**
  83950. * Defines if animations should run using a deterministic lock step
  83951. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  83952. */
  83953. deterministicLockstep?: boolean;
  83954. /** Defines the maximum steps to use with deterministic lock step mode */
  83955. lockstepMaxSteps?: number;
  83956. /**
  83957. * Defines that engine should ignore context lost events
  83958. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  83959. */
  83960. doNotHandleContextLost?: boolean;
  83961. /**
  83962. * Defines that engine should ignore modifying touch action attribute and style
  83963. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  83964. */
  83965. doNotHandleTouchAction?: boolean;
  83966. }
  83967. /**
  83968. * Defines the interface used by display changed events
  83969. */
  83970. export interface IDisplayChangedEventArgs {
  83971. /** Gets the vrDisplay object (if any) */
  83972. vrDisplay: Nullable<any>;
  83973. /** Gets a boolean indicating if webVR is supported */
  83974. vrSupported: boolean;
  83975. }
  83976. /**
  83977. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  83978. */
  83979. export class Engine {
  83980. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  83981. static ExceptionList: ({
  83982. key: string;
  83983. capture: string;
  83984. captureConstraint: number;
  83985. targets: string[];
  83986. } | {
  83987. key: string;
  83988. capture: null;
  83989. captureConstraint: null;
  83990. targets: string[];
  83991. })[];
  83992. /** Gets the list of created engines */
  83993. static readonly Instances: Engine[];
  83994. /**
  83995. * Gets the latest created engine
  83996. */
  83997. static readonly LastCreatedEngine: Nullable<Engine>;
  83998. /**
  83999. * Gets the latest created scene
  84000. */
  84001. static readonly LastCreatedScene: Nullable<Scene>;
  84002. /**
  84003. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  84004. * @param flag defines which part of the materials must be marked as dirty
  84005. * @param predicate defines a predicate used to filter which materials should be affected
  84006. */
  84007. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  84008. /**
  84009. * Hidden
  84010. */
  84011. static _TextureLoaders: IInternalTextureLoader[];
  84012. /** Defines that alpha blending is disabled */
  84013. static readonly ALPHA_DISABLE: number;
  84014. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  84015. static readonly ALPHA_ADD: number;
  84016. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  84017. static readonly ALPHA_COMBINE: number;
  84018. /** Defines that alpha blending to DEST - SRC * DEST */
  84019. static readonly ALPHA_SUBTRACT: number;
  84020. /** Defines that alpha blending to SRC * DEST */
  84021. static readonly ALPHA_MULTIPLY: number;
  84022. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  84023. static readonly ALPHA_MAXIMIZED: number;
  84024. /** Defines that alpha blending to SRC + DEST */
  84025. static readonly ALPHA_ONEONE: number;
  84026. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  84027. static readonly ALPHA_PREMULTIPLIED: number;
  84028. /**
  84029. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  84030. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  84031. */
  84032. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  84033. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  84034. static readonly ALPHA_INTERPOLATE: number;
  84035. /**
  84036. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  84037. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  84038. */
  84039. static readonly ALPHA_SCREENMODE: number;
  84040. /** Defines that the ressource is not delayed*/
  84041. static readonly DELAYLOADSTATE_NONE: number;
  84042. /** Defines that the ressource was successfully delay loaded */
  84043. static readonly DELAYLOADSTATE_LOADED: number;
  84044. /** Defines that the ressource is currently delay loading */
  84045. static readonly DELAYLOADSTATE_LOADING: number;
  84046. /** Defines that the ressource is delayed and has not started loading */
  84047. static readonly DELAYLOADSTATE_NOTLOADED: number;
  84048. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  84049. static readonly NEVER: number;
  84050. /** 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 */
  84051. static readonly ALWAYS: number;
  84052. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  84053. static readonly LESS: number;
  84054. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  84055. static readonly EQUAL: number;
  84056. /** 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 */
  84057. static readonly LEQUAL: number;
  84058. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  84059. static readonly GREATER: number;
  84060. /** 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 */
  84061. static readonly GEQUAL: number;
  84062. /** 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 */
  84063. static readonly NOTEQUAL: number;
  84064. /** Passed to stencilOperation to specify that stencil value must be kept */
  84065. static readonly KEEP: number;
  84066. /** Passed to stencilOperation to specify that stencil value must be replaced */
  84067. static readonly REPLACE: number;
  84068. /** Passed to stencilOperation to specify that stencil value must be incremented */
  84069. static readonly INCR: number;
  84070. /** Passed to stencilOperation to specify that stencil value must be decremented */
  84071. static readonly DECR: number;
  84072. /** Passed to stencilOperation to specify that stencil value must be inverted */
  84073. static readonly INVERT: number;
  84074. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  84075. static readonly INCR_WRAP: number;
  84076. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  84077. static readonly DECR_WRAP: number;
  84078. /** Texture is not repeating outside of 0..1 UVs */
  84079. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  84080. /** Texture is repeating outside of 0..1 UVs */
  84081. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  84082. /** Texture is repeating and mirrored */
  84083. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  84084. /** ALPHA */
  84085. static readonly TEXTUREFORMAT_ALPHA: number;
  84086. /** LUMINANCE */
  84087. static readonly TEXTUREFORMAT_LUMINANCE: number;
  84088. /** LUMINANCE_ALPHA */
  84089. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  84090. /** RGB */
  84091. static readonly TEXTUREFORMAT_RGB: number;
  84092. /** RGBA */
  84093. static readonly TEXTUREFORMAT_RGBA: number;
  84094. /** RED */
  84095. static readonly TEXTUREFORMAT_RED: number;
  84096. /** RED (2nd reference) */
  84097. static readonly TEXTUREFORMAT_R: number;
  84098. /** RG */
  84099. static readonly TEXTUREFORMAT_RG: number;
  84100. /** RED_INTEGER */
  84101. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  84102. /** RED_INTEGER (2nd reference) */
  84103. static readonly TEXTUREFORMAT_R_INTEGER: number;
  84104. /** RG_INTEGER */
  84105. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  84106. /** RGB_INTEGER */
  84107. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  84108. /** RGBA_INTEGER */
  84109. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  84110. /** UNSIGNED_BYTE */
  84111. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  84112. /** UNSIGNED_BYTE (2nd reference) */
  84113. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  84114. /** FLOAT */
  84115. static readonly TEXTURETYPE_FLOAT: number;
  84116. /** HALF_FLOAT */
  84117. static readonly TEXTURETYPE_HALF_FLOAT: number;
  84118. /** BYTE */
  84119. static readonly TEXTURETYPE_BYTE: number;
  84120. /** SHORT */
  84121. static readonly TEXTURETYPE_SHORT: number;
  84122. /** UNSIGNED_SHORT */
  84123. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  84124. /** INT */
  84125. static readonly TEXTURETYPE_INT: number;
  84126. /** UNSIGNED_INT */
  84127. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  84128. /** UNSIGNED_SHORT_4_4_4_4 */
  84129. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  84130. /** UNSIGNED_SHORT_5_5_5_1 */
  84131. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  84132. /** UNSIGNED_SHORT_5_6_5 */
  84133. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  84134. /** UNSIGNED_INT_2_10_10_10_REV */
  84135. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  84136. /** UNSIGNED_INT_24_8 */
  84137. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  84138. /** UNSIGNED_INT_10F_11F_11F_REV */
  84139. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  84140. /** UNSIGNED_INT_5_9_9_9_REV */
  84141. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  84142. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  84143. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  84144. /** nearest is mag = nearest and min = nearest and mip = linear */
  84145. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  84146. /** Bilinear is mag = linear and min = linear and mip = nearest */
  84147. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  84148. /** Trilinear is mag = linear and min = linear and mip = linear */
  84149. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  84150. /** nearest is mag = nearest and min = nearest and mip = linear */
  84151. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  84152. /** Bilinear is mag = linear and min = linear and mip = nearest */
  84153. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  84154. /** Trilinear is mag = linear and min = linear and mip = linear */
  84155. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  84156. /** mag = nearest and min = nearest and mip = nearest */
  84157. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  84158. /** mag = nearest and min = linear and mip = nearest */
  84159. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  84160. /** mag = nearest and min = linear and mip = linear */
  84161. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  84162. /** mag = nearest and min = linear and mip = none */
  84163. static readonly TEXTURE_NEAREST_LINEAR: number;
  84164. /** mag = nearest and min = nearest and mip = none */
  84165. static readonly TEXTURE_NEAREST_NEAREST: number;
  84166. /** mag = linear and min = nearest and mip = nearest */
  84167. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  84168. /** mag = linear and min = nearest and mip = linear */
  84169. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  84170. /** mag = linear and min = linear and mip = none */
  84171. static readonly TEXTURE_LINEAR_LINEAR: number;
  84172. /** mag = linear and min = nearest and mip = none */
  84173. static readonly TEXTURE_LINEAR_NEAREST: number;
  84174. /** Explicit coordinates mode */
  84175. static readonly TEXTURE_EXPLICIT_MODE: number;
  84176. /** Spherical coordinates mode */
  84177. static readonly TEXTURE_SPHERICAL_MODE: number;
  84178. /** Planar coordinates mode */
  84179. static readonly TEXTURE_PLANAR_MODE: number;
  84180. /** Cubic coordinates mode */
  84181. static readonly TEXTURE_CUBIC_MODE: number;
  84182. /** Projection coordinates mode */
  84183. static readonly TEXTURE_PROJECTION_MODE: number;
  84184. /** Skybox coordinates mode */
  84185. static readonly TEXTURE_SKYBOX_MODE: number;
  84186. /** Inverse Cubic coordinates mode */
  84187. static readonly TEXTURE_INVCUBIC_MODE: number;
  84188. /** Equirectangular coordinates mode */
  84189. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  84190. /** Equirectangular Fixed coordinates mode */
  84191. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  84192. /** Equirectangular Fixed Mirrored coordinates mode */
  84193. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  84194. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  84195. static readonly SCALEMODE_FLOOR: number;
  84196. /** Defines that texture rescaling will look for the nearest power of 2 size */
  84197. static readonly SCALEMODE_NEAREST: number;
  84198. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  84199. static readonly SCALEMODE_CEILING: number;
  84200. /**
  84201. * Returns the current version of the framework
  84202. */
  84203. static readonly Version: string;
  84204. /**
  84205. * Returns a string describing the current engine
  84206. */
  84207. readonly description: string;
  84208. /**
  84209. * Gets or sets the epsilon value used by collision engine
  84210. */
  84211. static CollisionsEpsilon: number;
  84212. /**
  84213. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  84214. */
  84215. static ShadersRepository: string;
  84216. /**
  84217. * Method called to create the default loading screen.
  84218. * This can be overriden in your own app.
  84219. * @param canvas The rendering canvas element
  84220. * @returns The loading screen
  84221. */
  84222. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  84223. /**
  84224. * Method called to create the default rescale post process on each engine.
  84225. */
  84226. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  84227. /**
  84228. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  84229. */
  84230. forcePOTTextures: boolean;
  84231. /**
  84232. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  84233. */
  84234. isFullscreen: boolean;
  84235. /**
  84236. * Gets a boolean indicating if the pointer is currently locked
  84237. */
  84238. isPointerLock: boolean;
  84239. /**
  84240. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  84241. */
  84242. cullBackFaces: boolean;
  84243. /**
  84244. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  84245. */
  84246. renderEvenInBackground: boolean;
  84247. /**
  84248. * Gets or sets a boolean indicating that cache can be kept between frames
  84249. */
  84250. preventCacheWipeBetweenFrames: boolean;
  84251. /**
  84252. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  84253. **/
  84254. enableOfflineSupport: boolean;
  84255. /**
  84256. * 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)
  84257. **/
  84258. disableManifestCheck: boolean;
  84259. /**
  84260. * Gets the list of created scenes
  84261. */
  84262. scenes: Scene[];
  84263. /**
  84264. * Event raised when a new scene is created
  84265. */
  84266. onNewSceneAddedObservable: Observable<Scene>;
  84267. /**
  84268. * Gets the list of created postprocesses
  84269. */
  84270. postProcesses: PostProcess[];
  84271. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  84272. validateShaderPrograms: boolean;
  84273. /**
  84274. * Observable event triggered each time the rendering canvas is resized
  84275. */
  84276. onResizeObservable: Observable<Engine>;
  84277. /**
  84278. * Observable event triggered each time the canvas loses focus
  84279. */
  84280. onCanvasBlurObservable: Observable<Engine>;
  84281. /**
  84282. * Observable event triggered each time the canvas gains focus
  84283. */
  84284. onCanvasFocusObservable: Observable<Engine>;
  84285. /**
  84286. * Observable event triggered each time the canvas receives pointerout event
  84287. */
  84288. onCanvasPointerOutObservable: Observable<PointerEvent>;
  84289. /**
  84290. * Observable event triggered before each texture is initialized
  84291. */
  84292. onBeforeTextureInitObservable: Observable<Texture>;
  84293. private _vrDisplay;
  84294. private _vrSupported;
  84295. private _oldSize;
  84296. private _oldHardwareScaleFactor;
  84297. private _vrExclusivePointerMode;
  84298. private _webVRInitPromise;
  84299. /**
  84300. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  84301. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  84302. */
  84303. readonly isInVRExclusivePointerMode: boolean;
  84304. /**
  84305. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  84306. */
  84307. disableUniformBuffers: boolean;
  84308. /** @hidden */
  84309. _uniformBuffers: UniformBuffer[];
  84310. /**
  84311. * Gets a boolean indicating that the engine supports uniform buffers
  84312. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  84313. */
  84314. readonly supportsUniformBuffers: boolean;
  84315. /**
  84316. * Observable raised when the engine begins a new frame
  84317. */
  84318. onBeginFrameObservable: Observable<Engine>;
  84319. /**
  84320. * If set, will be used to request the next animation frame for the render loop
  84321. */
  84322. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  84323. /**
  84324. * Observable raised when the engine ends the current frame
  84325. */
  84326. onEndFrameObservable: Observable<Engine>;
  84327. /**
  84328. * Observable raised when the engine is about to compile a shader
  84329. */
  84330. onBeforeShaderCompilationObservable: Observable<Engine>;
  84331. /**
  84332. * Observable raised when the engine has jsut compiled a shader
  84333. */
  84334. onAfterShaderCompilationObservable: Observable<Engine>;
  84335. /** @hidden */
  84336. _gl: WebGLRenderingContext;
  84337. private _renderingCanvas;
  84338. private _windowIsBackground;
  84339. private _webGLVersion;
  84340. /**
  84341. * Gets a boolean indicating that only power of 2 textures are supported
  84342. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  84343. */
  84344. readonly needPOTTextures: boolean;
  84345. /** @hidden */
  84346. _badOS: boolean;
  84347. /** @hidden */
  84348. _badDesktopOS: boolean;
  84349. /**
  84350. * Gets or sets a value indicating if we want to disable texture binding optimization.
  84351. * This could be required on some buggy drivers which wants to have textures bound in a progressive order.
  84352. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is
  84353. */
  84354. disableTextureBindingOptimization: boolean;
  84355. /**
  84356. * Gets the audio engine
  84357. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  84358. * @ignorenaming
  84359. */
  84360. static audioEngine: IAudioEngine;
  84361. /**
  84362. * Default AudioEngine factory responsible of creating the Audio Engine.
  84363. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  84364. */
  84365. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  84366. /**
  84367. * Default offline support factory responsible of creating a tool used to store data locally.
  84368. * By default, this will create a Database object if the workload has been embedded.
  84369. */
  84370. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  84371. private _onFocus;
  84372. private _onBlur;
  84373. private _onCanvasPointerOut;
  84374. private _onCanvasBlur;
  84375. private _onCanvasFocus;
  84376. private _onFullscreenChange;
  84377. private _onPointerLockChange;
  84378. private _onVRDisplayPointerRestricted;
  84379. private _onVRDisplayPointerUnrestricted;
  84380. private _onVrDisplayConnect;
  84381. private _onVrDisplayDisconnect;
  84382. private _onVrDisplayPresentChange;
  84383. /**
  84384. * Observable signaled when VR display mode changes
  84385. */
  84386. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  84387. /**
  84388. * Observable signaled when VR request present is complete
  84389. */
  84390. onVRRequestPresentComplete: Observable<boolean>;
  84391. /**
  84392. * Observable signaled when VR request present starts
  84393. */
  84394. onVRRequestPresentStart: Observable<Engine>;
  84395. private _hardwareScalingLevel;
  84396. /** @hidden */
  84397. protected _caps: EngineCapabilities;
  84398. private _pointerLockRequested;
  84399. private _isStencilEnable;
  84400. private _colorWrite;
  84401. private _loadingScreen;
  84402. /** @hidden */
  84403. _drawCalls: PerfCounter;
  84404. /** @hidden */
  84405. _textureCollisions: PerfCounter;
  84406. private _glVersion;
  84407. private _glRenderer;
  84408. private _glVendor;
  84409. private _videoTextureSupported;
  84410. private _renderingQueueLaunched;
  84411. private _activeRenderLoops;
  84412. private _deterministicLockstep;
  84413. private _lockstepMaxSteps;
  84414. /**
  84415. * Observable signaled when a context lost event is raised
  84416. */
  84417. onContextLostObservable: Observable<Engine>;
  84418. /**
  84419. * Observable signaled when a context restored event is raised
  84420. */
  84421. onContextRestoredObservable: Observable<Engine>;
  84422. private _onContextLost;
  84423. private _onContextRestored;
  84424. private _contextWasLost;
  84425. private _doNotHandleContextLost;
  84426. /**
  84427. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  84428. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  84429. */
  84430. doNotHandleContextLost: boolean;
  84431. private _performanceMonitor;
  84432. private _fps;
  84433. private _deltaTime;
  84434. /**
  84435. * Turn this value on if you want to pause FPS computation when in background
  84436. */
  84437. disablePerformanceMonitorInBackground: boolean;
  84438. /**
  84439. * Gets the performance monitor attached to this engine
  84440. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  84441. */
  84442. readonly performanceMonitor: PerformanceMonitor;
  84443. /** @hidden */
  84444. protected _depthCullingState: _DepthCullingState;
  84445. /** @hidden */
  84446. protected _stencilState: _StencilState;
  84447. /** @hidden */
  84448. protected _alphaState: _AlphaState;
  84449. /** @hidden */
  84450. protected _alphaMode: number;
  84451. protected _internalTexturesCache: InternalTexture[];
  84452. /** @hidden */
  84453. protected _activeChannel: number;
  84454. private _currentTextureChannel;
  84455. /** @hidden */
  84456. protected _boundTexturesCache: {
  84457. [key: string]: Nullable<InternalTexture>;
  84458. };
  84459. /** @hidden */
  84460. protected _currentEffect: Nullable<Effect>;
  84461. /** @hidden */
  84462. protected _currentProgram: Nullable<WebGLProgram>;
  84463. private _compiledEffects;
  84464. private _vertexAttribArraysEnabled;
  84465. /** @hidden */
  84466. protected _cachedViewport: Nullable<Viewport>;
  84467. private _cachedVertexArrayObject;
  84468. /** @hidden */
  84469. protected _cachedVertexBuffers: any;
  84470. /** @hidden */
  84471. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  84472. /** @hidden */
  84473. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  84474. /** @hidden */
  84475. protected _currentRenderTarget: Nullable<InternalTexture>;
  84476. private _uintIndicesCurrentlySet;
  84477. private _currentBoundBuffer;
  84478. /** @hidden */
  84479. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  84480. private _currentBufferPointers;
  84481. private _currentInstanceLocations;
  84482. private _currentInstanceBuffers;
  84483. private _textureUnits;
  84484. private _firstBoundInternalTextureTracker;
  84485. private _lastBoundInternalTextureTracker;
  84486. private _workingCanvas;
  84487. private _workingContext;
  84488. private _rescalePostProcess;
  84489. private _dummyFramebuffer;
  84490. private _externalData;
  84491. private _bindedRenderFunction;
  84492. private _vaoRecordInProgress;
  84493. private _mustWipeVertexAttributes;
  84494. private _emptyTexture;
  84495. private _emptyCubeTexture;
  84496. private _emptyTexture3D;
  84497. /** @hidden */
  84498. _frameHandler: number;
  84499. private _nextFreeTextureSlots;
  84500. private _maxSimultaneousTextures;
  84501. private _activeRequests;
  84502. private _texturesSupported;
  84503. private _textureFormatInUse;
  84504. /**
  84505. * Gets the list of texture formats supported
  84506. */
  84507. readonly texturesSupported: Array<string>;
  84508. /**
  84509. * Gets the list of texture formats in use
  84510. */
  84511. readonly textureFormatInUse: Nullable<string>;
  84512. /**
  84513. * Gets the current viewport
  84514. */
  84515. readonly currentViewport: Nullable<Viewport>;
  84516. /**
  84517. * Gets the default empty texture
  84518. */
  84519. readonly emptyTexture: InternalTexture;
  84520. /**
  84521. * Gets the default empty 3D texture
  84522. */
  84523. readonly emptyTexture3D: InternalTexture;
  84524. /**
  84525. * Gets the default empty cube texture
  84526. */
  84527. readonly emptyCubeTexture: InternalTexture;
  84528. /**
  84529. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  84530. */
  84531. readonly premultipliedAlpha: boolean;
  84532. /**
  84533. * Creates a new engine
  84534. * @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
  84535. * @param antialias defines enable antialiasing (default: false)
  84536. * @param options defines further options to be sent to the getContext() function
  84537. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  84538. */
  84539. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  84540. private _disableTouchAction;
  84541. private _rebuildInternalTextures;
  84542. private _rebuildEffects;
  84543. /**
  84544. * Gets a boolean indicating if all created effects are ready
  84545. * @returns true if all effects are ready
  84546. */
  84547. areAllEffectsReady(): boolean;
  84548. private _rebuildBuffers;
  84549. private _initGLContext;
  84550. /**
  84551. * Gets version of the current webGL context
  84552. */
  84553. readonly webGLVersion: number;
  84554. /**
  84555. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  84556. */
  84557. readonly isStencilEnable: boolean;
  84558. private _prepareWorkingCanvas;
  84559. /**
  84560. * Reset the texture cache to empty state
  84561. */
  84562. resetTextureCache(): void;
  84563. /**
  84564. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  84565. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  84566. * @returns true if engine is in deterministic lock step mode
  84567. */
  84568. isDeterministicLockStep(): boolean;
  84569. /**
  84570. * Gets the max steps when engine is running in deterministic lock step
  84571. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  84572. * @returns the max steps
  84573. */
  84574. getLockstepMaxSteps(): number;
  84575. /**
  84576. * Gets an object containing information about the current webGL context
  84577. * @returns an object containing the vender, the renderer and the version of the current webGL context
  84578. */
  84579. getGlInfo(): {
  84580. vendor: string;
  84581. renderer: string;
  84582. version: string;
  84583. };
  84584. /**
  84585. * Gets current aspect ratio
  84586. * @param camera defines the camera to use to get the aspect ratio
  84587. * @param useScreen defines if screen size must be used (or the current render target if any)
  84588. * @returns a number defining the aspect ratio
  84589. */
  84590. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  84591. /**
  84592. * Gets current screen aspect ratio
  84593. * @returns a number defining the aspect ratio
  84594. */
  84595. getScreenAspectRatio(): number;
  84596. /**
  84597. * Gets the current render width
  84598. * @param useScreen defines if screen size must be used (or the current render target if any)
  84599. * @returns a number defining the current render width
  84600. */
  84601. getRenderWidth(useScreen?: boolean): number;
  84602. /**
  84603. * Gets the current render height
  84604. * @param useScreen defines if screen size must be used (or the current render target if any)
  84605. * @returns a number defining the current render height
  84606. */
  84607. getRenderHeight(useScreen?: boolean): number;
  84608. /**
  84609. * Gets the HTML canvas attached with the current webGL context
  84610. * @returns a HTML canvas
  84611. */
  84612. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  84613. /**
  84614. * Gets the client rect of the HTML canvas attached with the current webGL context
  84615. * @returns a client rectanglee
  84616. */
  84617. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  84618. /**
  84619. * Defines the hardware scaling level.
  84620. * By default the hardware scaling level is computed from the window device ratio.
  84621. * 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.
  84622. * @param level defines the level to use
  84623. */
  84624. setHardwareScalingLevel(level: number): void;
  84625. /**
  84626. * Gets the current hardware scaling level.
  84627. * By default the hardware scaling level is computed from the window device ratio.
  84628. * 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.
  84629. * @returns a number indicating the current hardware scaling level
  84630. */
  84631. getHardwareScalingLevel(): number;
  84632. /**
  84633. * Gets the list of loaded textures
  84634. * @returns an array containing all loaded textures
  84635. */
  84636. getLoadedTexturesCache(): InternalTexture[];
  84637. /**
  84638. * Gets the object containing all engine capabilities
  84639. * @returns the EngineCapabilities object
  84640. */
  84641. getCaps(): EngineCapabilities;
  84642. /**
  84643. * Gets the current depth function
  84644. * @returns a number defining the depth function
  84645. */
  84646. getDepthFunction(): Nullable<number>;
  84647. /**
  84648. * Sets the current depth function
  84649. * @param depthFunc defines the function to use
  84650. */
  84651. setDepthFunction(depthFunc: number): void;
  84652. /**
  84653. * Sets the current depth function to GREATER
  84654. */
  84655. setDepthFunctionToGreater(): void;
  84656. /**
  84657. * Sets the current depth function to GEQUAL
  84658. */
  84659. setDepthFunctionToGreaterOrEqual(): void;
  84660. /**
  84661. * Sets the current depth function to LESS
  84662. */
  84663. setDepthFunctionToLess(): void;
  84664. /**
  84665. * Sets the current depth function to LEQUAL
  84666. */
  84667. setDepthFunctionToLessOrEqual(): void;
  84668. /**
  84669. * Gets a boolean indicating if stencil buffer is enabled
  84670. * @returns the current stencil buffer state
  84671. */
  84672. getStencilBuffer(): boolean;
  84673. /**
  84674. * Enable or disable the stencil buffer
  84675. * @param enable defines if the stencil buffer must be enabled or disabled
  84676. */
  84677. setStencilBuffer(enable: boolean): void;
  84678. /**
  84679. * Gets the current stencil mask
  84680. * @returns a number defining the new stencil mask to use
  84681. */
  84682. getStencilMask(): number;
  84683. /**
  84684. * Sets the current stencil mask
  84685. * @param mask defines the new stencil mask to use
  84686. */
  84687. setStencilMask(mask: number): void;
  84688. /**
  84689. * Gets the current stencil function
  84690. * @returns a number defining the stencil function to use
  84691. */
  84692. getStencilFunction(): number;
  84693. /**
  84694. * Gets the current stencil reference value
  84695. * @returns a number defining the stencil reference value to use
  84696. */
  84697. getStencilFunctionReference(): number;
  84698. /**
  84699. * Gets the current stencil mask
  84700. * @returns a number defining the stencil mask to use
  84701. */
  84702. getStencilFunctionMask(): number;
  84703. /**
  84704. * Sets the current stencil function
  84705. * @param stencilFunc defines the new stencil function to use
  84706. */
  84707. setStencilFunction(stencilFunc: number): void;
  84708. /**
  84709. * Sets the current stencil reference
  84710. * @param reference defines the new stencil reference to use
  84711. */
  84712. setStencilFunctionReference(reference: number): void;
  84713. /**
  84714. * Sets the current stencil mask
  84715. * @param mask defines the new stencil mask to use
  84716. */
  84717. setStencilFunctionMask(mask: number): void;
  84718. /**
  84719. * Gets the current stencil operation when stencil fails
  84720. * @returns a number defining stencil operation to use when stencil fails
  84721. */
  84722. getStencilOperationFail(): number;
  84723. /**
  84724. * Gets the current stencil operation when depth fails
  84725. * @returns a number defining stencil operation to use when depth fails
  84726. */
  84727. getStencilOperationDepthFail(): number;
  84728. /**
  84729. * Gets the current stencil operation when stencil passes
  84730. * @returns a number defining stencil operation to use when stencil passes
  84731. */
  84732. getStencilOperationPass(): number;
  84733. /**
  84734. * Sets the stencil operation to use when stencil fails
  84735. * @param operation defines the stencil operation to use when stencil fails
  84736. */
  84737. setStencilOperationFail(operation: number): void;
  84738. /**
  84739. * Sets the stencil operation to use when depth fails
  84740. * @param operation defines the stencil operation to use when depth fails
  84741. */
  84742. setStencilOperationDepthFail(operation: number): void;
  84743. /**
  84744. * Sets the stencil operation to use when stencil passes
  84745. * @param operation defines the stencil operation to use when stencil passes
  84746. */
  84747. setStencilOperationPass(operation: number): void;
  84748. /**
  84749. * Sets a boolean indicating if the dithering state is enabled or disabled
  84750. * @param value defines the dithering state
  84751. */
  84752. setDitheringState(value: boolean): void;
  84753. /**
  84754. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  84755. * @param value defines the rasterizer state
  84756. */
  84757. setRasterizerState(value: boolean): void;
  84758. /**
  84759. * stop executing a render loop function and remove it from the execution array
  84760. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  84761. */
  84762. stopRenderLoop(renderFunction?: () => void): void;
  84763. /** @hidden */
  84764. _renderLoop(): void;
  84765. /**
  84766. * Register and execute a render loop. The engine can have more than one render function
  84767. * @param renderFunction defines the function to continuously execute
  84768. */
  84769. runRenderLoop(renderFunction: () => void): void;
  84770. /**
  84771. * Toggle full screen mode
  84772. * @param requestPointerLock defines if a pointer lock should be requested from the user
  84773. */
  84774. switchFullscreen(requestPointerLock: boolean): void;
  84775. /**
  84776. * Enters full screen mode
  84777. * @param requestPointerLock defines if a pointer lock should be requested from the user
  84778. */
  84779. enterFullscreen(requestPointerLock: boolean): void;
  84780. /**
  84781. * Exits full screen mode
  84782. */
  84783. exitFullscreen(): void;
  84784. /**
  84785. * Clear the current render buffer or the current render target (if any is set up)
  84786. * @param color defines the color to use
  84787. * @param backBuffer defines if the back buffer must be cleared
  84788. * @param depth defines if the depth buffer must be cleared
  84789. * @param stencil defines if the stencil buffer must be cleared
  84790. */
  84791. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  84792. /**
  84793. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  84794. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  84795. * @param y defines the y-coordinate of the corner of the clear rectangle
  84796. * @param width defines the width of the clear rectangle
  84797. * @param height defines the height of the clear rectangle
  84798. * @param clearColor defines the clear color
  84799. */
  84800. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  84801. /**
  84802. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  84803. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  84804. * @param y defines the y-coordinate of the corner of the clear rectangle
  84805. * @param width defines the width of the clear rectangle
  84806. * @param height defines the height of the clear rectangle
  84807. */
  84808. enableScissor(x: number, y: number, width: number, height: number): void;
  84809. /**
  84810. * Disable previously set scissor test rectangle
  84811. */
  84812. disableScissor(): void;
  84813. private _viewportCached;
  84814. /** @hidden */
  84815. _viewport(x: number, y: number, width: number, height: number): void;
  84816. /**
  84817. * Set the WebGL's viewport
  84818. * @param viewport defines the viewport element to be used
  84819. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  84820. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  84821. */
  84822. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  84823. /**
  84824. * Directly set the WebGL Viewport
  84825. * @param x defines the x coordinate of the viewport (in screen space)
  84826. * @param y defines the y coordinate of the viewport (in screen space)
  84827. * @param width defines the width of the viewport (in screen space)
  84828. * @param height defines the height of the viewport (in screen space)
  84829. * @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
  84830. */
  84831. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  84832. /**
  84833. * Begin a new frame
  84834. */
  84835. beginFrame(): void;
  84836. /**
  84837. * Enf the current frame
  84838. */
  84839. endFrame(): void;
  84840. /**
  84841. * Resize the view according to the canvas' size
  84842. */
  84843. resize(): void;
  84844. /**
  84845. * Force a specific size of the canvas
  84846. * @param width defines the new canvas' width
  84847. * @param height defines the new canvas' height
  84848. */
  84849. setSize(width: number, height: number): void;
  84850. /**
  84851. * Gets a boolean indicating if a webVR device was detected
  84852. * @returns true if a webVR device was detected
  84853. */
  84854. isVRDevicePresent(): boolean;
  84855. /**
  84856. * Gets the current webVR device
  84857. * @returns the current webVR device (or null)
  84858. */
  84859. getVRDevice(): any;
  84860. /**
  84861. * Initializes a webVR display and starts listening to display change events
  84862. * The onVRDisplayChangedObservable will be notified upon these changes
  84863. * @returns The onVRDisplayChangedObservable
  84864. */
  84865. initWebVR(): Observable<IDisplayChangedEventArgs>;
  84866. /**
  84867. * Initializes a webVR display and starts listening to display change events
  84868. * The onVRDisplayChangedObservable will be notified upon these changes
  84869. * @returns A promise containing a VRDisplay and if vr is supported
  84870. */
  84871. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  84872. /**
  84873. * Call this function to switch to webVR mode
  84874. * Will do nothing if webVR is not supported or if there is no webVR device
  84875. * @see http://doc.babylonjs.com/how_to/webvr_camera
  84876. */
  84877. enableVR(): void;
  84878. /**
  84879. * Call this function to leave webVR mode
  84880. * Will do nothing if webVR is not supported or if there is no webVR device
  84881. * @see http://doc.babylonjs.com/how_to/webvr_camera
  84882. */
  84883. disableVR(): void;
  84884. private _onVRFullScreenTriggered;
  84885. private _getVRDisplaysAsync;
  84886. /**
  84887. * Binds the frame buffer to the specified texture.
  84888. * @param texture The texture to render to or null for the default canvas
  84889. * @param faceIndex The face of the texture to render to in case of cube texture
  84890. * @param requiredWidth The width of the target to render to
  84891. * @param requiredHeight The height of the target to render to
  84892. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  84893. * @param depthStencilTexture The depth stencil texture to use to render
  84894. * @param lodLevel defines le lod level to bind to the frame buffer
  84895. */
  84896. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  84897. private bindUnboundFramebuffer;
  84898. /**
  84899. * Unbind the current render target texture from the webGL context
  84900. * @param texture defines the render target texture to unbind
  84901. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  84902. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  84903. */
  84904. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  84905. /**
  84906. * Unbind a list of render target textures from the webGL context
  84907. * This is used only when drawBuffer extension or webGL2 are active
  84908. * @param textures defines the render target textures to unbind
  84909. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  84910. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  84911. */
  84912. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  84913. /**
  84914. * Force the mipmap generation for the given render target texture
  84915. * @param texture defines the render target texture to use
  84916. */
  84917. generateMipMapsForCubemap(texture: InternalTexture): void;
  84918. /**
  84919. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  84920. */
  84921. flushFramebuffer(): void;
  84922. /**
  84923. * Unbind the current render target and bind the default framebuffer
  84924. */
  84925. restoreDefaultFramebuffer(): void;
  84926. /**
  84927. * Create an uniform buffer
  84928. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  84929. * @param elements defines the content of the uniform buffer
  84930. * @returns the webGL uniform buffer
  84931. */
  84932. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  84933. /**
  84934. * Create a dynamic uniform buffer
  84935. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  84936. * @param elements defines the content of the uniform buffer
  84937. * @returns the webGL uniform buffer
  84938. */
  84939. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  84940. /**
  84941. * Update an existing uniform buffer
  84942. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  84943. * @param uniformBuffer defines the target uniform buffer
  84944. * @param elements defines the content to update
  84945. * @param offset defines the offset in the uniform buffer where update should start
  84946. * @param count defines the size of the data to update
  84947. */
  84948. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  84949. private _resetVertexBufferBinding;
  84950. /**
  84951. * Creates a vertex buffer
  84952. * @param data the data for the vertex buffer
  84953. * @returns the new WebGL static buffer
  84954. */
  84955. createVertexBuffer(data: DataArray): WebGLBuffer;
  84956. /**
  84957. * Creates a dynamic vertex buffer
  84958. * @param data the data for the dynamic vertex buffer
  84959. * @returns the new WebGL dynamic buffer
  84960. */
  84961. createDynamicVertexBuffer(data: DataArray): WebGLBuffer;
  84962. /**
  84963. * Update a dynamic index buffer
  84964. * @param indexBuffer defines the target index buffer
  84965. * @param indices defines the data to update
  84966. * @param offset defines the offset in the target index buffer where update should start
  84967. */
  84968. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  84969. /**
  84970. * Updates a dynamic vertex buffer.
  84971. * @param vertexBuffer the vertex buffer to update
  84972. * @param data the data used to update the vertex buffer
  84973. * @param byteOffset the byte offset of the data
  84974. * @param byteLength the byte length of the data
  84975. */
  84976. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  84977. private _resetIndexBufferBinding;
  84978. /**
  84979. * Creates a new index buffer
  84980. * @param indices defines the content of the index buffer
  84981. * @param updatable defines if the index buffer must be updatable
  84982. * @returns a new webGL buffer
  84983. */
  84984. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  84985. /**
  84986. * Bind a webGL buffer to the webGL context
  84987. * @param buffer defines the buffer to bind
  84988. */
  84989. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  84990. /**
  84991. * Bind an uniform buffer to the current webGL context
  84992. * @param buffer defines the buffer to bind
  84993. */
  84994. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  84995. /**
  84996. * Bind a buffer to the current webGL context at a given location
  84997. * @param buffer defines the buffer to bind
  84998. * @param location defines the index where to bind the buffer
  84999. */
  85000. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  85001. /**
  85002. * Bind a specific block at a given index in a specific shader program
  85003. * @param shaderProgram defines the shader program
  85004. * @param blockName defines the block name
  85005. * @param index defines the index where to bind the block
  85006. */
  85007. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  85008. private bindIndexBuffer;
  85009. private bindBuffer;
  85010. /**
  85011. * update the bound buffer with the given data
  85012. * @param data defines the data to update
  85013. */
  85014. updateArrayBuffer(data: Float32Array): void;
  85015. private _vertexAttribPointer;
  85016. private _bindIndexBufferWithCache;
  85017. private _bindVertexBuffersAttributes;
  85018. /**
  85019. * Records a vertex array object
  85020. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  85021. * @param vertexBuffers defines the list of vertex buffers to store
  85022. * @param indexBuffer defines the index buffer to store
  85023. * @param effect defines the effect to store
  85024. * @returns the new vertex array object
  85025. */
  85026. recordVertexArrayObject(vertexBuffers: {
  85027. [key: string]: VertexBuffer;
  85028. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  85029. /**
  85030. * Bind a specific vertex array object
  85031. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  85032. * @param vertexArrayObject defines the vertex array object to bind
  85033. * @param indexBuffer defines the index buffer to bind
  85034. */
  85035. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  85036. /**
  85037. * Bind webGl buffers directly to the webGL context
  85038. * @param vertexBuffer defines the vertex buffer to bind
  85039. * @param indexBuffer defines the index buffer to bind
  85040. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  85041. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  85042. * @param effect defines the effect associated with the vertex buffer
  85043. */
  85044. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  85045. private _unbindVertexArrayObject;
  85046. /**
  85047. * Bind a list of vertex buffers to the webGL context
  85048. * @param vertexBuffers defines the list of vertex buffers to bind
  85049. * @param indexBuffer defines the index buffer to bind
  85050. * @param effect defines the effect associated with the vertex buffers
  85051. */
  85052. bindBuffers(vertexBuffers: {
  85053. [key: string]: Nullable<VertexBuffer>;
  85054. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  85055. /**
  85056. * Unbind all instance attributes
  85057. */
  85058. unbindInstanceAttributes(): void;
  85059. /**
  85060. * Release and free the memory of a vertex array object
  85061. * @param vao defines the vertex array object to delete
  85062. */
  85063. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  85064. /** @hidden */
  85065. _releaseBuffer(buffer: WebGLBuffer): boolean;
  85066. /**
  85067. * Creates a webGL buffer to use with instanciation
  85068. * @param capacity defines the size of the buffer
  85069. * @returns the webGL buffer
  85070. */
  85071. createInstancesBuffer(capacity: number): WebGLBuffer;
  85072. /**
  85073. * Delete a webGL buffer used with instanciation
  85074. * @param buffer defines the webGL buffer to delete
  85075. */
  85076. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  85077. /**
  85078. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  85079. * @param instancesBuffer defines the webGL buffer to update and bind
  85080. * @param data defines the data to store in the buffer
  85081. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  85082. */
  85083. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  85084. /**
  85085. * Apply all cached states (depth, culling, stencil and alpha)
  85086. */
  85087. applyStates(): void;
  85088. /**
  85089. * Send a draw order
  85090. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  85091. * @param indexStart defines the starting index
  85092. * @param indexCount defines the number of index to draw
  85093. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  85094. */
  85095. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  85096. /**
  85097. * Draw a list of points
  85098. * @param verticesStart defines the index of first vertex to draw
  85099. * @param verticesCount defines the count of vertices to draw
  85100. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  85101. */
  85102. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  85103. /**
  85104. * Draw a list of unindexed primitives
  85105. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  85106. * @param verticesStart defines the index of first vertex to draw
  85107. * @param verticesCount defines the count of vertices to draw
  85108. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  85109. */
  85110. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  85111. /**
  85112. * Draw a list of indexed primitives
  85113. * @param fillMode defines the primitive to use
  85114. * @param indexStart defines the starting index
  85115. * @param indexCount defines the number of index to draw
  85116. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  85117. */
  85118. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  85119. /**
  85120. * Draw a list of unindexed primitives
  85121. * @param fillMode defines the primitive to use
  85122. * @param verticesStart defines the index of first vertex to draw
  85123. * @param verticesCount defines the count of vertices to draw
  85124. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  85125. */
  85126. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  85127. private _drawMode;
  85128. /** @hidden */
  85129. _releaseEffect(effect: Effect): void;
  85130. /** @hidden */
  85131. _deleteProgram(program: WebGLProgram): void;
  85132. /**
  85133. * Create a new effect (used to store vertex/fragment shaders)
  85134. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  85135. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  85136. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  85137. * @param samplers defines an array of string used to represent textures
  85138. * @param defines defines the string containing the defines to use to compile the shaders
  85139. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  85140. * @param onCompiled defines a function to call when the effect creation is successful
  85141. * @param onError defines a function to call when the effect creation has failed
  85142. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  85143. * @returns the new Effect
  85144. */
  85145. 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;
  85146. private _compileShader;
  85147. private _compileRawShader;
  85148. /**
  85149. * Directly creates a webGL program
  85150. * @param vertexCode defines the vertex shader code to use
  85151. * @param fragmentCode defines the fragment shader code to use
  85152. * @param context defines the webGL context to use (if not set, the current one will be used)
  85153. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  85154. * @returns the new webGL program
  85155. */
  85156. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  85157. /**
  85158. * Creates a webGL program
  85159. * @param vertexCode defines the vertex shader code to use
  85160. * @param fragmentCode defines the fragment shader code to use
  85161. * @param defines defines the string containing the defines to use to compile the shaders
  85162. * @param context defines the webGL context to use (if not set, the current one will be used)
  85163. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  85164. * @returns the new webGL program
  85165. */
  85166. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  85167. private _createShaderProgram;
  85168. private _finalizeProgram;
  85169. /** @hidden */
  85170. _isProgramCompiled(shaderProgram: WebGLProgram): boolean;
  85171. /** @hidden */
  85172. _executeWhenProgramIsCompiled(shaderProgram: WebGLProgram, action: () => void): void;
  85173. /**
  85174. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  85175. * @param shaderProgram defines the webGL program to use
  85176. * @param uniformsNames defines the list of uniform names
  85177. * @returns an array of webGL uniform locations
  85178. */
  85179. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  85180. /**
  85181. * Gets the lsit of active attributes for a given webGL program
  85182. * @param shaderProgram defines the webGL program to use
  85183. * @param attributesNames defines the list of attribute names to get
  85184. * @returns an array of indices indicating the offset of each attribute
  85185. */
  85186. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  85187. /**
  85188. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  85189. * @param effect defines the effect to activate
  85190. */
  85191. enableEffect(effect: Nullable<Effect>): void;
  85192. /**
  85193. * Set the value of an uniform to an array of int32
  85194. * @param uniform defines the webGL uniform location where to store the value
  85195. * @param array defines the array of int32 to store
  85196. */
  85197. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  85198. /**
  85199. * Set the value of an uniform to an array of int32 (stored as vec2)
  85200. * @param uniform defines the webGL uniform location where to store the value
  85201. * @param array defines the array of int32 to store
  85202. */
  85203. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  85204. /**
  85205. * Set the value of an uniform to an array of int32 (stored as vec3)
  85206. * @param uniform defines the webGL uniform location where to store the value
  85207. * @param array defines the array of int32 to store
  85208. */
  85209. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  85210. /**
  85211. * Set the value of an uniform to an array of int32 (stored as vec4)
  85212. * @param uniform defines the webGL uniform location where to store the value
  85213. * @param array defines the array of int32 to store
  85214. */
  85215. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  85216. /**
  85217. * Set the value of an uniform to an array of float32
  85218. * @param uniform defines the webGL uniform location where to store the value
  85219. * @param array defines the array of float32 to store
  85220. */
  85221. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  85222. /**
  85223. * Set the value of an uniform to an array of float32 (stored as vec2)
  85224. * @param uniform defines the webGL uniform location where to store the value
  85225. * @param array defines the array of float32 to store
  85226. */
  85227. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  85228. /**
  85229. * Set the value of an uniform to an array of float32 (stored as vec3)
  85230. * @param uniform defines the webGL uniform location where to store the value
  85231. * @param array defines the array of float32 to store
  85232. */
  85233. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  85234. /**
  85235. * Set the value of an uniform to an array of float32 (stored as vec4)
  85236. * @param uniform defines the webGL uniform location where to store the value
  85237. * @param array defines the array of float32 to store
  85238. */
  85239. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  85240. /**
  85241. * Set the value of an uniform to an array of number
  85242. * @param uniform defines the webGL uniform location where to store the value
  85243. * @param array defines the array of number to store
  85244. */
  85245. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  85246. /**
  85247. * Set the value of an uniform to an array of number (stored as vec2)
  85248. * @param uniform defines the webGL uniform location where to store the value
  85249. * @param array defines the array of number to store
  85250. */
  85251. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  85252. /**
  85253. * Set the value of an uniform to an array of number (stored as vec3)
  85254. * @param uniform defines the webGL uniform location where to store the value
  85255. * @param array defines the array of number to store
  85256. */
  85257. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  85258. /**
  85259. * Set the value of an uniform to an array of number (stored as vec4)
  85260. * @param uniform defines the webGL uniform location where to store the value
  85261. * @param array defines the array of number to store
  85262. */
  85263. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  85264. /**
  85265. * Set the value of an uniform to an array of float32 (stored as matrices)
  85266. * @param uniform defines the webGL uniform location where to store the value
  85267. * @param matrices defines the array of float32 to store
  85268. */
  85269. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  85270. /**
  85271. * Set the value of an uniform to a matrix
  85272. * @param uniform defines the webGL uniform location where to store the value
  85273. * @param matrix defines the matrix to store
  85274. */
  85275. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  85276. /**
  85277. * Set the value of an uniform to a matrix (3x3)
  85278. * @param uniform defines the webGL uniform location where to store the value
  85279. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  85280. */
  85281. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  85282. /**
  85283. * Set the value of an uniform to a matrix (2x2)
  85284. * @param uniform defines the webGL uniform location where to store the value
  85285. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  85286. */
  85287. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  85288. /**
  85289. * Set the value of an uniform to a number (int)
  85290. * @param uniform defines the webGL uniform location where to store the value
  85291. * @param value defines the int number to store
  85292. */
  85293. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  85294. /**
  85295. * Set the value of an uniform to a number (float)
  85296. * @param uniform defines the webGL uniform location where to store the value
  85297. * @param value defines the float number to store
  85298. */
  85299. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  85300. /**
  85301. * Set the value of an uniform to a vec2
  85302. * @param uniform defines the webGL uniform location where to store the value
  85303. * @param x defines the 1st component of the value
  85304. * @param y defines the 2nd component of the value
  85305. */
  85306. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  85307. /**
  85308. * Set the value of an uniform to a vec3
  85309. * @param uniform defines the webGL uniform location where to store the value
  85310. * @param x defines the 1st component of the value
  85311. * @param y defines the 2nd component of the value
  85312. * @param z defines the 3rd component of the value
  85313. */
  85314. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  85315. /**
  85316. * Set the value of an uniform to a boolean
  85317. * @param uniform defines the webGL uniform location where to store the value
  85318. * @param bool defines the boolean to store
  85319. */
  85320. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  85321. /**
  85322. * Set the value of an uniform to a vec4
  85323. * @param uniform defines the webGL uniform location where to store the value
  85324. * @param x defines the 1st component of the value
  85325. * @param y defines the 2nd component of the value
  85326. * @param z defines the 3rd component of the value
  85327. * @param w defines the 4th component of the value
  85328. */
  85329. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  85330. /**
  85331. * Set the value of an uniform to a Color3
  85332. * @param uniform defines the webGL uniform location where to store the value
  85333. * @param color3 defines the color to store
  85334. */
  85335. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  85336. /**
  85337. * Set the value of an uniform to a Color3 and an alpha value
  85338. * @param uniform defines the webGL uniform location where to store the value
  85339. * @param color3 defines the color to store
  85340. * @param alpha defines the alpha component to store
  85341. */
  85342. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  85343. /**
  85344. * Sets a Color4 on a uniform variable
  85345. * @param uniform defines the uniform location
  85346. * @param color4 defines the value to be set
  85347. */
  85348. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  85349. /**
  85350. * Set various states to the webGL context
  85351. * @param culling defines backface culling state
  85352. * @param zOffset defines the value to apply to zOffset (0 by default)
  85353. * @param force defines if states must be applied even if cache is up to date
  85354. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  85355. */
  85356. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  85357. /**
  85358. * Set the z offset to apply to current rendering
  85359. * @param value defines the offset to apply
  85360. */
  85361. setZOffset(value: number): void;
  85362. /**
  85363. * Gets the current value of the zOffset
  85364. * @returns the current zOffset state
  85365. */
  85366. getZOffset(): number;
  85367. /**
  85368. * Enable or disable depth buffering
  85369. * @param enable defines the state to set
  85370. */
  85371. setDepthBuffer(enable: boolean): void;
  85372. /**
  85373. * Gets a boolean indicating if depth writing is enabled
  85374. * @returns the current depth writing state
  85375. */
  85376. getDepthWrite(): boolean;
  85377. /**
  85378. * Enable or disable depth writing
  85379. * @param enable defines the state to set
  85380. */
  85381. setDepthWrite(enable: boolean): void;
  85382. /**
  85383. * Enable or disable color writing
  85384. * @param enable defines the state to set
  85385. */
  85386. setColorWrite(enable: boolean): void;
  85387. /**
  85388. * Gets a boolean indicating if color writing is enabled
  85389. * @returns the current color writing state
  85390. */
  85391. getColorWrite(): boolean;
  85392. /**
  85393. * Sets alpha constants used by some alpha blending modes
  85394. * @param r defines the red component
  85395. * @param g defines the green component
  85396. * @param b defines the blue component
  85397. * @param a defines the alpha component
  85398. */
  85399. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  85400. /**
  85401. * Sets the current alpha mode
  85402. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  85403. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  85404. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  85405. */
  85406. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  85407. /**
  85408. * Gets the current alpha mode
  85409. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  85410. * @returns the current alpha mode
  85411. */
  85412. getAlphaMode(): number;
  85413. /**
  85414. * Clears the list of texture accessible through engine.
  85415. * This can help preventing texture load conflict due to name collision.
  85416. */
  85417. clearInternalTexturesCache(): void;
  85418. /**
  85419. * Force the entire cache to be cleared
  85420. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  85421. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  85422. */
  85423. wipeCaches(bruteForce?: boolean): void;
  85424. /**
  85425. * Set the compressed texture format to use, based on the formats you have, and the formats
  85426. * supported by the hardware / browser.
  85427. *
  85428. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  85429. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  85430. * to API arguments needed to compressed textures. This puts the burden on the container
  85431. * generator to house the arcane code for determining these for current & future formats.
  85432. *
  85433. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  85434. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  85435. *
  85436. * Note: The result of this call is not taken into account when a texture is base64.
  85437. *
  85438. * @param formatsAvailable defines the list of those format families you have created
  85439. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  85440. *
  85441. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  85442. * @returns The extension selected.
  85443. */
  85444. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  85445. private _getSamplingParameters;
  85446. private _partialLoadImg;
  85447. private _cascadeLoadImgs;
  85448. /** @hidden */
  85449. _createTexture(): WebGLTexture;
  85450. /**
  85451. * Usually called from Texture.ts.
  85452. * Passed information to create a WebGLTexture
  85453. * @param urlArg defines a value which contains one of the following:
  85454. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  85455. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  85456. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  85457. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  85458. * @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)
  85459. * @param scene needed for loading to the correct scene
  85460. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  85461. * @param onLoad optional callback to be called upon successful completion
  85462. * @param onError optional callback to be called upon failure
  85463. * @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
  85464. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  85465. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  85466. * @param forcedExtension defines the extension to use to pick the right loader
  85467. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  85468. * @returns a InternalTexture for assignment back into BABYLON.Texture
  85469. */
  85470. 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;
  85471. private _rescaleTexture;
  85472. /**
  85473. * Update a raw texture
  85474. * @param texture defines the texture to update
  85475. * @param data defines the data to store in the texture
  85476. * @param format defines the format of the data
  85477. * @param invertY defines if data must be stored with Y axis inverted
  85478. * @param compression defines the compression used (null by default)
  85479. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  85480. */
  85481. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  85482. /**
  85483. * Creates a raw texture
  85484. * @param data defines the data to store in the texture
  85485. * @param width defines the width of the texture
  85486. * @param height defines the height of the texture
  85487. * @param format defines the format of the data
  85488. * @param generateMipMaps defines if the engine should generate the mip levels
  85489. * @param invertY defines if data must be stored with Y axis inverted
  85490. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  85491. * @param compression defines the compression used (null by default)
  85492. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  85493. * @returns the raw texture inside an InternalTexture
  85494. */
  85495. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  85496. private _unpackFlipYCached;
  85497. /**
  85498. * In case you are sharing the context with other applications, it might
  85499. * be interested to not cache the unpack flip y state to ensure a consistent
  85500. * value would be set.
  85501. */
  85502. enableUnpackFlipYCached: boolean;
  85503. /** @hidden */
  85504. _unpackFlipY(value: boolean): void;
  85505. /** @hidden */
  85506. _getUnpackAlignement(): number;
  85507. /**
  85508. * Creates a dynamic texture
  85509. * @param width defines the width of the texture
  85510. * @param height defines the height of the texture
  85511. * @param generateMipMaps defines if the engine should generate the mip levels
  85512. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  85513. * @returns the dynamic texture inside an InternalTexture
  85514. */
  85515. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  85516. /**
  85517. * Update the sampling mode of a given texture
  85518. * @param samplingMode defines the required sampling mode
  85519. * @param texture defines the texture to update
  85520. */
  85521. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  85522. /**
  85523. * Update the content of a dynamic texture
  85524. * @param texture defines the texture to update
  85525. * @param canvas defines the canvas containing the source
  85526. * @param invertY defines if data must be stored with Y axis inverted
  85527. * @param premulAlpha defines if alpha is stored as premultiplied
  85528. * @param format defines the format of the data
  85529. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  85530. */
  85531. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  85532. /**
  85533. * Update a video texture
  85534. * @param texture defines the texture to update
  85535. * @param video defines the video element to use
  85536. * @param invertY defines if data must be stored with Y axis inverted
  85537. */
  85538. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  85539. /**
  85540. * Updates a depth texture Comparison Mode and Function.
  85541. * If the comparison Function is equal to 0, the mode will be set to none.
  85542. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  85543. * @param texture The texture to set the comparison function for
  85544. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  85545. */
  85546. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  85547. private _setupDepthStencilTexture;
  85548. /**
  85549. * Creates a depth stencil texture.
  85550. * This is only available in WebGL 2 or with the depth texture extension available.
  85551. * @param size The size of face edge in the texture.
  85552. * @param options The options defining the texture.
  85553. * @returns The texture
  85554. */
  85555. createDepthStencilTexture(size: number | {
  85556. width: number;
  85557. height: number;
  85558. }, options: DepthTextureCreationOptions): InternalTexture;
  85559. /**
  85560. * Creates a depth stencil texture.
  85561. * This is only available in WebGL 2 or with the depth texture extension available.
  85562. * @param size The size of face edge in the texture.
  85563. * @param options The options defining the texture.
  85564. * @returns The texture
  85565. */
  85566. private _createDepthStencilTexture;
  85567. /**
  85568. * Creates a depth stencil cube texture.
  85569. * This is only available in WebGL 2.
  85570. * @param size The size of face edge in the cube texture.
  85571. * @param options The options defining the cube texture.
  85572. * @returns The cube texture
  85573. */
  85574. private _createDepthStencilCubeTexture;
  85575. /**
  85576. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  85577. * @param renderTarget The render target to set the frame buffer for
  85578. */
  85579. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  85580. /**
  85581. * Creates a new render target texture
  85582. * @param size defines the size of the texture
  85583. * @param options defines the options used to create the texture
  85584. * @returns a new render target texture stored in an InternalTexture
  85585. */
  85586. createRenderTargetTexture(size: number | {
  85587. width: number;
  85588. height: number;
  85589. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  85590. /**
  85591. * Create a multi render target texture
  85592. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  85593. * @param size defines the size of the texture
  85594. * @param options defines the creation options
  85595. * @returns the cube texture as an InternalTexture
  85596. */
  85597. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  85598. private _setupFramebufferDepthAttachments;
  85599. /**
  85600. * Updates the sample count of a render target texture
  85601. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  85602. * @param texture defines the texture to update
  85603. * @param samples defines the sample count to set
  85604. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  85605. */
  85606. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  85607. /**
  85608. * Update the sample count for a given multiple render target texture
  85609. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  85610. * @param textures defines the textures to update
  85611. * @param samples defines the sample count to set
  85612. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  85613. */
  85614. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  85615. /** @hidden */
  85616. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  85617. /** @hidden */
  85618. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  85619. /** @hidden */
  85620. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  85621. /** @hidden */
  85622. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  85623. /**
  85624. * Creates a new render target cube texture
  85625. * @param size defines the size of the texture
  85626. * @param options defines the options used to create the texture
  85627. * @returns a new render target cube texture stored in an InternalTexture
  85628. */
  85629. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  85630. /**
  85631. * Creates a cube texture
  85632. * @param rootUrl defines the url where the files to load is located
  85633. * @param scene defines the current scene
  85634. * @param files defines the list of files to load (1 per face)
  85635. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  85636. * @param onLoad defines an optional callback raised when the texture is loaded
  85637. * @param onError defines an optional callback raised if there is an issue to load the texture
  85638. * @param format defines the format of the data
  85639. * @param forcedExtension defines the extension to use to pick the right loader
  85640. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  85641. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  85642. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  85643. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  85644. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  85645. * @returns the cube texture as an InternalTexture
  85646. */
  85647. 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;
  85648. /**
  85649. * @hidden
  85650. */
  85651. _setCubeMapTextureParams(loadMipmap: boolean): void;
  85652. /**
  85653. * Update a raw cube texture
  85654. * @param texture defines the texture to udpdate
  85655. * @param data defines the data to store
  85656. * @param format defines the data format
  85657. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  85658. * @param invertY defines if data must be stored with Y axis inverted
  85659. * @param compression defines the compression used (null by default)
  85660. * @param level defines which level of the texture to update
  85661. */
  85662. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  85663. /**
  85664. * Creates a new raw cube texture
  85665. * @param data defines the array of data to use to create each face
  85666. * @param size defines the size of the textures
  85667. * @param format defines the format of the data
  85668. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  85669. * @param generateMipMaps defines if the engine should generate the mip levels
  85670. * @param invertY defines if data must be stored with Y axis inverted
  85671. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  85672. * @param compression defines the compression used (null by default)
  85673. * @returns the cube texture as an InternalTexture
  85674. */
  85675. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  85676. /**
  85677. * Creates a new raw cube texture from a specified url
  85678. * @param url defines the url where the data is located
  85679. * @param scene defines the current scene
  85680. * @param size defines the size of the textures
  85681. * @param format defines the format of the data
  85682. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  85683. * @param noMipmap defines if the engine should avoid generating the mip levels
  85684. * @param callback defines a callback used to extract texture data from loaded data
  85685. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  85686. * @param onLoad defines a callback called when texture is loaded
  85687. * @param onError defines a callback called if there is an error
  85688. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  85689. * @param invertY defines if data must be stored with Y axis inverted
  85690. * @returns the cube texture as an InternalTexture
  85691. */
  85692. 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;
  85693. /**
  85694. * Update a raw 3D texture
  85695. * @param texture defines the texture to update
  85696. * @param data defines the data to store
  85697. * @param format defines the data format
  85698. * @param invertY defines if data must be stored with Y axis inverted
  85699. * @param compression defines the used compression (can be null)
  85700. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  85701. */
  85702. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  85703. /**
  85704. * Creates a new raw 3D texture
  85705. * @param data defines the data used to create the texture
  85706. * @param width defines the width of the texture
  85707. * @param height defines the height of the texture
  85708. * @param depth defines the depth of the texture
  85709. * @param format defines the format of the texture
  85710. * @param generateMipMaps defines if the engine must generate mip levels
  85711. * @param invertY defines if data must be stored with Y axis inverted
  85712. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  85713. * @param compression defines the compressed used (can be null)
  85714. * @param textureType defines the compressed used (can be null)
  85715. * @returns a new raw 3D texture (stored in an InternalTexture)
  85716. */
  85717. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  85718. private _prepareWebGLTextureContinuation;
  85719. private _prepareWebGLTexture;
  85720. private _convertRGBtoRGBATextureData;
  85721. /** @hidden */
  85722. _releaseFramebufferObjects(texture: InternalTexture): void;
  85723. /** @hidden */
  85724. _releaseTexture(texture: InternalTexture): void;
  85725. private setProgram;
  85726. private _boundUniforms;
  85727. /**
  85728. * Binds an effect to the webGL context
  85729. * @param effect defines the effect to bind
  85730. */
  85731. bindSamplers(effect: Effect): void;
  85732. private _moveBoundTextureOnTop;
  85733. private _getCorrectTextureChannel;
  85734. private _linkTrackers;
  85735. private _removeDesignatedSlot;
  85736. private _activateCurrentTexture;
  85737. /** @hidden */
  85738. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  85739. /** @hidden */
  85740. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  85741. /**
  85742. * Sets a texture to the webGL context from a postprocess
  85743. * @param channel defines the channel to use
  85744. * @param postProcess defines the source postprocess
  85745. */
  85746. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  85747. /**
  85748. * Binds the output of the passed in post process to the texture channel specified
  85749. * @param channel The channel the texture should be bound to
  85750. * @param postProcess The post process which's output should be bound
  85751. */
  85752. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  85753. /**
  85754. * Unbind all textures from the webGL context
  85755. */
  85756. unbindAllTextures(): void;
  85757. /**
  85758. * Sets a texture to the according uniform.
  85759. * @param channel The texture channel
  85760. * @param uniform The uniform to set
  85761. * @param texture The texture to apply
  85762. */
  85763. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  85764. /**
  85765. * Sets a depth stencil texture from a render target to the according uniform.
  85766. * @param channel The texture channel
  85767. * @param uniform The uniform to set
  85768. * @param texture The render target texture containing the depth stencil texture to apply
  85769. */
  85770. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  85771. private _bindSamplerUniformToChannel;
  85772. private _getTextureWrapMode;
  85773. private _setTexture;
  85774. /**
  85775. * Sets an array of texture to the webGL context
  85776. * @param channel defines the channel where the texture array must be set
  85777. * @param uniform defines the associated uniform location
  85778. * @param textures defines the array of textures to bind
  85779. */
  85780. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  85781. /** @hidden */
  85782. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  85783. private _setTextureParameterFloat;
  85784. private _setTextureParameterInteger;
  85785. /**
  85786. * Reads pixels from the current frame buffer. Please note that this function can be slow
  85787. * @param x defines the x coordinate of the rectangle where pixels must be read
  85788. * @param y defines the y coordinate of the rectangle where pixels must be read
  85789. * @param width defines the width of the rectangle where pixels must be read
  85790. * @param height defines the height of the rectangle where pixels must be read
  85791. * @returns a Uint8Array containing RGBA colors
  85792. */
  85793. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  85794. /**
  85795. * Add an externaly attached data from its key.
  85796. * This method call will fail and return false, if such key already exists.
  85797. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  85798. * @param key the unique key that identifies the data
  85799. * @param data the data object to associate to the key for this Engine instance
  85800. * @return true if no such key were already present and the data was added successfully, false otherwise
  85801. */
  85802. addExternalData<T>(key: string, data: T): boolean;
  85803. /**
  85804. * Get an externaly attached data from its key
  85805. * @param key the unique key that identifies the data
  85806. * @return the associated data, if present (can be null), or undefined if not present
  85807. */
  85808. getExternalData<T>(key: string): T;
  85809. /**
  85810. * Get an externaly attached data from its key, create it using a factory if it's not already present
  85811. * @param key the unique key that identifies the data
  85812. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  85813. * @return the associated data, can be null if the factory returned null.
  85814. */
  85815. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  85816. /**
  85817. * Remove an externaly attached data from the Engine instance
  85818. * @param key the unique key that identifies the data
  85819. * @return true if the data was successfully removed, false if it doesn't exist
  85820. */
  85821. removeExternalData(key: string): boolean;
  85822. /**
  85823. * Unbind all vertex attributes from the webGL context
  85824. */
  85825. unbindAllAttributes(): void;
  85826. /**
  85827. * 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
  85828. */
  85829. releaseEffects(): void;
  85830. /**
  85831. * Dispose and release all associated resources
  85832. */
  85833. dispose(): void;
  85834. /**
  85835. * Display the loading screen
  85836. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  85837. */
  85838. displayLoadingUI(): void;
  85839. /**
  85840. * Hide the loading screen
  85841. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  85842. */
  85843. hideLoadingUI(): void;
  85844. /**
  85845. * Gets the current loading screen object
  85846. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  85847. */
  85848. /**
  85849. * Sets the current loading screen object
  85850. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  85851. */
  85852. loadingScreen: ILoadingScreen;
  85853. /**
  85854. * Sets the current loading screen text
  85855. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  85856. */
  85857. loadingUIText: string;
  85858. /**
  85859. * Sets the current loading screen background color
  85860. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  85861. */
  85862. loadingUIBackgroundColor: string;
  85863. /**
  85864. * Attach a new callback raised when context lost event is fired
  85865. * @param callback defines the callback to call
  85866. */
  85867. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  85868. /**
  85869. * Attach a new callback raised when context restored event is fired
  85870. * @param callback defines the callback to call
  85871. */
  85872. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  85873. /**
  85874. * Gets the source code of the vertex shader associated with a specific webGL program
  85875. * @param program defines the program to use
  85876. * @returns a string containing the source code of the vertex shader associated with the program
  85877. */
  85878. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  85879. /**
  85880. * Gets the source code of the fragment shader associated with a specific webGL program
  85881. * @param program defines the program to use
  85882. * @returns a string containing the source code of the fragment shader associated with the program
  85883. */
  85884. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  85885. /**
  85886. * Get the current error code of the webGL context
  85887. * @returns the error code
  85888. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  85889. */
  85890. getError(): number;
  85891. /**
  85892. * Gets the current framerate
  85893. * @returns a number representing the framerate
  85894. */
  85895. getFps(): number;
  85896. /**
  85897. * Gets the time spent between current and previous frame
  85898. * @returns a number representing the delta time in ms
  85899. */
  85900. getDeltaTime(): number;
  85901. private _measureFps;
  85902. /** @hidden */
  85903. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  85904. private _canRenderToFloatFramebuffer;
  85905. private _canRenderToHalfFloatFramebuffer;
  85906. private _canRenderToFramebuffer;
  85907. /** @hidden */
  85908. _getWebGLTextureType(type: number): number;
  85909. private _getInternalFormat;
  85910. /** @hidden */
  85911. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  85912. /** @hidden */
  85913. _getRGBAMultiSampleBufferFormat(type: number): number;
  85914. /** @hidden */
  85915. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: XMLHttpRequest, exception?: any) => void): IFileRequest;
  85916. /** @hidden */
  85917. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  85918. private _partialLoadFile;
  85919. private _cascadeLoadFiles;
  85920. /**
  85921. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  85922. * @returns true if the engine can be created
  85923. * @ignorenaming
  85924. */
  85925. static isSupported(): boolean;
  85926. }
  85927. }
  85928. declare module BABYLON {
  85929. /**
  85930. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  85931. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  85932. */
  85933. export class EffectFallbacks {
  85934. private _defines;
  85935. private _currentRank;
  85936. private _maxRank;
  85937. private _mesh;
  85938. /**
  85939. * Removes the fallback from the bound mesh.
  85940. */
  85941. unBindMesh(): void;
  85942. /**
  85943. * Adds a fallback on the specified property.
  85944. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  85945. * @param define The name of the define in the shader
  85946. */
  85947. addFallback(rank: number, define: string): void;
  85948. /**
  85949. * Sets the mesh to use CPU skinning when needing to fallback.
  85950. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  85951. * @param mesh The mesh to use the fallbacks.
  85952. */
  85953. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  85954. /**
  85955. * Checks to see if more fallbacks are still availible.
  85956. */
  85957. readonly isMoreFallbacks: boolean;
  85958. /**
  85959. * Removes the defines that shoould be removed when falling back.
  85960. * @param currentDefines defines the current define statements for the shader.
  85961. * @param effect defines the current effect we try to compile
  85962. * @returns The resulting defines with defines of the current rank removed.
  85963. */
  85964. reduce(currentDefines: string, effect: Effect): string;
  85965. }
  85966. /**
  85967. * Options to be used when creating an effect.
  85968. */
  85969. export class EffectCreationOptions {
  85970. /**
  85971. * Atrributes that will be used in the shader.
  85972. */
  85973. attributes: string[];
  85974. /**
  85975. * Uniform varible names that will be set in the shader.
  85976. */
  85977. uniformsNames: string[];
  85978. /**
  85979. * Uniform buffer varible names that will be set in the shader.
  85980. */
  85981. uniformBuffersNames: string[];
  85982. /**
  85983. * Sampler texture variable names that will be set in the shader.
  85984. */
  85985. samplers: string[];
  85986. /**
  85987. * Define statements that will be set in the shader.
  85988. */
  85989. defines: any;
  85990. /**
  85991. * Possible fallbacks for this effect to improve performance when needed.
  85992. */
  85993. fallbacks: Nullable<EffectFallbacks>;
  85994. /**
  85995. * Callback that will be called when the shader is compiled.
  85996. */
  85997. onCompiled: Nullable<(effect: Effect) => void>;
  85998. /**
  85999. * Callback that will be called if an error occurs during shader compilation.
  86000. */
  86001. onError: Nullable<(effect: Effect, errors: string) => void>;
  86002. /**
  86003. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  86004. */
  86005. indexParameters: any;
  86006. /**
  86007. * Max number of lights that can be used in the shader.
  86008. */
  86009. maxSimultaneousLights: number;
  86010. /**
  86011. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  86012. */
  86013. transformFeedbackVaryings: Nullable<string[]>;
  86014. }
  86015. /**
  86016. * Effect containing vertex and fragment shader that can be executed on an object.
  86017. */
  86018. export class Effect {
  86019. /**
  86020. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  86021. */
  86022. static ShadersRepository: string;
  86023. /**
  86024. * Name of the effect.
  86025. */
  86026. name: any;
  86027. /**
  86028. * String container all the define statements that should be set on the shader.
  86029. */
  86030. defines: string;
  86031. /**
  86032. * Callback that will be called when the shader is compiled.
  86033. */
  86034. onCompiled: Nullable<(effect: Effect) => void>;
  86035. /**
  86036. * Callback that will be called if an error occurs during shader compilation.
  86037. */
  86038. onError: Nullable<(effect: Effect, errors: string) => void>;
  86039. /**
  86040. * Callback that will be called when effect is bound.
  86041. */
  86042. onBind: Nullable<(effect: Effect) => void>;
  86043. /**
  86044. * Unique ID of the effect.
  86045. */
  86046. uniqueId: number;
  86047. /**
  86048. * Observable that will be called when the shader is compiled.
  86049. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  86050. */
  86051. onCompileObservable: Observable<Effect>;
  86052. /**
  86053. * Observable that will be called if an error occurs during shader compilation.
  86054. */
  86055. onErrorObservable: Observable<Effect>;
  86056. /** @hidden */
  86057. _onBindObservable: Nullable<Observable<Effect>>;
  86058. /**
  86059. * Observable that will be called when effect is bound.
  86060. */
  86061. readonly onBindObservable: Observable<Effect>;
  86062. /** @hidden */
  86063. _bonesComputationForcedToCPU: boolean;
  86064. private static _uniqueIdSeed;
  86065. private _engine;
  86066. private _uniformBuffersNames;
  86067. private _uniformsNames;
  86068. private _samplers;
  86069. private _isReady;
  86070. private _compilationError;
  86071. private _attributesNames;
  86072. private _attributes;
  86073. private _uniforms;
  86074. /**
  86075. * Key for the effect.
  86076. * @hidden
  86077. */
  86078. _key: string;
  86079. private _indexParameters;
  86080. private _fallbacks;
  86081. private _vertexSourceCode;
  86082. private _fragmentSourceCode;
  86083. private _vertexSourceCodeOverride;
  86084. private _fragmentSourceCodeOverride;
  86085. private _transformFeedbackVaryings;
  86086. /**
  86087. * Compiled shader to webGL program.
  86088. * @hidden
  86089. */
  86090. _program: WebGLProgram;
  86091. private _valueCache;
  86092. private static _baseCache;
  86093. /**
  86094. * Instantiates an effect.
  86095. * An effect can be used to create/manage/execute vertex and fragment shaders.
  86096. * @param baseName Name of the effect.
  86097. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  86098. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  86099. * @param samplers List of sampler variables that will be passed to the shader.
  86100. * @param engine Engine to be used to render the effect
  86101. * @param defines Define statements to be added to the shader.
  86102. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  86103. * @param onCompiled Callback that will be called when the shader is compiled.
  86104. * @param onError Callback that will be called if an error occurs during shader compilation.
  86105. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  86106. */
  86107. 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);
  86108. /**
  86109. * Unique key for this effect
  86110. */
  86111. readonly key: string;
  86112. /**
  86113. * If the effect has been compiled and prepared.
  86114. * @returns if the effect is compiled and prepared.
  86115. */
  86116. isReady(): boolean;
  86117. /**
  86118. * The engine the effect was initialized with.
  86119. * @returns the engine.
  86120. */
  86121. getEngine(): Engine;
  86122. /**
  86123. * The compiled webGL program for the effect
  86124. * @returns the webGL program.
  86125. */
  86126. getProgram(): WebGLProgram;
  86127. /**
  86128. * The set of names of attribute variables for the shader.
  86129. * @returns An array of attribute names.
  86130. */
  86131. getAttributesNames(): string[];
  86132. /**
  86133. * Returns the attribute at the given index.
  86134. * @param index The index of the attribute.
  86135. * @returns The location of the attribute.
  86136. */
  86137. getAttributeLocation(index: number): number;
  86138. /**
  86139. * Returns the attribute based on the name of the variable.
  86140. * @param name of the attribute to look up.
  86141. * @returns the attribute location.
  86142. */
  86143. getAttributeLocationByName(name: string): number;
  86144. /**
  86145. * The number of attributes.
  86146. * @returns the numnber of attributes.
  86147. */
  86148. getAttributesCount(): number;
  86149. /**
  86150. * Gets the index of a uniform variable.
  86151. * @param uniformName of the uniform to look up.
  86152. * @returns the index.
  86153. */
  86154. getUniformIndex(uniformName: string): number;
  86155. /**
  86156. * Returns the attribute based on the name of the variable.
  86157. * @param uniformName of the uniform to look up.
  86158. * @returns the location of the uniform.
  86159. */
  86160. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  86161. /**
  86162. * Returns an array of sampler variable names
  86163. * @returns The array of sampler variable neames.
  86164. */
  86165. getSamplers(): string[];
  86166. /**
  86167. * The error from the last compilation.
  86168. * @returns the error string.
  86169. */
  86170. getCompilationError(): string;
  86171. /**
  86172. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  86173. * @param func The callback to be used.
  86174. */
  86175. executeWhenCompiled(func: (effect: Effect) => void): void;
  86176. private _checkIsReady;
  86177. /** @hidden */
  86178. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  86179. /** @hidden */
  86180. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  86181. /** @hidden */
  86182. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  86183. private _processShaderConversion;
  86184. private _processIncludes;
  86185. private _processPrecision;
  86186. /**
  86187. * Recompiles the webGL program
  86188. * @param vertexSourceCode The source code for the vertex shader.
  86189. * @param fragmentSourceCode The source code for the fragment shader.
  86190. * @param onCompiled Callback called when completed.
  86191. * @param onError Callback called on error.
  86192. * @hidden
  86193. */
  86194. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  86195. /**
  86196. * Gets the uniform locations of the the specified variable names
  86197. * @param names THe names of the variables to lookup.
  86198. * @returns Array of locations in the same order as variable names.
  86199. */
  86200. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  86201. /**
  86202. * Prepares the effect
  86203. * @hidden
  86204. */
  86205. _prepareEffect(): void;
  86206. /**
  86207. * Checks if the effect is supported. (Must be called after compilation)
  86208. */
  86209. readonly isSupported: boolean;
  86210. /**
  86211. * Binds a texture to the engine to be used as output of the shader.
  86212. * @param channel Name of the output variable.
  86213. * @param texture Texture to bind.
  86214. * @hidden
  86215. */
  86216. _bindTexture(channel: string, texture: InternalTexture): void;
  86217. /**
  86218. * Sets a texture on the engine to be used in the shader.
  86219. * @param channel Name of the sampler variable.
  86220. * @param texture Texture to set.
  86221. */
  86222. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  86223. /**
  86224. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  86225. * @param channel Name of the sampler variable.
  86226. * @param texture Texture to set.
  86227. */
  86228. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  86229. /**
  86230. * Sets an array of textures on the engine to be used in the shader.
  86231. * @param channel Name of the variable.
  86232. * @param textures Textures to set.
  86233. */
  86234. setTextureArray(channel: string, textures: BaseTexture[]): void;
  86235. /**
  86236. * 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)
  86237. * @param channel Name of the sampler variable.
  86238. * @param postProcess Post process to get the input texture from.
  86239. */
  86240. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  86241. /**
  86242. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  86243. * 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)
  86244. * @param channel Name of the sampler variable.
  86245. * @param postProcess Post process to get the output texture from.
  86246. */
  86247. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  86248. /** @hidden */
  86249. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  86250. /** @hidden */
  86251. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  86252. /** @hidden */
  86253. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  86254. /** @hidden */
  86255. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  86256. /**
  86257. * Binds a buffer to a uniform.
  86258. * @param buffer Buffer to bind.
  86259. * @param name Name of the uniform variable to bind to.
  86260. */
  86261. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  86262. /**
  86263. * Binds block to a uniform.
  86264. * @param blockName Name of the block to bind.
  86265. * @param index Index to bind.
  86266. */
  86267. bindUniformBlock(blockName: string, index: number): void;
  86268. /**
  86269. * Sets an interger value on a uniform variable.
  86270. * @param uniformName Name of the variable.
  86271. * @param value Value to be set.
  86272. * @returns this effect.
  86273. */
  86274. setInt(uniformName: string, value: number): Effect;
  86275. /**
  86276. * Sets an int array on a uniform variable.
  86277. * @param uniformName Name of the variable.
  86278. * @param array array to be set.
  86279. * @returns this effect.
  86280. */
  86281. setIntArray(uniformName: string, array: Int32Array): Effect;
  86282. /**
  86283. * 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)
  86284. * @param uniformName Name of the variable.
  86285. * @param array array to be set.
  86286. * @returns this effect.
  86287. */
  86288. setIntArray2(uniformName: string, array: Int32Array): Effect;
  86289. /**
  86290. * 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)
  86291. * @param uniformName Name of the variable.
  86292. * @param array array to be set.
  86293. * @returns this effect.
  86294. */
  86295. setIntArray3(uniformName: string, array: Int32Array): Effect;
  86296. /**
  86297. * 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)
  86298. * @param uniformName Name of the variable.
  86299. * @param array array to be set.
  86300. * @returns this effect.
  86301. */
  86302. setIntArray4(uniformName: string, array: Int32Array): Effect;
  86303. /**
  86304. * Sets an float array on a uniform variable.
  86305. * @param uniformName Name of the variable.
  86306. * @param array array to be set.
  86307. * @returns this effect.
  86308. */
  86309. setFloatArray(uniformName: string, array: Float32Array): Effect;
  86310. /**
  86311. * 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)
  86312. * @param uniformName Name of the variable.
  86313. * @param array array to be set.
  86314. * @returns this effect.
  86315. */
  86316. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  86317. /**
  86318. * 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)
  86319. * @param uniformName Name of the variable.
  86320. * @param array array to be set.
  86321. * @returns this effect.
  86322. */
  86323. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  86324. /**
  86325. * 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)
  86326. * @param uniformName Name of the variable.
  86327. * @param array array to be set.
  86328. * @returns this effect.
  86329. */
  86330. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  86331. /**
  86332. * Sets an array on a uniform variable.
  86333. * @param uniformName Name of the variable.
  86334. * @param array array to be set.
  86335. * @returns this effect.
  86336. */
  86337. setArray(uniformName: string, array: number[]): Effect;
  86338. /**
  86339. * 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)
  86340. * @param uniformName Name of the variable.
  86341. * @param array array to be set.
  86342. * @returns this effect.
  86343. */
  86344. setArray2(uniformName: string, array: number[]): Effect;
  86345. /**
  86346. * 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)
  86347. * @param uniformName Name of the variable.
  86348. * @param array array to be set.
  86349. * @returns this effect.
  86350. */
  86351. setArray3(uniformName: string, array: number[]): Effect;
  86352. /**
  86353. * 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)
  86354. * @param uniformName Name of the variable.
  86355. * @param array array to be set.
  86356. * @returns this effect.
  86357. */
  86358. setArray4(uniformName: string, array: number[]): Effect;
  86359. /**
  86360. * Sets matrices on a uniform variable.
  86361. * @param uniformName Name of the variable.
  86362. * @param matrices matrices to be set.
  86363. * @returns this effect.
  86364. */
  86365. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  86366. /**
  86367. * Sets matrix on a uniform variable.
  86368. * @param uniformName Name of the variable.
  86369. * @param matrix matrix to be set.
  86370. * @returns this effect.
  86371. */
  86372. setMatrix(uniformName: string, matrix: Matrix): Effect;
  86373. /**
  86374. * 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)
  86375. * @param uniformName Name of the variable.
  86376. * @param matrix matrix to be set.
  86377. * @returns this effect.
  86378. */
  86379. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  86380. /**
  86381. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  86382. * @param uniformName Name of the variable.
  86383. * @param matrix matrix to be set.
  86384. * @returns this effect.
  86385. */
  86386. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  86387. /**
  86388. * Sets a float on a uniform variable.
  86389. * @param uniformName Name of the variable.
  86390. * @param value value to be set.
  86391. * @returns this effect.
  86392. */
  86393. setFloat(uniformName: string, value: number): Effect;
  86394. /**
  86395. * Sets a boolean on a uniform variable.
  86396. * @param uniformName Name of the variable.
  86397. * @param bool value to be set.
  86398. * @returns this effect.
  86399. */
  86400. setBool(uniformName: string, bool: boolean): Effect;
  86401. /**
  86402. * Sets a Vector2 on a uniform variable.
  86403. * @param uniformName Name of the variable.
  86404. * @param vector2 vector2 to be set.
  86405. * @returns this effect.
  86406. */
  86407. setVector2(uniformName: string, vector2: Vector2): Effect;
  86408. /**
  86409. * Sets a float2 on a uniform variable.
  86410. * @param uniformName Name of the variable.
  86411. * @param x First float in float2.
  86412. * @param y Second float in float2.
  86413. * @returns this effect.
  86414. */
  86415. setFloat2(uniformName: string, x: number, y: number): Effect;
  86416. /**
  86417. * Sets a Vector3 on a uniform variable.
  86418. * @param uniformName Name of the variable.
  86419. * @param vector3 Value to be set.
  86420. * @returns this effect.
  86421. */
  86422. setVector3(uniformName: string, vector3: Vector3): Effect;
  86423. /**
  86424. * Sets a float3 on a uniform variable.
  86425. * @param uniformName Name of the variable.
  86426. * @param x First float in float3.
  86427. * @param y Second float in float3.
  86428. * @param z Third float in float3.
  86429. * @returns this effect.
  86430. */
  86431. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  86432. /**
  86433. * Sets a Vector4 on a uniform variable.
  86434. * @param uniformName Name of the variable.
  86435. * @param vector4 Value to be set.
  86436. * @returns this effect.
  86437. */
  86438. setVector4(uniformName: string, vector4: Vector4): Effect;
  86439. /**
  86440. * Sets a float4 on a uniform variable.
  86441. * @param uniformName Name of the variable.
  86442. * @param x First float in float4.
  86443. * @param y Second float in float4.
  86444. * @param z Third float in float4.
  86445. * @param w Fourth float in float4.
  86446. * @returns this effect.
  86447. */
  86448. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  86449. /**
  86450. * Sets a Color3 on a uniform variable.
  86451. * @param uniformName Name of the variable.
  86452. * @param color3 Value to be set.
  86453. * @returns this effect.
  86454. */
  86455. setColor3(uniformName: string, color3: Color3): Effect;
  86456. /**
  86457. * Sets a Color4 on a uniform variable.
  86458. * @param uniformName Name of the variable.
  86459. * @param color3 Value to be set.
  86460. * @param alpha Alpha value to be set.
  86461. * @returns this effect.
  86462. */
  86463. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  86464. /**
  86465. * Sets a Color4 on a uniform variable
  86466. * @param uniformName defines the name of the variable
  86467. * @param color4 defines the value to be set
  86468. * @returns this effect.
  86469. */
  86470. setDirectColor4(uniformName: string, color4: Color4): Effect;
  86471. /**
  86472. * This function will add a new shader to the shader store
  86473. * @param name the name of the shader
  86474. * @param pixelShader optional pixel shader content
  86475. * @param vertexShader optional vertex shader content
  86476. */
  86477. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  86478. /**
  86479. * Store of each shader (The can be looked up using effect.key)
  86480. */
  86481. static ShadersStore: {
  86482. [key: string]: string;
  86483. };
  86484. /**
  86485. * Store of each included file for a shader (The can be looked up using effect.key)
  86486. */
  86487. static IncludesShadersStore: {
  86488. [key: string]: string;
  86489. };
  86490. /**
  86491. * Resets the cache of effects.
  86492. */
  86493. static ResetCache(): void;
  86494. }
  86495. }
  86496. declare module BABYLON {
  86497. /**
  86498. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  86499. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  86500. * 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;
  86501. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  86502. */
  86503. export class ColorCurves {
  86504. private _dirty;
  86505. private _tempColor;
  86506. private _globalCurve;
  86507. private _highlightsCurve;
  86508. private _midtonesCurve;
  86509. private _shadowsCurve;
  86510. private _positiveCurve;
  86511. private _negativeCurve;
  86512. private _globalHue;
  86513. private _globalDensity;
  86514. private _globalSaturation;
  86515. private _globalExposure;
  86516. /**
  86517. * Gets the global Hue value.
  86518. * 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).
  86519. */
  86520. /**
  86521. * Sets the global Hue value.
  86522. * 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).
  86523. */
  86524. globalHue: number;
  86525. /**
  86526. * Gets the global Density value.
  86527. * 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.
  86528. * Values less than zero provide a filter of opposite hue.
  86529. */
  86530. /**
  86531. * Sets the global Density value.
  86532. * 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.
  86533. * Values less than zero provide a filter of opposite hue.
  86534. */
  86535. globalDensity: number;
  86536. /**
  86537. * Gets the global Saturation value.
  86538. * 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.
  86539. */
  86540. /**
  86541. * Sets the global Saturation value.
  86542. * 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.
  86543. */
  86544. globalSaturation: number;
  86545. /**
  86546. * Gets the global Exposure value.
  86547. * 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.
  86548. */
  86549. /**
  86550. * Sets the global Exposure value.
  86551. * 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.
  86552. */
  86553. globalExposure: number;
  86554. private _highlightsHue;
  86555. private _highlightsDensity;
  86556. private _highlightsSaturation;
  86557. private _highlightsExposure;
  86558. /**
  86559. * Gets the highlights Hue value.
  86560. * 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).
  86561. */
  86562. /**
  86563. * Sets the highlights Hue value.
  86564. * 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).
  86565. */
  86566. highlightsHue: number;
  86567. /**
  86568. * Gets the highlights Density value.
  86569. * 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.
  86570. * Values less than zero provide a filter of opposite hue.
  86571. */
  86572. /**
  86573. * Sets the highlights Density value.
  86574. * 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.
  86575. * Values less than zero provide a filter of opposite hue.
  86576. */
  86577. highlightsDensity: number;
  86578. /**
  86579. * Gets the highlights Saturation value.
  86580. * 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.
  86581. */
  86582. /**
  86583. * Sets the highlights Saturation value.
  86584. * 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.
  86585. */
  86586. highlightsSaturation: number;
  86587. /**
  86588. * Gets the highlights Exposure value.
  86589. * 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.
  86590. */
  86591. /**
  86592. * Sets the highlights Exposure value.
  86593. * 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.
  86594. */
  86595. highlightsExposure: number;
  86596. private _midtonesHue;
  86597. private _midtonesDensity;
  86598. private _midtonesSaturation;
  86599. private _midtonesExposure;
  86600. /**
  86601. * Gets the midtones Hue value.
  86602. * 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).
  86603. */
  86604. /**
  86605. * Sets the midtones Hue value.
  86606. * 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).
  86607. */
  86608. midtonesHue: number;
  86609. /**
  86610. * Gets the midtones Density value.
  86611. * 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.
  86612. * Values less than zero provide a filter of opposite hue.
  86613. */
  86614. /**
  86615. * Sets the midtones Density value.
  86616. * 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.
  86617. * Values less than zero provide a filter of opposite hue.
  86618. */
  86619. midtonesDensity: number;
  86620. /**
  86621. * Gets the midtones Saturation value.
  86622. * 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.
  86623. */
  86624. /**
  86625. * Sets the midtones Saturation value.
  86626. * 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.
  86627. */
  86628. midtonesSaturation: number;
  86629. /**
  86630. * Gets the midtones Exposure value.
  86631. * 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.
  86632. */
  86633. /**
  86634. * Sets the midtones Exposure value.
  86635. * 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.
  86636. */
  86637. midtonesExposure: number;
  86638. private _shadowsHue;
  86639. private _shadowsDensity;
  86640. private _shadowsSaturation;
  86641. private _shadowsExposure;
  86642. /**
  86643. * Gets the shadows Hue value.
  86644. * 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).
  86645. */
  86646. /**
  86647. * Sets the shadows Hue value.
  86648. * 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).
  86649. */
  86650. shadowsHue: number;
  86651. /**
  86652. * Gets the shadows Density value.
  86653. * 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.
  86654. * Values less than zero provide a filter of opposite hue.
  86655. */
  86656. /**
  86657. * Sets the shadows Density value.
  86658. * 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.
  86659. * Values less than zero provide a filter of opposite hue.
  86660. */
  86661. shadowsDensity: number;
  86662. /**
  86663. * Gets the shadows Saturation value.
  86664. * 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.
  86665. */
  86666. /**
  86667. * Sets the shadows Saturation value.
  86668. * 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.
  86669. */
  86670. shadowsSaturation: number;
  86671. /**
  86672. * Gets the shadows Exposure value.
  86673. * 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.
  86674. */
  86675. /**
  86676. * Sets the shadows Exposure value.
  86677. * 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.
  86678. */
  86679. shadowsExposure: number;
  86680. /**
  86681. * Returns the class name
  86682. * @returns The class name
  86683. */
  86684. getClassName(): string;
  86685. /**
  86686. * Binds the color curves to the shader.
  86687. * @param colorCurves The color curve to bind
  86688. * @param effect The effect to bind to
  86689. * @param positiveUniform The positive uniform shader parameter
  86690. * @param neutralUniform The neutral uniform shader parameter
  86691. * @param negativeUniform The negative uniform shader parameter
  86692. */
  86693. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  86694. /**
  86695. * Prepare the list of uniforms associated with the ColorCurves effects.
  86696. * @param uniformsList The list of uniforms used in the effect
  86697. */
  86698. static PrepareUniforms(uniformsList: string[]): void;
  86699. /**
  86700. * Returns color grading data based on a hue, density, saturation and exposure value.
  86701. * @param filterHue The hue of the color filter.
  86702. * @param filterDensity The density of the color filter.
  86703. * @param saturation The saturation.
  86704. * @param exposure The exposure.
  86705. * @param result The result data container.
  86706. */
  86707. private getColorGradingDataToRef;
  86708. /**
  86709. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  86710. * @param value The input slider value in range [-100,100].
  86711. * @returns Adjusted value.
  86712. */
  86713. private static applyColorGradingSliderNonlinear;
  86714. /**
  86715. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  86716. * @param hue The hue (H) input.
  86717. * @param saturation The saturation (S) input.
  86718. * @param brightness The brightness (B) input.
  86719. * @result An RGBA color represented as Vector4.
  86720. */
  86721. private static fromHSBToRef;
  86722. /**
  86723. * Returns a value clamped between min and max
  86724. * @param value The value to clamp
  86725. * @param min The minimum of value
  86726. * @param max The maximum of value
  86727. * @returns The clamped value.
  86728. */
  86729. private static clamp;
  86730. /**
  86731. * Clones the current color curve instance.
  86732. * @return The cloned curves
  86733. */
  86734. clone(): ColorCurves;
  86735. /**
  86736. * Serializes the current color curve instance to a json representation.
  86737. * @return a JSON representation
  86738. */
  86739. serialize(): any;
  86740. /**
  86741. * Parses the color curve from a json representation.
  86742. * @param source the JSON source to parse
  86743. * @return The parsed curves
  86744. */
  86745. static Parse(source: any): ColorCurves;
  86746. }
  86747. }
  86748. declare module BABYLON {
  86749. /**
  86750. * Interface to follow in your material defines to integrate easily the
  86751. * Image proccessing functions.
  86752. * @hidden
  86753. */
  86754. export interface IImageProcessingConfigurationDefines {
  86755. IMAGEPROCESSING: boolean;
  86756. VIGNETTE: boolean;
  86757. VIGNETTEBLENDMODEMULTIPLY: boolean;
  86758. VIGNETTEBLENDMODEOPAQUE: boolean;
  86759. TONEMAPPING: boolean;
  86760. TONEMAPPING_ACES: boolean;
  86761. CONTRAST: boolean;
  86762. EXPOSURE: boolean;
  86763. COLORCURVES: boolean;
  86764. COLORGRADING: boolean;
  86765. COLORGRADING3D: boolean;
  86766. SAMPLER3DGREENDEPTH: boolean;
  86767. SAMPLER3DBGRMAP: boolean;
  86768. IMAGEPROCESSINGPOSTPROCESS: boolean;
  86769. }
  86770. /**
  86771. * @hidden
  86772. */
  86773. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  86774. IMAGEPROCESSING: boolean;
  86775. VIGNETTE: boolean;
  86776. VIGNETTEBLENDMODEMULTIPLY: boolean;
  86777. VIGNETTEBLENDMODEOPAQUE: boolean;
  86778. TONEMAPPING: boolean;
  86779. TONEMAPPING_ACES: boolean;
  86780. CONTRAST: boolean;
  86781. COLORCURVES: boolean;
  86782. COLORGRADING: boolean;
  86783. COLORGRADING3D: boolean;
  86784. SAMPLER3DGREENDEPTH: boolean;
  86785. SAMPLER3DBGRMAP: boolean;
  86786. IMAGEPROCESSINGPOSTPROCESS: boolean;
  86787. EXPOSURE: boolean;
  86788. constructor();
  86789. }
  86790. /**
  86791. * This groups together the common properties used for image processing either in direct forward pass
  86792. * or through post processing effect depending on the use of the image processing pipeline in your scene
  86793. * or not.
  86794. */
  86795. export class ImageProcessingConfiguration {
  86796. /**
  86797. * Default tone mapping applied in BabylonJS.
  86798. */
  86799. static readonly TONEMAPPING_STANDARD: number;
  86800. /**
  86801. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  86802. * to other engines rendering to increase portability.
  86803. */
  86804. static readonly TONEMAPPING_ACES: number;
  86805. /**
  86806. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  86807. */
  86808. colorCurves: Nullable<ColorCurves>;
  86809. private _colorCurvesEnabled;
  86810. /**
  86811. * Gets wether the color curves effect is enabled.
  86812. */
  86813. /**
  86814. * Sets wether the color curves effect is enabled.
  86815. */
  86816. colorCurvesEnabled: boolean;
  86817. private _colorGradingTexture;
  86818. /**
  86819. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  86820. */
  86821. /**
  86822. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  86823. */
  86824. colorGradingTexture: Nullable<BaseTexture>;
  86825. private _colorGradingEnabled;
  86826. /**
  86827. * Gets wether the color grading effect is enabled.
  86828. */
  86829. /**
  86830. * Sets wether the color grading effect is enabled.
  86831. */
  86832. colorGradingEnabled: boolean;
  86833. private _colorGradingWithGreenDepth;
  86834. /**
  86835. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  86836. */
  86837. /**
  86838. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  86839. */
  86840. colorGradingWithGreenDepth: boolean;
  86841. private _colorGradingBGR;
  86842. /**
  86843. * Gets wether the color grading texture contains BGR values.
  86844. */
  86845. /**
  86846. * Sets wether the color grading texture contains BGR values.
  86847. */
  86848. colorGradingBGR: boolean;
  86849. /** @hidden */
  86850. _exposure: number;
  86851. /**
  86852. * Gets the Exposure used in the effect.
  86853. */
  86854. /**
  86855. * Sets the Exposure used in the effect.
  86856. */
  86857. exposure: number;
  86858. private _toneMappingEnabled;
  86859. /**
  86860. * Gets wether the tone mapping effect is enabled.
  86861. */
  86862. /**
  86863. * Sets wether the tone mapping effect is enabled.
  86864. */
  86865. toneMappingEnabled: boolean;
  86866. private _toneMappingType;
  86867. /**
  86868. * Gets the type of tone mapping effect.
  86869. */
  86870. /**
  86871. * Sets the type of tone mapping effect used in BabylonJS.
  86872. */
  86873. toneMappingType: number;
  86874. protected _contrast: number;
  86875. /**
  86876. * Gets the contrast used in the effect.
  86877. */
  86878. /**
  86879. * Sets the contrast used in the effect.
  86880. */
  86881. contrast: number;
  86882. /**
  86883. * Vignette stretch size.
  86884. */
  86885. vignetteStretch: number;
  86886. /**
  86887. * Vignette centre X Offset.
  86888. */
  86889. vignetteCentreX: number;
  86890. /**
  86891. * Vignette centre Y Offset.
  86892. */
  86893. vignetteCentreY: number;
  86894. /**
  86895. * Vignette weight or intensity of the vignette effect.
  86896. */
  86897. vignetteWeight: number;
  86898. /**
  86899. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  86900. * if vignetteEnabled is set to true.
  86901. */
  86902. vignetteColor: Color4;
  86903. /**
  86904. * Camera field of view used by the Vignette effect.
  86905. */
  86906. vignetteCameraFov: number;
  86907. private _vignetteBlendMode;
  86908. /**
  86909. * Gets the vignette blend mode allowing different kind of effect.
  86910. */
  86911. /**
  86912. * Sets the vignette blend mode allowing different kind of effect.
  86913. */
  86914. vignetteBlendMode: number;
  86915. private _vignetteEnabled;
  86916. /**
  86917. * Gets wether the vignette effect is enabled.
  86918. */
  86919. /**
  86920. * Sets wether the vignette effect is enabled.
  86921. */
  86922. vignetteEnabled: boolean;
  86923. private _applyByPostProcess;
  86924. /**
  86925. * Gets wether the image processing is applied through a post process or not.
  86926. */
  86927. /**
  86928. * Sets wether the image processing is applied through a post process or not.
  86929. */
  86930. applyByPostProcess: boolean;
  86931. private _isEnabled;
  86932. /**
  86933. * Gets wether the image processing is enabled or not.
  86934. */
  86935. /**
  86936. * Sets wether the image processing is enabled or not.
  86937. */
  86938. isEnabled: boolean;
  86939. /**
  86940. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  86941. */
  86942. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  86943. /**
  86944. * Method called each time the image processing information changes requires to recompile the effect.
  86945. */
  86946. protected _updateParameters(): void;
  86947. /**
  86948. * Gets the current class name.
  86949. * @return "ImageProcessingConfiguration"
  86950. */
  86951. getClassName(): string;
  86952. /**
  86953. * Prepare the list of uniforms associated with the Image Processing effects.
  86954. * @param uniforms The list of uniforms used in the effect
  86955. * @param defines the list of defines currently in use
  86956. */
  86957. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  86958. /**
  86959. * Prepare the list of samplers associated with the Image Processing effects.
  86960. * @param samplersList The list of uniforms used in the effect
  86961. * @param defines the list of defines currently in use
  86962. */
  86963. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  86964. /**
  86965. * Prepare the list of defines associated to the shader.
  86966. * @param defines the list of defines to complete
  86967. * @param forPostProcess Define if we are currently in post process mode or not
  86968. */
  86969. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  86970. /**
  86971. * Returns true if all the image processing information are ready.
  86972. * @returns True if ready, otherwise, false
  86973. */
  86974. isReady(): boolean;
  86975. /**
  86976. * Binds the image processing to the shader.
  86977. * @param effect The effect to bind to
  86978. * @param aspectRatio Define the current aspect ratio of the effect
  86979. */
  86980. bind(effect: Effect, aspectRatio?: number): void;
  86981. /**
  86982. * Clones the current image processing instance.
  86983. * @return The cloned image processing
  86984. */
  86985. clone(): ImageProcessingConfiguration;
  86986. /**
  86987. * Serializes the current image processing instance to a json representation.
  86988. * @return a JSON representation
  86989. */
  86990. serialize(): any;
  86991. /**
  86992. * Parses the image processing from a json representation.
  86993. * @param source the JSON source to parse
  86994. * @return The parsed image processing
  86995. */
  86996. static Parse(source: any): ImageProcessingConfiguration;
  86997. private static _VIGNETTEMODE_MULTIPLY;
  86998. private static _VIGNETTEMODE_OPAQUE;
  86999. /**
  87000. * Used to apply the vignette as a mix with the pixel color.
  87001. */
  87002. static readonly VIGNETTEMODE_MULTIPLY: number;
  87003. /**
  87004. * Used to apply the vignette as a replacement of the pixel color.
  87005. */
  87006. static readonly VIGNETTEMODE_OPAQUE: number;
  87007. }
  87008. }
  87009. declare module BABYLON {
  87010. /**
  87011. * This represents all the required information to add a fresnel effect on a material:
  87012. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  87013. */
  87014. export class FresnelParameters {
  87015. private _isEnabled;
  87016. /**
  87017. * Define if the fresnel effect is enable or not.
  87018. */
  87019. isEnabled: boolean;
  87020. /**
  87021. * Define the color used on edges (grazing angle)
  87022. */
  87023. leftColor: Color3;
  87024. /**
  87025. * Define the color used on center
  87026. */
  87027. rightColor: Color3;
  87028. /**
  87029. * Define bias applied to computed fresnel term
  87030. */
  87031. bias: number;
  87032. /**
  87033. * Defined the power exponent applied to fresnel term
  87034. */
  87035. power: number;
  87036. /**
  87037. * Clones the current fresnel and its valuues
  87038. * @returns a clone fresnel configuration
  87039. */
  87040. clone(): FresnelParameters;
  87041. /**
  87042. * Serializes the current fresnel parameters to a JSON representation.
  87043. * @return the JSON serialization
  87044. */
  87045. serialize(): any;
  87046. /**
  87047. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  87048. * @param parsedFresnelParameters Define the JSON representation
  87049. * @returns the parsed parameters
  87050. */
  87051. static Parse(parsedFresnelParameters: any): FresnelParameters;
  87052. }
  87053. }
  87054. declare module BABYLON {
  87055. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  87056. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  87057. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  87058. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  87059. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  87060. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  87061. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  87062. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  87063. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  87064. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  87065. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  87066. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  87067. /**
  87068. * Decorator used to define property that can be serialized as reference to a camera
  87069. * @param sourceName defines the name of the property to decorate
  87070. */
  87071. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  87072. /**
  87073. * Class used to help serialization objects
  87074. */
  87075. export class SerializationHelper {
  87076. /** hidden */
  87077. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  87078. /** hidden */
  87079. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  87080. /** hidden */
  87081. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  87082. /** hidden */
  87083. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  87084. /**
  87085. * Appends the serialized animations from the source animations
  87086. * @param source Source containing the animations
  87087. * @param destination Target to store the animations
  87088. */
  87089. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  87090. /**
  87091. * Static function used to serialized a specific entity
  87092. * @param entity defines the entity to serialize
  87093. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  87094. * @returns a JSON compatible object representing the serialization of the entity
  87095. */
  87096. static Serialize<T>(entity: T, serializationObject?: any): any;
  87097. /**
  87098. * Creates a new entity from a serialization data object
  87099. * @param creationFunction defines a function used to instanciated the new entity
  87100. * @param source defines the source serialization data
  87101. * @param scene defines the hosting scene
  87102. * @param rootUrl defines the root url for resources
  87103. * @returns a new entity
  87104. */
  87105. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  87106. /**
  87107. * Clones an object
  87108. * @param creationFunction defines the function used to instanciate the new object
  87109. * @param source defines the source object
  87110. * @returns the cloned object
  87111. */
  87112. static Clone<T>(creationFunction: () => T, source: T): T;
  87113. /**
  87114. * Instanciates a new object based on a source one (some data will be shared between both object)
  87115. * @param creationFunction defines the function used to instanciate the new object
  87116. * @param source defines the source object
  87117. * @returns the new object
  87118. */
  87119. static Instanciate<T>(creationFunction: () => T, source: T): T;
  87120. }
  87121. }
  87122. declare module BABYLON {
  87123. /**
  87124. * This is the base class of all the camera used in the application.
  87125. * @see http://doc.babylonjs.com/features/cameras
  87126. */
  87127. export class Camera extends Node {
  87128. /** @hidden */
  87129. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  87130. /**
  87131. * This is the default projection mode used by the cameras.
  87132. * It helps recreating a feeling of perspective and better appreciate depth.
  87133. * This is the best way to simulate real life cameras.
  87134. */
  87135. static readonly PERSPECTIVE_CAMERA: number;
  87136. /**
  87137. * This helps creating camera with an orthographic mode.
  87138. * 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.
  87139. */
  87140. static readonly ORTHOGRAPHIC_CAMERA: number;
  87141. /**
  87142. * This is the default FOV mode for perspective cameras.
  87143. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  87144. */
  87145. static readonly FOVMODE_VERTICAL_FIXED: number;
  87146. /**
  87147. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  87148. */
  87149. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  87150. /**
  87151. * This specifies ther is no need for a camera rig.
  87152. * Basically only one eye is rendered corresponding to the camera.
  87153. */
  87154. static readonly RIG_MODE_NONE: number;
  87155. /**
  87156. * Simulates a camera Rig with one blue eye and one red eye.
  87157. * This can be use with 3d blue and red glasses.
  87158. */
  87159. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  87160. /**
  87161. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  87162. */
  87163. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  87164. /**
  87165. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  87166. */
  87167. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  87168. /**
  87169. * Defines that both eyes of the camera will be rendered over under each other.
  87170. */
  87171. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  87172. /**
  87173. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  87174. */
  87175. static readonly RIG_MODE_VR: number;
  87176. /**
  87177. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  87178. */
  87179. static readonly RIG_MODE_WEBVR: number;
  87180. /**
  87181. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  87182. */
  87183. static readonly RIG_MODE_CUSTOM: number;
  87184. /**
  87185. * Defines if by default attaching controls should prevent the default javascript event to continue.
  87186. */
  87187. static ForceAttachControlToAlwaysPreventDefault: boolean;
  87188. /**
  87189. * @hidden
  87190. * Might be removed once multiview will be a thing
  87191. */
  87192. static UseAlternateWebVRRendering: boolean;
  87193. /**
  87194. * Define the input manager associated with the camera.
  87195. */
  87196. inputs: CameraInputsManager<Camera>;
  87197. /** @hidden */
  87198. _position: Vector3;
  87199. /**
  87200. * Define the current local position of the camera in the scene
  87201. */
  87202. position: Vector3;
  87203. /**
  87204. * The vector the camera should consider as up.
  87205. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  87206. */
  87207. upVector: Vector3;
  87208. /**
  87209. * Define the current limit on the left side for an orthographic camera
  87210. * In scene unit
  87211. */
  87212. orthoLeft: Nullable<number>;
  87213. /**
  87214. * Define the current limit on the right side for an orthographic camera
  87215. * In scene unit
  87216. */
  87217. orthoRight: Nullable<number>;
  87218. /**
  87219. * Define the current limit on the bottom side for an orthographic camera
  87220. * In scene unit
  87221. */
  87222. orthoBottom: Nullable<number>;
  87223. /**
  87224. * Define the current limit on the top side for an orthographic camera
  87225. * In scene unit
  87226. */
  87227. orthoTop: Nullable<number>;
  87228. /**
  87229. * Field Of View is set in Radians. (default is 0.8)
  87230. */
  87231. fov: number;
  87232. /**
  87233. * Define the minimum distance the camera can see from.
  87234. * This is important to note that the depth buffer are not infinite and the closer it starts
  87235. * the more your scene might encounter depth fighting issue.
  87236. */
  87237. minZ: number;
  87238. /**
  87239. * Define the maximum distance the camera can see to.
  87240. * This is important to note that the depth buffer are not infinite and the further it end
  87241. * the more your scene might encounter depth fighting issue.
  87242. */
  87243. maxZ: number;
  87244. /**
  87245. * Define the default inertia of the camera.
  87246. * This helps giving a smooth feeling to the camera movement.
  87247. */
  87248. inertia: number;
  87249. /**
  87250. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  87251. */
  87252. mode: number;
  87253. /**
  87254. * Define wether the camera is intermediate.
  87255. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  87256. */
  87257. isIntermediate: boolean;
  87258. /**
  87259. * Define the viewport of the camera.
  87260. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  87261. */
  87262. viewport: Viewport;
  87263. /**
  87264. * Restricts the camera to viewing objects with the same layerMask.
  87265. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  87266. */
  87267. layerMask: number;
  87268. /**
  87269. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  87270. */
  87271. fovMode: number;
  87272. /**
  87273. * Rig mode of the camera.
  87274. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  87275. * This is normally controlled byt the camera themselves as internal use.
  87276. */
  87277. cameraRigMode: number;
  87278. /**
  87279. * Defines the distance between both "eyes" in case of a RIG
  87280. */
  87281. interaxialDistance: number;
  87282. /**
  87283. * Defines if stereoscopic rendering is done side by side or over under.
  87284. */
  87285. isStereoscopicSideBySide: boolean;
  87286. /**
  87287. * 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
  87288. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  87289. * else in the scene.
  87290. */
  87291. customRenderTargets: RenderTargetTexture[];
  87292. /**
  87293. * When set, the camera will render to this render target instead of the default canvas
  87294. */
  87295. outputRenderTarget: Nullable<RenderTargetTexture>;
  87296. /**
  87297. * Observable triggered when the camera view matrix has changed.
  87298. */
  87299. onViewMatrixChangedObservable: Observable<Camera>;
  87300. /**
  87301. * Observable triggered when the camera Projection matrix has changed.
  87302. */
  87303. onProjectionMatrixChangedObservable: Observable<Camera>;
  87304. /**
  87305. * Observable triggered when the inputs have been processed.
  87306. */
  87307. onAfterCheckInputsObservable: Observable<Camera>;
  87308. /**
  87309. * Observable triggered when reset has been called and applied to the camera.
  87310. */
  87311. onRestoreStateObservable: Observable<Camera>;
  87312. /** @hidden */
  87313. _cameraRigParams: any;
  87314. /** @hidden */
  87315. _rigCameras: Camera[];
  87316. /** @hidden */
  87317. _rigPostProcess: Nullable<PostProcess>;
  87318. protected _webvrViewMatrix: Matrix;
  87319. /** @hidden */
  87320. _skipRendering: boolean;
  87321. /** @hidden */
  87322. _alternateCamera: Camera;
  87323. /** @hidden */
  87324. _projectionMatrix: Matrix;
  87325. /** @hidden */
  87326. _postProcesses: Nullable<PostProcess>[];
  87327. /** @hidden */
  87328. _activeMeshes: SmartArray<AbstractMesh>;
  87329. protected _globalPosition: Vector3;
  87330. /** hidden */
  87331. _computedViewMatrix: Matrix;
  87332. private _doNotComputeProjectionMatrix;
  87333. private _transformMatrix;
  87334. private _frustumPlanes;
  87335. private _refreshFrustumPlanes;
  87336. private _storedFov;
  87337. private _stateStored;
  87338. /**
  87339. * Instantiates a new camera object.
  87340. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  87341. * @see http://doc.babylonjs.com/features/cameras
  87342. * @param name Defines the name of the camera in the scene
  87343. * @param position Defines the position of the camera
  87344. * @param scene Defines the scene the camera belongs too
  87345. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  87346. */
  87347. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  87348. /**
  87349. * Store current camera state (fov, position, etc..)
  87350. * @returns the camera
  87351. */
  87352. storeState(): Camera;
  87353. /**
  87354. * Restores the camera state values if it has been stored. You must call storeState() first
  87355. */
  87356. protected _restoreStateValues(): boolean;
  87357. /**
  87358. * Restored camera state. You must call storeState() first.
  87359. * @returns true if restored and false otherwise
  87360. */
  87361. restoreState(): boolean;
  87362. /**
  87363. * Gets the class name of the camera.
  87364. * @returns the class name
  87365. */
  87366. getClassName(): string;
  87367. /** @hidden */
  87368. readonly _isCamera: boolean;
  87369. /**
  87370. * Gets a string representation of the camera useful for debug purpose.
  87371. * @param fullDetails Defines that a more verboe level of logging is required
  87372. * @returns the string representation
  87373. */
  87374. toString(fullDetails?: boolean): string;
  87375. /**
  87376. * Gets the current world space position of the camera.
  87377. */
  87378. readonly globalPosition: Vector3;
  87379. /**
  87380. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  87381. * @returns the active meshe list
  87382. */
  87383. getActiveMeshes(): SmartArray<AbstractMesh>;
  87384. /**
  87385. * Check wether a mesh is part of the current active mesh list of the camera
  87386. * @param mesh Defines the mesh to check
  87387. * @returns true if active, false otherwise
  87388. */
  87389. isActiveMesh(mesh: Mesh): boolean;
  87390. /**
  87391. * Is this camera ready to be used/rendered
  87392. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  87393. * @return true if the camera is ready
  87394. */
  87395. isReady(completeCheck?: boolean): boolean;
  87396. /** @hidden */
  87397. _initCache(): void;
  87398. /** @hidden */
  87399. _updateCache(ignoreParentClass?: boolean): void;
  87400. /** @hidden */
  87401. _isSynchronized(): boolean;
  87402. /** @hidden */
  87403. _isSynchronizedViewMatrix(): boolean;
  87404. /** @hidden */
  87405. _isSynchronizedProjectionMatrix(): boolean;
  87406. /**
  87407. * Attach the input controls to a specific dom element to get the input from.
  87408. * @param element Defines the element the controls should be listened from
  87409. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  87410. */
  87411. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  87412. /**
  87413. * Detach the current controls from the specified dom element.
  87414. * @param element Defines the element to stop listening the inputs from
  87415. */
  87416. detachControl(element: HTMLElement): void;
  87417. /**
  87418. * Update the camera state according to the different inputs gathered during the frame.
  87419. */
  87420. update(): void;
  87421. /** @hidden */
  87422. _checkInputs(): void;
  87423. /** @hidden */
  87424. readonly rigCameras: Camera[];
  87425. /**
  87426. * Gets the post process used by the rig cameras
  87427. */
  87428. readonly rigPostProcess: Nullable<PostProcess>;
  87429. /**
  87430. * Internal, gets the first post proces.
  87431. * @returns the first post process to be run on this camera.
  87432. */
  87433. _getFirstPostProcess(): Nullable<PostProcess>;
  87434. private _cascadePostProcessesToRigCams;
  87435. /**
  87436. * Attach a post process to the camera.
  87437. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  87438. * @param postProcess The post process to attach to the camera
  87439. * @param insertAt The position of the post process in case several of them are in use in the scene
  87440. * @returns the position the post process has been inserted at
  87441. */
  87442. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  87443. /**
  87444. * Detach a post process to the camera.
  87445. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  87446. * @param postProcess The post process to detach from the camera
  87447. */
  87448. detachPostProcess(postProcess: PostProcess): void;
  87449. /**
  87450. * Gets the current world matrix of the camera
  87451. */
  87452. getWorldMatrix(): Matrix;
  87453. /** @hidden */
  87454. _getViewMatrix(): Matrix;
  87455. /**
  87456. * Gets the current view matrix of the camera.
  87457. * @param force forces the camera to recompute the matrix without looking at the cached state
  87458. * @returns the view matrix
  87459. */
  87460. getViewMatrix(force?: boolean): Matrix;
  87461. /**
  87462. * Freeze the projection matrix.
  87463. * It will prevent the cache check of the camera projection compute and can speed up perf
  87464. * if no parameter of the camera are meant to change
  87465. * @param projection Defines manually a projection if necessary
  87466. */
  87467. freezeProjectionMatrix(projection?: Matrix): void;
  87468. /**
  87469. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  87470. */
  87471. unfreezeProjectionMatrix(): void;
  87472. /**
  87473. * Gets the current projection matrix of the camera.
  87474. * @param force forces the camera to recompute the matrix without looking at the cached state
  87475. * @returns the projection matrix
  87476. */
  87477. getProjectionMatrix(force?: boolean): Matrix;
  87478. /**
  87479. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  87480. * @returns a Matrix
  87481. */
  87482. getTransformationMatrix(): Matrix;
  87483. private _updateFrustumPlanes;
  87484. /**
  87485. * Checks if a cullable object (mesh...) is in the camera frustum
  87486. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  87487. * @param target The object to check
  87488. * @returns true if the object is in frustum otherwise false
  87489. */
  87490. isInFrustum(target: ICullable): boolean;
  87491. /**
  87492. * Checks if a cullable object (mesh...) is in the camera frustum
  87493. * Unlike isInFrustum this cheks the full bounding box
  87494. * @param target The object to check
  87495. * @returns true if the object is in frustum otherwise false
  87496. */
  87497. isCompletelyInFrustum(target: ICullable): boolean;
  87498. /**
  87499. * Gets a ray in the forward direction from the camera.
  87500. * @param length Defines the length of the ray to create
  87501. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  87502. * @param origin Defines the start point of the ray which defaults to the camera position
  87503. * @returns the forward ray
  87504. */
  87505. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  87506. /**
  87507. * Releases resources associated with this node.
  87508. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  87509. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  87510. */
  87511. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  87512. /** @hidden */
  87513. _isLeftCamera: boolean;
  87514. /**
  87515. * Gets the left camera of a rig setup in case of Rigged Camera
  87516. */
  87517. readonly isLeftCamera: boolean;
  87518. /** @hidden */
  87519. _isRightCamera: boolean;
  87520. /**
  87521. * Gets the right camera of a rig setup in case of Rigged Camera
  87522. */
  87523. readonly isRightCamera: boolean;
  87524. /**
  87525. * Gets the left camera of a rig setup in case of Rigged Camera
  87526. */
  87527. readonly leftCamera: Nullable<FreeCamera>;
  87528. /**
  87529. * Gets the right camera of a rig setup in case of Rigged Camera
  87530. */
  87531. readonly rightCamera: Nullable<FreeCamera>;
  87532. /**
  87533. * Gets the left camera target of a rig setup in case of Rigged Camera
  87534. * @returns the target position
  87535. */
  87536. getLeftTarget(): Nullable<Vector3>;
  87537. /**
  87538. * Gets the right camera target of a rig setup in case of Rigged Camera
  87539. * @returns the target position
  87540. */
  87541. getRightTarget(): Nullable<Vector3>;
  87542. /**
  87543. * @hidden
  87544. */
  87545. setCameraRigMode(mode: number, rigParams: any): void;
  87546. /** @hidden */
  87547. static _setStereoscopicRigMode(camera: Camera): void;
  87548. /** @hidden */
  87549. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  87550. /** @hidden */
  87551. static _setVRRigMode(camera: Camera, rigParams: any): void;
  87552. /** @hidden */
  87553. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  87554. /** @hidden */
  87555. _getVRProjectionMatrix(): Matrix;
  87556. protected _updateCameraRotationMatrix(): void;
  87557. protected _updateWebVRCameraRotationMatrix(): void;
  87558. /**
  87559. * This function MUST be overwritten by the different WebVR cameras available.
  87560. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  87561. * @hidden
  87562. */
  87563. _getWebVRProjectionMatrix(): Matrix;
  87564. /**
  87565. * This function MUST be overwritten by the different WebVR cameras available.
  87566. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  87567. * @hidden
  87568. */
  87569. _getWebVRViewMatrix(): Matrix;
  87570. /** @hidden */
  87571. setCameraRigParameter(name: string, value: any): void;
  87572. /**
  87573. * needs to be overridden by children so sub has required properties to be copied
  87574. * @hidden
  87575. */
  87576. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  87577. /**
  87578. * May need to be overridden by children
  87579. * @hidden
  87580. */
  87581. _updateRigCameras(): void;
  87582. /** @hidden */
  87583. _setupInputs(): void;
  87584. /**
  87585. * Serialiaze the camera setup to a json represention
  87586. * @returns the JSON representation
  87587. */
  87588. serialize(): any;
  87589. /**
  87590. * Clones the current camera.
  87591. * @param name The cloned camera name
  87592. * @returns the cloned camera
  87593. */
  87594. clone(name: string): Camera;
  87595. /**
  87596. * Gets the direction of the camera relative to a given local axis.
  87597. * @param localAxis Defines the reference axis to provide a relative direction.
  87598. * @return the direction
  87599. */
  87600. getDirection(localAxis: Vector3): Vector3;
  87601. /**
  87602. * Gets the direction of the camera relative to a given local axis into a passed vector.
  87603. * @param localAxis Defines the reference axis to provide a relative direction.
  87604. * @param result Defines the vector to store the result in
  87605. */
  87606. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  87607. /**
  87608. * Gets a camera constructor for a given camera type
  87609. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  87610. * @param name The name of the camera the result will be able to instantiate
  87611. * @param scene The scene the result will construct the camera in
  87612. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  87613. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  87614. * @returns a factory method to construc the camera
  87615. */
  87616. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  87617. /**
  87618. * Compute the world matrix of the camera.
  87619. * @returns the camera workd matrix
  87620. */
  87621. computeWorldMatrix(): Matrix;
  87622. /**
  87623. * Parse a JSON and creates the camera from the parsed information
  87624. * @param parsedCamera The JSON to parse
  87625. * @param scene The scene to instantiate the camera in
  87626. * @returns the newly constructed camera
  87627. */
  87628. static Parse(parsedCamera: any, scene: Scene): Camera;
  87629. }
  87630. }
  87631. declare module BABYLON {
  87632. /**
  87633. * Interface for any object that can request an animation frame
  87634. */
  87635. export interface ICustomAnimationFrameRequester {
  87636. /**
  87637. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  87638. */
  87639. renderFunction?: Function;
  87640. /**
  87641. * Called to request the next frame to render to
  87642. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  87643. */
  87644. requestAnimationFrame: Function;
  87645. /**
  87646. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  87647. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  87648. */
  87649. requestID?: number;
  87650. }
  87651. /**
  87652. * Interface containing an array of animations
  87653. */
  87654. export interface IAnimatable {
  87655. /**
  87656. * Array of animations
  87657. */
  87658. animations: Array<Animation>;
  87659. }
  87660. /** Interface used by value gradients (color, factor, ...) */
  87661. export interface IValueGradient {
  87662. /**
  87663. * Gets or sets the gradient value (between 0 and 1)
  87664. */
  87665. gradient: number;
  87666. }
  87667. /** Class used to store color4 gradient */
  87668. export class ColorGradient implements IValueGradient {
  87669. /**
  87670. * Gets or sets the gradient value (between 0 and 1)
  87671. */
  87672. gradient: number;
  87673. /**
  87674. * Gets or sets first associated color
  87675. */
  87676. color1: Color4;
  87677. /**
  87678. * Gets or sets second associated color
  87679. */
  87680. color2?: Color4;
  87681. /**
  87682. * Will get a color picked randomly between color1 and color2.
  87683. * If color2 is undefined then color1 will be used
  87684. * @param result defines the target Color4 to store the result in
  87685. */
  87686. getColorToRef(result: Color4): void;
  87687. }
  87688. /** Class used to store color 3 gradient */
  87689. export class Color3Gradient implements IValueGradient {
  87690. /**
  87691. * Gets or sets the gradient value (between 0 and 1)
  87692. */
  87693. gradient: number;
  87694. /**
  87695. * Gets or sets the associated color
  87696. */
  87697. color: Color3;
  87698. }
  87699. /** Class used to store factor gradient */
  87700. export class FactorGradient implements IValueGradient {
  87701. /**
  87702. * Gets or sets the gradient value (between 0 and 1)
  87703. */
  87704. gradient: number;
  87705. /**
  87706. * Gets or sets first associated factor
  87707. */
  87708. factor1: number;
  87709. /**
  87710. * Gets or sets second associated factor
  87711. */
  87712. factor2?: number;
  87713. /**
  87714. * Will get a number picked randomly between factor1 and factor2.
  87715. * If factor2 is undefined then factor1 will be used
  87716. * @returns the picked number
  87717. */
  87718. getFactor(): number;
  87719. }
  87720. /**
  87721. * @ignore
  87722. * Application error to support additional information when loading a file
  87723. */
  87724. export class LoadFileError extends Error {
  87725. /** defines the optional XHR request */
  87726. request?: XMLHttpRequest | undefined;
  87727. private static _setPrototypeOf;
  87728. /**
  87729. * Creates a new LoadFileError
  87730. * @param message defines the message of the error
  87731. * @param request defines the optional XHR request
  87732. */
  87733. constructor(message: string,
  87734. /** defines the optional XHR request */
  87735. request?: XMLHttpRequest | undefined);
  87736. }
  87737. /**
  87738. * Class used to define a retry strategy when error happens while loading assets
  87739. */
  87740. export class RetryStrategy {
  87741. /**
  87742. * Function used to defines an exponential back off strategy
  87743. * @param maxRetries defines the maximum number of retries (3 by default)
  87744. * @param baseInterval defines the interval between retries
  87745. * @returns the strategy function to use
  87746. */
  87747. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  87748. }
  87749. /**
  87750. * File request interface
  87751. */
  87752. export interface IFileRequest {
  87753. /**
  87754. * Raised when the request is complete (success or error).
  87755. */
  87756. onCompleteObservable: Observable<IFileRequest>;
  87757. /**
  87758. * Aborts the request for a file.
  87759. */
  87760. abort: () => void;
  87761. }
  87762. /**
  87763. * Class containing a set of static utilities functions
  87764. */
  87765. export class Tools {
  87766. /**
  87767. * Gets or sets the base URL to use to load assets
  87768. */
  87769. static BaseUrl: string;
  87770. /**
  87771. * Enable/Disable Custom HTTP Request Headers globally.
  87772. * default = false
  87773. * @see CustomRequestHeaders
  87774. */
  87775. static UseCustomRequestHeaders: boolean;
  87776. /**
  87777. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  87778. * i.e. when loading files, where the server/service expects an Authorization header
  87779. */
  87780. static CustomRequestHeaders: {
  87781. [key: string]: string;
  87782. };
  87783. /**
  87784. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  87785. */
  87786. static DefaultRetryStrategy: (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  87787. /**
  87788. * Default behaviour for cors in the application.
  87789. * It can be a string if the expected behavior is identical in the entire app.
  87790. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  87791. */
  87792. static CorsBehavior: string | ((url: string | string[]) => string);
  87793. /**
  87794. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  87795. * @ignorenaming
  87796. */
  87797. static UseFallbackTexture: boolean;
  87798. /**
  87799. * Use this object to register external classes like custom textures or material
  87800. * to allow the laoders to instantiate them
  87801. */
  87802. static RegisteredExternalClasses: {
  87803. [key: string]: Object;
  87804. };
  87805. /**
  87806. * Texture content used if a texture cannot loaded
  87807. * @ignorenaming
  87808. */
  87809. static fallbackTexture: string;
  87810. /**
  87811. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  87812. * @param u defines the coordinate on X axis
  87813. * @param v defines the coordinate on Y axis
  87814. * @param width defines the width of the source data
  87815. * @param height defines the height of the source data
  87816. * @param pixels defines the source byte array
  87817. * @param color defines the output color
  87818. */
  87819. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  87820. /**
  87821. * Interpolates between a and b via alpha
  87822. * @param a The lower value (returned when alpha = 0)
  87823. * @param b The upper value (returned when alpha = 1)
  87824. * @param alpha The interpolation-factor
  87825. * @return The mixed value
  87826. */
  87827. static Mix(a: number, b: number, alpha: number): number;
  87828. /**
  87829. * Tries to instantiate a new object from a given class name
  87830. * @param className defines the class name to instantiate
  87831. * @returns the new object or null if the system was not able to do the instantiation
  87832. */
  87833. static Instantiate(className: string): any;
  87834. /**
  87835. * Provides a slice function that will work even on IE
  87836. * @param data defines the array to slice
  87837. * @param start defines the start of the data (optional)
  87838. * @param end defines the end of the data (optional)
  87839. * @returns the new sliced array
  87840. */
  87841. static Slice<T>(data: T, start?: number, end?: number): T;
  87842. /**
  87843. * Polyfill for setImmediate
  87844. * @param action defines the action to execute after the current execution block
  87845. */
  87846. static SetImmediate(action: () => void): void;
  87847. /**
  87848. * Function indicating if a number is an exponent of 2
  87849. * @param value defines the value to test
  87850. * @returns true if the value is an exponent of 2
  87851. */
  87852. static IsExponentOfTwo(value: number): boolean;
  87853. private static _tmpFloatArray;
  87854. /**
  87855. * Returns the nearest 32-bit single precision float representation of a Number
  87856. * @param value A Number. If the parameter is of a different type, it will get converted
  87857. * to a number or to NaN if it cannot be converted
  87858. * @returns number
  87859. */
  87860. static FloatRound(value: number): number;
  87861. /**
  87862. * Find the next highest power of two.
  87863. * @param x Number to start search from.
  87864. * @return Next highest power of two.
  87865. */
  87866. static CeilingPOT(x: number): number;
  87867. /**
  87868. * Find the next lowest power of two.
  87869. * @param x Number to start search from.
  87870. * @return Next lowest power of two.
  87871. */
  87872. static FloorPOT(x: number): number;
  87873. /**
  87874. * Find the nearest power of two.
  87875. * @param x Number to start search from.
  87876. * @return Next nearest power of two.
  87877. */
  87878. static NearestPOT(x: number): number;
  87879. /**
  87880. * Get the closest exponent of two
  87881. * @param value defines the value to approximate
  87882. * @param max defines the maximum value to return
  87883. * @param mode defines how to define the closest value
  87884. * @returns closest exponent of two of the given value
  87885. */
  87886. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  87887. /**
  87888. * Extracts the filename from a path
  87889. * @param path defines the path to use
  87890. * @returns the filename
  87891. */
  87892. static GetFilename(path: string): string;
  87893. /**
  87894. * Extracts the "folder" part of a path (everything before the filename).
  87895. * @param uri The URI to extract the info from
  87896. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  87897. * @returns The "folder" part of the path
  87898. */
  87899. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  87900. /**
  87901. * Extracts text content from a DOM element hierarchy
  87902. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  87903. */
  87904. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  87905. /**
  87906. * Convert an angle in radians to degrees
  87907. * @param angle defines the angle to convert
  87908. * @returns the angle in degrees
  87909. */
  87910. static ToDegrees(angle: number): number;
  87911. /**
  87912. * Convert an angle in degrees to radians
  87913. * @param angle defines the angle to convert
  87914. * @returns the angle in radians
  87915. */
  87916. static ToRadians(angle: number): number;
  87917. /**
  87918. * Encode a buffer to a base64 string
  87919. * @param buffer defines the buffer to encode
  87920. * @returns the encoded string
  87921. */
  87922. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  87923. /**
  87924. * Extracts minimum and maximum values from a list of indexed positions
  87925. * @param positions defines the positions to use
  87926. * @param indices defines the indices to the positions
  87927. * @param indexStart defines the start index
  87928. * @param indexCount defines the end index
  87929. * @param bias defines bias value to add to the result
  87930. * @return minimum and maximum values
  87931. */
  87932. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  87933. minimum: Vector3;
  87934. maximum: Vector3;
  87935. };
  87936. /**
  87937. * Extracts minimum and maximum values from a list of positions
  87938. * @param positions defines the positions to use
  87939. * @param start defines the start index in the positions array
  87940. * @param count defines the number of positions to handle
  87941. * @param bias defines bias value to add to the result
  87942. * @param stride defines the stride size to use (distance between two positions in the positions array)
  87943. * @return minimum and maximum values
  87944. */
  87945. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  87946. minimum: Vector3;
  87947. maximum: Vector3;
  87948. };
  87949. /**
  87950. * Returns an array if obj is not an array
  87951. * @param obj defines the object to evaluate as an array
  87952. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  87953. * @returns either obj directly if obj is an array or a new array containing obj
  87954. */
  87955. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  87956. /**
  87957. * Gets the pointer prefix to use
  87958. * @returns "pointer" if touch is enabled. Else returns "mouse"
  87959. */
  87960. static GetPointerPrefix(): string;
  87961. /**
  87962. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  87963. * @param func - the function to be called
  87964. * @param requester - the object that will request the next frame. Falls back to window.
  87965. * @returns frame number
  87966. */
  87967. static QueueNewFrame(func: () => void, requester?: any): number;
  87968. /**
  87969. * Ask the browser to promote the current element to fullscreen rendering mode
  87970. * @param element defines the DOM element to promote
  87971. */
  87972. static RequestFullscreen(element: HTMLElement): void;
  87973. /**
  87974. * Asks the browser to exit fullscreen mode
  87975. */
  87976. static ExitFullscreen(): void;
  87977. /**
  87978. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  87979. * @param url define the url we are trying
  87980. * @param element define the dom element where to configure the cors policy
  87981. */
  87982. static SetCorsBehavior(url: string | string[], element: {
  87983. crossOrigin: string | null;
  87984. }): void;
  87985. /**
  87986. * Removes unwanted characters from an url
  87987. * @param url defines the url to clean
  87988. * @returns the cleaned url
  87989. */
  87990. static CleanUrl(url: string): string;
  87991. /**
  87992. * Gets or sets a function used to pre-process url before using them to load assets
  87993. */
  87994. static PreprocessUrl: (url: string) => string;
  87995. /**
  87996. * Loads an image as an HTMLImageElement.
  87997. * @param input url string, ArrayBuffer, or Blob to load
  87998. * @param onLoad callback called when the image successfully loads
  87999. * @param onError callback called when the image fails to load
  88000. * @param offlineProvider offline provider for caching
  88001. * @returns the HTMLImageElement of the loaded image
  88002. */
  88003. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  88004. /**
  88005. * Loads a file
  88006. * @param url url string, ArrayBuffer, or Blob to load
  88007. * @param onSuccess callback called when the file successfully loads
  88008. * @param onProgress callback called while file is loading (if the server supports this mode)
  88009. * @param offlineProvider defines the offline provider for caching
  88010. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  88011. * @param onError callback called when the file fails to load
  88012. * @returns a file request object
  88013. */
  88014. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: XMLHttpRequest, exception?: any) => void): IFileRequest;
  88015. /**
  88016. * Load a script (identified by an url). When the url returns, the
  88017. * content of this file is added into a new script element, attached to the DOM (body element)
  88018. * @param scriptUrl defines the url of the script to laod
  88019. * @param onSuccess defines the callback called when the script is loaded
  88020. * @param onError defines the callback to call if an error occurs
  88021. */
  88022. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void): void;
  88023. /**
  88024. * Loads a file from a blob
  88025. * @param fileToLoad defines the blob to use
  88026. * @param callback defines the callback to call when data is loaded
  88027. * @param progressCallback defines the callback to call during loading process
  88028. * @returns a file request object
  88029. */
  88030. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  88031. /**
  88032. * Loads a file
  88033. * @param fileToLoad defines the file to load
  88034. * @param callback defines the callback to call when data is loaded
  88035. * @param progressCallBack defines the callback to call during loading process
  88036. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  88037. * @returns a file request object
  88038. */
  88039. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  88040. /**
  88041. * Creates a data url from a given string content
  88042. * @param content defines the content to convert
  88043. * @returns the new data url link
  88044. */
  88045. static FileAsURL(content: string): string;
  88046. /**
  88047. * Format the given number to a specific decimal format
  88048. * @param value defines the number to format
  88049. * @param decimals defines the number of decimals to use
  88050. * @returns the formatted string
  88051. */
  88052. static Format(value: number, decimals?: number): string;
  88053. /**
  88054. * Checks if a given vector is inside a specific range
  88055. * @param v defines the vector to test
  88056. * @param min defines the minimum range
  88057. * @param max defines the maximum range
  88058. */
  88059. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  88060. /**
  88061. * Tries to copy an object by duplicating every property
  88062. * @param source defines the source object
  88063. * @param destination defines the target object
  88064. * @param doNotCopyList defines a list of properties to avoid
  88065. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  88066. */
  88067. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  88068. /**
  88069. * Gets a boolean indicating if the given object has no own property
  88070. * @param obj defines the object to test
  88071. * @returns true if object has no own property
  88072. */
  88073. static IsEmpty(obj: any): boolean;
  88074. /**
  88075. * Function used to register events at window level
  88076. * @param events defines the events to register
  88077. */
  88078. static RegisterTopRootEvents(events: {
  88079. name: string;
  88080. handler: Nullable<(e: FocusEvent) => any>;
  88081. }[]): void;
  88082. /**
  88083. * Function used to unregister events from window level
  88084. * @param events defines the events to unregister
  88085. */
  88086. static UnregisterTopRootEvents(events: {
  88087. name: string;
  88088. handler: Nullable<(e: FocusEvent) => any>;
  88089. }[]): void;
  88090. /**
  88091. * @ignore
  88092. */
  88093. static _ScreenshotCanvas: HTMLCanvasElement;
  88094. /**
  88095. * Dumps the current bound framebuffer
  88096. * @param width defines the rendering width
  88097. * @param height defines the rendering height
  88098. * @param engine defines the hosting engine
  88099. * @param successCallback defines the callback triggered once the data are available
  88100. * @param mimeType defines the mime type of the result
  88101. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  88102. */
  88103. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  88104. /**
  88105. * Converts the canvas data to blob.
  88106. * This acts as a polyfill for browsers not supporting the to blob function.
  88107. * @param canvas Defines the canvas to extract the data from
  88108. * @param successCallback Defines the callback triggered once the data are available
  88109. * @param mimeType Defines the mime type of the result
  88110. */
  88111. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  88112. /**
  88113. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  88114. * @param successCallback defines the callback triggered once the data are available
  88115. * @param mimeType defines the mime type of the result
  88116. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  88117. */
  88118. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  88119. /**
  88120. * Downloads a blob in the browser
  88121. * @param blob defines the blob to download
  88122. * @param fileName defines the name of the downloaded file
  88123. */
  88124. static Download(blob: Blob, fileName: string): void;
  88125. /**
  88126. * Captures a screenshot of the current rendering
  88127. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  88128. * @param engine defines the rendering engine
  88129. * @param camera defines the source camera
  88130. * @param size This parameter can be set to a single number or to an object with the
  88131. * following (optional) properties: precision, width, height. If a single number is passed,
  88132. * it will be used for both width and height. If an object is passed, the screenshot size
  88133. * will be derived from the parameters. The precision property is a multiplier allowing
  88134. * rendering at a higher or lower resolution
  88135. * @param successCallback defines the callback receives a single parameter which contains the
  88136. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  88137. * src parameter of an <img> to display it
  88138. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  88139. * Check your browser for supported MIME types
  88140. */
  88141. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  88142. /**
  88143. * Generates an image screenshot from the specified camera.
  88144. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  88145. * @param engine The engine to use for rendering
  88146. * @param camera The camera to use for rendering
  88147. * @param size This parameter can be set to a single number or to an object with the
  88148. * following (optional) properties: precision, width, height. If a single number is passed,
  88149. * it will be used for both width and height. If an object is passed, the screenshot size
  88150. * will be derived from the parameters. The precision property is a multiplier allowing
  88151. * rendering at a higher or lower resolution
  88152. * @param successCallback The callback receives a single parameter which contains the
  88153. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  88154. * src parameter of an <img> to display it
  88155. * @param mimeType The MIME type of the screenshot image (default: image/png).
  88156. * Check your browser for supported MIME types
  88157. * @param samples Texture samples (default: 1)
  88158. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  88159. * @param fileName A name for for the downloaded file.
  88160. */
  88161. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  88162. /**
  88163. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  88164. * Be aware Math.random() could cause collisions, but:
  88165. * "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"
  88166. * @returns a pseudo random id
  88167. */
  88168. static RandomId(): string;
  88169. /**
  88170. * Test if the given uri is a base64 string
  88171. * @param uri The uri to test
  88172. * @return True if the uri is a base64 string or false otherwise
  88173. */
  88174. static IsBase64(uri: string): boolean;
  88175. /**
  88176. * Decode the given base64 uri.
  88177. * @param uri The uri to decode
  88178. * @return The decoded base64 data.
  88179. */
  88180. static DecodeBase64(uri: string): ArrayBuffer;
  88181. /**
  88182. * No log
  88183. */
  88184. static readonly NoneLogLevel: number;
  88185. /**
  88186. * Only message logs
  88187. */
  88188. static readonly MessageLogLevel: number;
  88189. /**
  88190. * Only warning logs
  88191. */
  88192. static readonly WarningLogLevel: number;
  88193. /**
  88194. * Only error logs
  88195. */
  88196. static readonly ErrorLogLevel: number;
  88197. /**
  88198. * All logs
  88199. */
  88200. static readonly AllLogLevel: number;
  88201. /**
  88202. * Gets a value indicating the number of loading errors
  88203. * @ignorenaming
  88204. */
  88205. static readonly errorsCount: number;
  88206. /**
  88207. * Callback called when a new log is added
  88208. */
  88209. static OnNewCacheEntry: (entry: string) => void;
  88210. /**
  88211. * Log a message to the console
  88212. * @param message defines the message to log
  88213. */
  88214. static Log(message: string): void;
  88215. /**
  88216. * Write a warning message to the console
  88217. * @param message defines the message to log
  88218. */
  88219. static Warn(message: string): void;
  88220. /**
  88221. * Write an error message to the console
  88222. * @param message defines the message to log
  88223. */
  88224. static Error(message: string): void;
  88225. /**
  88226. * Gets current log cache (list of logs)
  88227. */
  88228. static readonly LogCache: string;
  88229. /**
  88230. * Clears the log cache
  88231. */
  88232. static ClearLogCache(): void;
  88233. /**
  88234. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  88235. */
  88236. static LogLevels: number;
  88237. /**
  88238. * Checks if the loaded document was accessed via `file:`-Protocol.
  88239. * @returns boolean
  88240. */
  88241. static IsFileURL(): boolean;
  88242. /**
  88243. * Checks if the window object exists
  88244. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  88245. */
  88246. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  88247. /**
  88248. * No performance log
  88249. */
  88250. static readonly PerformanceNoneLogLevel: number;
  88251. /**
  88252. * Use user marks to log performance
  88253. */
  88254. static readonly PerformanceUserMarkLogLevel: number;
  88255. /**
  88256. * Log performance to the console
  88257. */
  88258. static readonly PerformanceConsoleLogLevel: number;
  88259. private static _performance;
  88260. /**
  88261. * Sets the current performance log level
  88262. */
  88263. static PerformanceLogLevel: number;
  88264. private static _StartPerformanceCounterDisabled;
  88265. private static _EndPerformanceCounterDisabled;
  88266. private static _StartUserMark;
  88267. private static _EndUserMark;
  88268. private static _StartPerformanceConsole;
  88269. private static _EndPerformanceConsole;
  88270. /**
  88271. * Starts a performance counter
  88272. */
  88273. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  88274. /**
  88275. * Ends a specific performance coutner
  88276. */
  88277. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  88278. /**
  88279. * Gets either window.performance.now() if supported or Date.now() else
  88280. */
  88281. static readonly Now: number;
  88282. /**
  88283. * This method will return the name of the class used to create the instance of the given object.
  88284. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  88285. * @param object the object to get the class name from
  88286. * @param isType defines if the object is actually a type
  88287. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  88288. */
  88289. static GetClassName(object: any, isType?: boolean): string;
  88290. /**
  88291. * Gets the first element of an array satisfying a given predicate
  88292. * @param array defines the array to browse
  88293. * @param predicate defines the predicate to use
  88294. * @returns null if not found or the element
  88295. */
  88296. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  88297. /**
  88298. * This method will return the name of the full name of the class, including its owning module (if any).
  88299. * 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).
  88300. * @param object the object to get the class name from
  88301. * @param isType defines if the object is actually a type
  88302. * @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.
  88303. * @ignorenaming
  88304. */
  88305. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  88306. /**
  88307. * Returns a promise that resolves after the given amount of time.
  88308. * @param delay Number of milliseconds to delay
  88309. * @returns Promise that resolves after the given amount of time
  88310. */
  88311. static DelayAsync(delay: number): Promise<void>;
  88312. /**
  88313. * Gets the current gradient from an array of IValueGradient
  88314. * @param ratio defines the current ratio to get
  88315. * @param gradients defines the array of IValueGradient
  88316. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  88317. */
  88318. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  88319. }
  88320. /**
  88321. * This class is used to track a performance counter which is number based.
  88322. * The user has access to many properties which give statistics of different nature.
  88323. *
  88324. * The implementer can track two kinds of Performance Counter: time and count.
  88325. * 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.
  88326. * 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.
  88327. */
  88328. export class PerfCounter {
  88329. /**
  88330. * Gets or sets a global boolean to turn on and off all the counters
  88331. */
  88332. static Enabled: boolean;
  88333. /**
  88334. * Returns the smallest value ever
  88335. */
  88336. readonly min: number;
  88337. /**
  88338. * Returns the biggest value ever
  88339. */
  88340. readonly max: number;
  88341. /**
  88342. * Returns the average value since the performance counter is running
  88343. */
  88344. readonly average: number;
  88345. /**
  88346. * Returns the average value of the last second the counter was monitored
  88347. */
  88348. readonly lastSecAverage: number;
  88349. /**
  88350. * Returns the current value
  88351. */
  88352. readonly current: number;
  88353. /**
  88354. * Gets the accumulated total
  88355. */
  88356. readonly total: number;
  88357. /**
  88358. * Gets the total value count
  88359. */
  88360. readonly count: number;
  88361. /**
  88362. * Creates a new counter
  88363. */
  88364. constructor();
  88365. /**
  88366. * Call this method to start monitoring a new frame.
  88367. * 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.
  88368. */
  88369. fetchNewFrame(): void;
  88370. /**
  88371. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  88372. * @param newCount the count value to add to the monitored count
  88373. * @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.
  88374. */
  88375. addCount(newCount: number, fetchResult: boolean): void;
  88376. /**
  88377. * Start monitoring this performance counter
  88378. */
  88379. beginMonitoring(): void;
  88380. /**
  88381. * Compute the time lapsed since the previous beginMonitoring() call.
  88382. * @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
  88383. */
  88384. endMonitoring(newFrame?: boolean): void;
  88385. private _fetchResult;
  88386. private _startMonitoringTime;
  88387. private _min;
  88388. private _max;
  88389. private _average;
  88390. private _current;
  88391. private _totalValueCount;
  88392. private _totalAccumulated;
  88393. private _lastSecAverage;
  88394. private _lastSecAccumulated;
  88395. private _lastSecTime;
  88396. private _lastSecValueCount;
  88397. }
  88398. /**
  88399. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  88400. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  88401. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  88402. * @param name The name of the class, case should be preserved
  88403. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  88404. */
  88405. export function className(name: string, module?: string): (target: Object) => void;
  88406. /**
  88407. * An implementation of a loop for asynchronous functions.
  88408. */
  88409. export class AsyncLoop {
  88410. /**
  88411. * Defines the number of iterations for the loop
  88412. */
  88413. iterations: number;
  88414. /**
  88415. * Defines the current index of the loop.
  88416. */
  88417. index: number;
  88418. private _done;
  88419. private _fn;
  88420. private _successCallback;
  88421. /**
  88422. * Constructor.
  88423. * @param iterations the number of iterations.
  88424. * @param func the function to run each iteration
  88425. * @param successCallback the callback that will be called upon succesful execution
  88426. * @param offset starting offset.
  88427. */
  88428. constructor(
  88429. /**
  88430. * Defines the number of iterations for the loop
  88431. */
  88432. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  88433. /**
  88434. * Execute the next iteration. Must be called after the last iteration was finished.
  88435. */
  88436. executeNext(): void;
  88437. /**
  88438. * Break the loop and run the success callback.
  88439. */
  88440. breakLoop(): void;
  88441. /**
  88442. * Create and run an async loop.
  88443. * @param iterations the number of iterations.
  88444. * @param fn the function to run each iteration
  88445. * @param successCallback the callback that will be called upon succesful execution
  88446. * @param offset starting offset.
  88447. * @returns the created async loop object
  88448. */
  88449. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  88450. /**
  88451. * A for-loop that will run a given number of iterations synchronous and the rest async.
  88452. * @param iterations total number of iterations
  88453. * @param syncedIterations number of synchronous iterations in each async iteration.
  88454. * @param fn the function to call each iteration.
  88455. * @param callback a success call back that will be called when iterating stops.
  88456. * @param breakFunction a break condition (optional)
  88457. * @param timeout timeout settings for the setTimeout function. default - 0.
  88458. * @returns the created async loop object
  88459. */
  88460. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  88461. }
  88462. }
  88463. declare module BABYLON {
  88464. /** @hidden */
  88465. export interface ICollisionCoordinator {
  88466. createCollider(): Collider;
  88467. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  88468. init(scene: Scene): void;
  88469. }
  88470. /** @hidden */
  88471. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  88472. private _scene;
  88473. private _scaledPosition;
  88474. private _scaledVelocity;
  88475. private _finalPosition;
  88476. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  88477. createCollider(): Collider;
  88478. init(scene: Scene): void;
  88479. private _collideWithWorld;
  88480. }
  88481. }
  88482. declare module BABYLON {
  88483. /**
  88484. * This class defines the direct association between an animation and a target
  88485. */
  88486. export class TargetedAnimation {
  88487. /**
  88488. * Animation to perform
  88489. */
  88490. animation: Animation;
  88491. /**
  88492. * Target to animate
  88493. */
  88494. target: any;
  88495. }
  88496. /**
  88497. * Use this class to create coordinated animations on multiple targets
  88498. */
  88499. export class AnimationGroup implements IDisposable {
  88500. /** The name of the animation group */
  88501. name: string;
  88502. private _scene;
  88503. private _targetedAnimations;
  88504. private _animatables;
  88505. private _from;
  88506. private _to;
  88507. private _isStarted;
  88508. private _isPaused;
  88509. private _speedRatio;
  88510. /**
  88511. * Gets or sets the unique id of the node
  88512. */
  88513. uniqueId: number;
  88514. /**
  88515. * This observable will notify when one animation have ended
  88516. */
  88517. onAnimationEndObservable: Observable<TargetedAnimation>;
  88518. /**
  88519. * Observer raised when one animation loops
  88520. */
  88521. onAnimationLoopObservable: Observable<TargetedAnimation>;
  88522. /**
  88523. * This observable will notify when all animations have ended.
  88524. */
  88525. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  88526. /**
  88527. * This observable will notify when all animations have paused.
  88528. */
  88529. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  88530. /**
  88531. * This observable will notify when all animations are playing.
  88532. */
  88533. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  88534. /**
  88535. * Gets the first frame
  88536. */
  88537. readonly from: number;
  88538. /**
  88539. * Gets the last frame
  88540. */
  88541. readonly to: number;
  88542. /**
  88543. * Define if the animations are started
  88544. */
  88545. readonly isStarted: boolean;
  88546. /**
  88547. * Gets a value indicating that the current group is playing
  88548. */
  88549. readonly isPlaying: boolean;
  88550. /**
  88551. * Gets or sets the speed ratio to use for all animations
  88552. */
  88553. /**
  88554. * Gets or sets the speed ratio to use for all animations
  88555. */
  88556. speedRatio: number;
  88557. /**
  88558. * Gets the targeted animations for this animation group
  88559. */
  88560. readonly targetedAnimations: Array<TargetedAnimation>;
  88561. /**
  88562. * returning the list of animatables controlled by this animation group.
  88563. */
  88564. readonly animatables: Array<Animatable>;
  88565. /**
  88566. * Instantiates a new Animation Group.
  88567. * This helps managing several animations at once.
  88568. * @see http://doc.babylonjs.com/how_to/group
  88569. * @param name Defines the name of the group
  88570. * @param scene Defines the scene the group belongs to
  88571. */
  88572. constructor(
  88573. /** The name of the animation group */
  88574. name: string, scene?: Nullable<Scene>);
  88575. /**
  88576. * Add an animation (with its target) in the group
  88577. * @param animation defines the animation we want to add
  88578. * @param target defines the target of the animation
  88579. * @returns the TargetedAnimation object
  88580. */
  88581. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  88582. /**
  88583. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  88584. * It can add constant keys at begin or end
  88585. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  88586. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  88587. * @returns the animation group
  88588. */
  88589. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  88590. /**
  88591. * Start all animations on given targets
  88592. * @param loop defines if animations must loop
  88593. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  88594. * @param from defines the from key (optional)
  88595. * @param to defines the to key (optional)
  88596. * @returns the current animation group
  88597. */
  88598. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  88599. /**
  88600. * Pause all animations
  88601. * @returns the animation group
  88602. */
  88603. pause(): AnimationGroup;
  88604. /**
  88605. * Play all animations to initial state
  88606. * This function will start() the animations if they were not started or will restart() them if they were paused
  88607. * @param loop defines if animations must loop
  88608. * @returns the animation group
  88609. */
  88610. play(loop?: boolean): AnimationGroup;
  88611. /**
  88612. * Reset all animations to initial state
  88613. * @returns the animation group
  88614. */
  88615. reset(): AnimationGroup;
  88616. /**
  88617. * Restart animations from key 0
  88618. * @returns the animation group
  88619. */
  88620. restart(): AnimationGroup;
  88621. /**
  88622. * Stop all animations
  88623. * @returns the animation group
  88624. */
  88625. stop(): AnimationGroup;
  88626. /**
  88627. * Set animation weight for all animatables
  88628. * @param weight defines the weight to use
  88629. * @return the animationGroup
  88630. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  88631. */
  88632. setWeightForAllAnimatables(weight: number): AnimationGroup;
  88633. /**
  88634. * Synchronize and normalize all animatables with a source animatable
  88635. * @param root defines the root animatable to synchronize with
  88636. * @return the animationGroup
  88637. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  88638. */
  88639. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  88640. /**
  88641. * Goes to a specific frame in this animation group
  88642. * @param frame the frame number to go to
  88643. * @return the animationGroup
  88644. */
  88645. goToFrame(frame: number): AnimationGroup;
  88646. /**
  88647. * Dispose all associated resources
  88648. */
  88649. dispose(): void;
  88650. private _checkAnimationGroupEnded;
  88651. /**
  88652. * Clone the current animation group and returns a copy
  88653. * @param newName defines the name of the new group
  88654. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  88655. * @returns the new aniamtion group
  88656. */
  88657. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  88658. /**
  88659. * Returns a new AnimationGroup object parsed from the source provided.
  88660. * @param parsedAnimationGroup defines the source
  88661. * @param scene defines the scene that will receive the animationGroup
  88662. * @returns a new AnimationGroup
  88663. */
  88664. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  88665. /**
  88666. * Returns the string "AnimationGroup"
  88667. * @returns "AnimationGroup"
  88668. */
  88669. getClassName(): string;
  88670. /**
  88671. * Creates a detailled string about the object
  88672. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  88673. * @returns a string representing the object
  88674. */
  88675. toString(fullDetails?: boolean): string;
  88676. }
  88677. }
  88678. declare module BABYLON {
  88679. /**
  88680. * Define an interface for all classes that will hold resources
  88681. */
  88682. export interface IDisposable {
  88683. /**
  88684. * Releases all held resources
  88685. */
  88686. dispose(): void;
  88687. }
  88688. /** Interface defining initialization parameters for Scene class */
  88689. export interface SceneOptions {
  88690. /**
  88691. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  88692. * It will improve performance when the number of geometries becomes important.
  88693. */
  88694. useGeometryUniqueIdsMap?: boolean;
  88695. /**
  88696. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  88697. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  88698. */
  88699. useMaterialMeshMap?: boolean;
  88700. /**
  88701. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  88702. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  88703. */
  88704. useClonedMeshhMap?: boolean;
  88705. }
  88706. /**
  88707. * Represents a scene to be rendered by the engine.
  88708. * @see http://doc.babylonjs.com/features/scene
  88709. */
  88710. export class Scene extends AbstractScene implements IAnimatable {
  88711. private static _uniqueIdCounter;
  88712. /** The fog is deactivated */
  88713. static readonly FOGMODE_NONE: number;
  88714. /** The fog density is following an exponential function */
  88715. static readonly FOGMODE_EXP: number;
  88716. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  88717. static readonly FOGMODE_EXP2: number;
  88718. /** The fog density is following a linear function. */
  88719. static readonly FOGMODE_LINEAR: number;
  88720. /**
  88721. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  88722. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  88723. */
  88724. static MinDeltaTime: number;
  88725. /**
  88726. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  88727. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  88728. */
  88729. static MaxDeltaTime: number;
  88730. /**
  88731. * Factory used to create the default material.
  88732. * @param name The name of the material to create
  88733. * @param scene The scene to create the material for
  88734. * @returns The default material
  88735. */
  88736. static DefaultMaterialFactory(scene: Scene): Material;
  88737. /**
  88738. * Factory used to create the a collision coordinator.
  88739. * @returns The collision coordinator
  88740. */
  88741. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  88742. /** @hidden */
  88743. readonly _isScene: boolean;
  88744. /**
  88745. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  88746. */
  88747. autoClear: boolean;
  88748. /**
  88749. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  88750. */
  88751. autoClearDepthAndStencil: boolean;
  88752. /**
  88753. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  88754. */
  88755. clearColor: Color4;
  88756. /**
  88757. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  88758. */
  88759. ambientColor: Color3;
  88760. /** @hidden */
  88761. _environmentBRDFTexture: BaseTexture;
  88762. /** @hidden */
  88763. protected _environmentTexture: Nullable<BaseTexture>;
  88764. /**
  88765. * Texture used in all pbr material as the reflection texture.
  88766. * As in the majority of the scene they are the same (exception for multi room and so on),
  88767. * this is easier to reference from here than from all the materials.
  88768. */
  88769. /**
  88770. * Texture used in all pbr material as the reflection texture.
  88771. * As in the majority of the scene they are the same (exception for multi room and so on),
  88772. * this is easier to set here than in all the materials.
  88773. */
  88774. environmentTexture: Nullable<BaseTexture>;
  88775. /** @hidden */
  88776. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  88777. /**
  88778. * Default image processing configuration used either in the rendering
  88779. * Forward main pass or through the imageProcessingPostProcess if present.
  88780. * As in the majority of the scene they are the same (exception for multi camera),
  88781. * this is easier to reference from here than from all the materials and post process.
  88782. *
  88783. * No setter as we it is a shared configuration, you can set the values instead.
  88784. */
  88785. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  88786. private _forceWireframe;
  88787. /**
  88788. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  88789. */
  88790. forceWireframe: boolean;
  88791. private _forcePointsCloud;
  88792. /**
  88793. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  88794. */
  88795. forcePointsCloud: boolean;
  88796. /**
  88797. * Gets or sets the active clipplane 1
  88798. */
  88799. clipPlane: Nullable<Plane>;
  88800. /**
  88801. * Gets or sets the active clipplane 2
  88802. */
  88803. clipPlane2: Nullable<Plane>;
  88804. /**
  88805. * Gets or sets the active clipplane 3
  88806. */
  88807. clipPlane3: Nullable<Plane>;
  88808. /**
  88809. * Gets or sets the active clipplane 4
  88810. */
  88811. clipPlane4: Nullable<Plane>;
  88812. /**
  88813. * Gets or sets a boolean indicating if animations are enabled
  88814. */
  88815. animationsEnabled: boolean;
  88816. private _animationPropertiesOverride;
  88817. /**
  88818. * Gets or sets the animation properties override
  88819. */
  88820. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  88821. /**
  88822. * Gets or sets a boolean indicating if a constant deltatime has to be used
  88823. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  88824. */
  88825. useConstantAnimationDeltaTime: boolean;
  88826. /**
  88827. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  88828. * Please note that it requires to run a ray cast through the scene on every frame
  88829. */
  88830. constantlyUpdateMeshUnderPointer: boolean;
  88831. /**
  88832. * Defines the HTML cursor to use when hovering over interactive elements
  88833. */
  88834. hoverCursor: string;
  88835. /**
  88836. * Defines the HTML default cursor to use (empty by default)
  88837. */
  88838. defaultCursor: string;
  88839. /**
  88840. * This is used to call preventDefault() on pointer down
  88841. * in order to block unwanted artifacts like system double clicks
  88842. */
  88843. preventDefaultOnPointerDown: boolean;
  88844. /**
  88845. * This is used to call preventDefault() on pointer up
  88846. * in order to block unwanted artifacts like system double clicks
  88847. */
  88848. preventDefaultOnPointerUp: boolean;
  88849. /**
  88850. * Gets or sets user defined metadata
  88851. */
  88852. metadata: any;
  88853. /**
  88854. * For internal use only. Please do not use.
  88855. */
  88856. reservedDataStore: any;
  88857. /**
  88858. * Gets the name of the plugin used to load this scene (null by default)
  88859. */
  88860. loadingPluginName: string;
  88861. /**
  88862. * Use this array to add regular expressions used to disable offline support for specific urls
  88863. */
  88864. disableOfflineSupportExceptionRules: RegExp[];
  88865. /**
  88866. * An event triggered when the scene is disposed.
  88867. */
  88868. onDisposeObservable: Observable<Scene>;
  88869. private _onDisposeObserver;
  88870. /** Sets a function to be executed when this scene is disposed. */
  88871. onDispose: () => void;
  88872. /**
  88873. * An event triggered before rendering the scene (right after animations and physics)
  88874. */
  88875. onBeforeRenderObservable: Observable<Scene>;
  88876. private _onBeforeRenderObserver;
  88877. /** Sets a function to be executed before rendering this scene */
  88878. beforeRender: Nullable<() => void>;
  88879. /**
  88880. * An event triggered after rendering the scene
  88881. */
  88882. onAfterRenderObservable: Observable<Scene>;
  88883. private _onAfterRenderObserver;
  88884. /** Sets a function to be executed after rendering this scene */
  88885. afterRender: Nullable<() => void>;
  88886. /**
  88887. * An event triggered before animating the scene
  88888. */
  88889. onBeforeAnimationsObservable: Observable<Scene>;
  88890. /**
  88891. * An event triggered after animations processing
  88892. */
  88893. onAfterAnimationsObservable: Observable<Scene>;
  88894. /**
  88895. * An event triggered before draw calls are ready to be sent
  88896. */
  88897. onBeforeDrawPhaseObservable: Observable<Scene>;
  88898. /**
  88899. * An event triggered after draw calls have been sent
  88900. */
  88901. onAfterDrawPhaseObservable: Observable<Scene>;
  88902. /**
  88903. * An event triggered when the scene is ready
  88904. */
  88905. onReadyObservable: Observable<Scene>;
  88906. /**
  88907. * An event triggered before rendering a camera
  88908. */
  88909. onBeforeCameraRenderObservable: Observable<Camera>;
  88910. private _onBeforeCameraRenderObserver;
  88911. /** Sets a function to be executed before rendering a camera*/
  88912. beforeCameraRender: () => void;
  88913. /**
  88914. * An event triggered after rendering a camera
  88915. */
  88916. onAfterCameraRenderObservable: Observable<Camera>;
  88917. private _onAfterCameraRenderObserver;
  88918. /** Sets a function to be executed after rendering a camera*/
  88919. afterCameraRender: () => void;
  88920. /**
  88921. * An event triggered when active meshes evaluation is about to start
  88922. */
  88923. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  88924. /**
  88925. * An event triggered when active meshes evaluation is done
  88926. */
  88927. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  88928. /**
  88929. * An event triggered when particles rendering is about to start
  88930. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  88931. */
  88932. onBeforeParticlesRenderingObservable: Observable<Scene>;
  88933. /**
  88934. * An event triggered when particles rendering is done
  88935. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  88936. */
  88937. onAfterParticlesRenderingObservable: Observable<Scene>;
  88938. /**
  88939. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  88940. */
  88941. onDataLoadedObservable: Observable<Scene>;
  88942. /**
  88943. * An event triggered when a camera is created
  88944. */
  88945. onNewCameraAddedObservable: Observable<Camera>;
  88946. /**
  88947. * An event triggered when a camera is removed
  88948. */
  88949. onCameraRemovedObservable: Observable<Camera>;
  88950. /**
  88951. * An event triggered when a light is created
  88952. */
  88953. onNewLightAddedObservable: Observable<Light>;
  88954. /**
  88955. * An event triggered when a light is removed
  88956. */
  88957. onLightRemovedObservable: Observable<Light>;
  88958. /**
  88959. * An event triggered when a geometry is created
  88960. */
  88961. onNewGeometryAddedObservable: Observable<Geometry>;
  88962. /**
  88963. * An event triggered when a geometry is removed
  88964. */
  88965. onGeometryRemovedObservable: Observable<Geometry>;
  88966. /**
  88967. * An event triggered when a transform node is created
  88968. */
  88969. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  88970. /**
  88971. * An event triggered when a transform node is removed
  88972. */
  88973. onTransformNodeRemovedObservable: Observable<TransformNode>;
  88974. /**
  88975. * An event triggered when a mesh is created
  88976. */
  88977. onNewMeshAddedObservable: Observable<AbstractMesh>;
  88978. /**
  88979. * An event triggered when a mesh is removed
  88980. */
  88981. onMeshRemovedObservable: Observable<AbstractMesh>;
  88982. /**
  88983. * An event triggered when a material is created
  88984. */
  88985. onNewMaterialAddedObservable: Observable<Material>;
  88986. /**
  88987. * An event triggered when a material is removed
  88988. */
  88989. onMaterialRemovedObservable: Observable<Material>;
  88990. /**
  88991. * An event triggered when a texture is created
  88992. */
  88993. onNewTextureAddedObservable: Observable<BaseTexture>;
  88994. /**
  88995. * An event triggered when a texture is removed
  88996. */
  88997. onTextureRemovedObservable: Observable<BaseTexture>;
  88998. /**
  88999. * An event triggered when render targets are about to be rendered
  89000. * Can happen multiple times per frame.
  89001. */
  89002. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  89003. /**
  89004. * An event triggered when render targets were rendered.
  89005. * Can happen multiple times per frame.
  89006. */
  89007. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  89008. /**
  89009. * An event triggered before calculating deterministic simulation step
  89010. */
  89011. onBeforeStepObservable: Observable<Scene>;
  89012. /**
  89013. * An event triggered after calculating deterministic simulation step
  89014. */
  89015. onAfterStepObservable: Observable<Scene>;
  89016. /**
  89017. * An event triggered when the activeCamera property is updated
  89018. */
  89019. onActiveCameraChanged: Observable<Scene>;
  89020. /**
  89021. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  89022. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  89023. * 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)
  89024. */
  89025. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  89026. /**
  89027. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  89028. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  89029. * 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)
  89030. */
  89031. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  89032. /**
  89033. * This Observable will when a mesh has been imported into the scene.
  89034. */
  89035. onMeshImportedObservable: Observable<AbstractMesh>;
  89036. /**
  89037. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  89038. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  89039. */
  89040. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  89041. /** @hidden */
  89042. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  89043. /**
  89044. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  89045. */
  89046. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  89047. /**
  89048. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  89049. */
  89050. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  89051. /**
  89052. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  89053. */
  89054. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  89055. private _onPointerMove;
  89056. private _onPointerDown;
  89057. private _onPointerUp;
  89058. /** Callback called when a pointer move is detected */
  89059. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  89060. /** Callback called when a pointer down is detected */
  89061. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  89062. /** Callback called when a pointer up is detected */
  89063. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  89064. /** Callback called when a pointer pick is detected */
  89065. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  89066. /**
  89067. * 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).
  89068. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  89069. */
  89070. onPrePointerObservable: Observable<PointerInfoPre>;
  89071. /**
  89072. * Observable event triggered each time an input event is received from the rendering canvas
  89073. */
  89074. onPointerObservable: Observable<PointerInfo>;
  89075. /**
  89076. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  89077. */
  89078. readonly unTranslatedPointer: Vector2;
  89079. /** The distance in pixel that you have to move to prevent some events */
  89080. static DragMovementThreshold: number;
  89081. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  89082. static LongPressDelay: number;
  89083. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  89084. static DoubleClickDelay: number;
  89085. /** If you need to check double click without raising a single click at first click, enable this flag */
  89086. static ExclusiveDoubleClickMode: boolean;
  89087. private _initClickEvent;
  89088. private _initActionManager;
  89089. private _delayedSimpleClick;
  89090. private _delayedSimpleClickTimeout;
  89091. private _previousDelayedSimpleClickTimeout;
  89092. private _meshPickProceed;
  89093. private _previousButtonPressed;
  89094. private _currentPickResult;
  89095. private _previousPickResult;
  89096. private _totalPointersPressed;
  89097. private _doubleClickOccured;
  89098. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  89099. cameraToUseForPointers: Nullable<Camera>;
  89100. private _pointerX;
  89101. private _pointerY;
  89102. private _unTranslatedPointerX;
  89103. private _unTranslatedPointerY;
  89104. private _startingPointerPosition;
  89105. private _previousStartingPointerPosition;
  89106. private _startingPointerTime;
  89107. private _previousStartingPointerTime;
  89108. private _pointerCaptures;
  89109. private _timeAccumulator;
  89110. private _currentStepId;
  89111. private _currentInternalStep;
  89112. /** @hidden */
  89113. _mirroredCameraPosition: Nullable<Vector3>;
  89114. /**
  89115. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  89116. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  89117. */
  89118. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  89119. /**
  89120. * Observable event triggered each time an keyboard event is received from the hosting window
  89121. */
  89122. onKeyboardObservable: Observable<KeyboardInfo>;
  89123. private _onKeyDown;
  89124. private _onKeyUp;
  89125. private _onCanvasFocusObserver;
  89126. private _onCanvasBlurObserver;
  89127. private _useRightHandedSystem;
  89128. /**
  89129. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  89130. */
  89131. useRightHandedSystem: boolean;
  89132. /**
  89133. * Sets the step Id used by deterministic lock step
  89134. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  89135. * @param newStepId defines the step Id
  89136. */
  89137. setStepId(newStepId: number): void;
  89138. /**
  89139. * Gets the step Id used by deterministic lock step
  89140. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  89141. * @returns the step Id
  89142. */
  89143. getStepId(): number;
  89144. /**
  89145. * Gets the internal step used by deterministic lock step
  89146. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  89147. * @returns the internal step
  89148. */
  89149. getInternalStep(): number;
  89150. private _fogEnabled;
  89151. /**
  89152. * Gets or sets a boolean indicating if fog is enabled on this scene
  89153. * @see http://doc.babylonjs.com/babylon101/environment#fog
  89154. * (Default is true)
  89155. */
  89156. fogEnabled: boolean;
  89157. private _fogMode;
  89158. /**
  89159. * Gets or sets the fog mode to use
  89160. * @see http://doc.babylonjs.com/babylon101/environment#fog
  89161. * | mode | value |
  89162. * | --- | --- |
  89163. * | FOGMODE_NONE | 0 |
  89164. * | FOGMODE_EXP | 1 |
  89165. * | FOGMODE_EXP2 | 2 |
  89166. * | FOGMODE_LINEAR | 3 |
  89167. */
  89168. fogMode: number;
  89169. /**
  89170. * Gets or sets the fog color to use
  89171. * @see http://doc.babylonjs.com/babylon101/environment#fog
  89172. * (Default is Color3(0.2, 0.2, 0.3))
  89173. */
  89174. fogColor: Color3;
  89175. /**
  89176. * Gets or sets the fog density to use
  89177. * @see http://doc.babylonjs.com/babylon101/environment#fog
  89178. * (Default is 0.1)
  89179. */
  89180. fogDensity: number;
  89181. /**
  89182. * Gets or sets the fog start distance to use
  89183. * @see http://doc.babylonjs.com/babylon101/environment#fog
  89184. * (Default is 0)
  89185. */
  89186. fogStart: number;
  89187. /**
  89188. * Gets or sets the fog end distance to use
  89189. * @see http://doc.babylonjs.com/babylon101/environment#fog
  89190. * (Default is 1000)
  89191. */
  89192. fogEnd: number;
  89193. private _shadowsEnabled;
  89194. /**
  89195. * Gets or sets a boolean indicating if shadows are enabled on this scene
  89196. */
  89197. shadowsEnabled: boolean;
  89198. private _lightsEnabled;
  89199. /**
  89200. * Gets or sets a boolean indicating if lights are enabled on this scene
  89201. */
  89202. lightsEnabled: boolean;
  89203. /** All of the active cameras added to this scene. */
  89204. activeCameras: Camera[];
  89205. private _activeCamera;
  89206. /** Gets or sets the current active camera */
  89207. activeCamera: Nullable<Camera>;
  89208. private _defaultMaterial;
  89209. /** The default material used on meshes when no material is affected */
  89210. /** The default material used on meshes when no material is affected */
  89211. defaultMaterial: Material;
  89212. private _texturesEnabled;
  89213. /**
  89214. * Gets or sets a boolean indicating if textures are enabled on this scene
  89215. */
  89216. texturesEnabled: boolean;
  89217. /**
  89218. * Gets or sets a boolean indicating if particles are enabled on this scene
  89219. */
  89220. particlesEnabled: boolean;
  89221. /**
  89222. * Gets or sets a boolean indicating if sprites are enabled on this scene
  89223. */
  89224. spritesEnabled: boolean;
  89225. private _skeletonsEnabled;
  89226. /**
  89227. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  89228. */
  89229. skeletonsEnabled: boolean;
  89230. /**
  89231. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  89232. */
  89233. lensFlaresEnabled: boolean;
  89234. /**
  89235. * Gets or sets a boolean indicating if collisions are enabled on this scene
  89236. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  89237. */
  89238. collisionsEnabled: boolean;
  89239. private _collisionCoordinator;
  89240. /** @hidden */
  89241. readonly collisionCoordinator: ICollisionCoordinator;
  89242. /**
  89243. * Defines the gravity applied to this scene (used only for collisions)
  89244. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  89245. */
  89246. gravity: Vector3;
  89247. /**
  89248. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  89249. */
  89250. postProcessesEnabled: boolean;
  89251. /**
  89252. * The list of postprocesses added to the scene
  89253. */
  89254. postProcesses: PostProcess[];
  89255. /**
  89256. * Gets the current postprocess manager
  89257. */
  89258. postProcessManager: PostProcessManager;
  89259. /**
  89260. * Gets or sets a boolean indicating if render targets are enabled on this scene
  89261. */
  89262. renderTargetsEnabled: boolean;
  89263. /**
  89264. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  89265. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  89266. */
  89267. dumpNextRenderTargets: boolean;
  89268. /**
  89269. * The list of user defined render targets added to the scene
  89270. */
  89271. customRenderTargets: RenderTargetTexture[];
  89272. /**
  89273. * Defines if texture loading must be delayed
  89274. * If true, textures will only be loaded when they need to be rendered
  89275. */
  89276. useDelayedTextureLoading: boolean;
  89277. /**
  89278. * Gets the list of meshes imported to the scene through SceneLoader
  89279. */
  89280. importedMeshesFiles: String[];
  89281. /**
  89282. * Gets or sets a boolean indicating if probes are enabled on this scene
  89283. */
  89284. probesEnabled: boolean;
  89285. /**
  89286. * Gets or sets the current offline provider to use to store scene data
  89287. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  89288. */
  89289. offlineProvider: IOfflineProvider;
  89290. /**
  89291. * Gets or sets the action manager associated with the scene
  89292. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  89293. */
  89294. actionManager: AbstractActionManager;
  89295. private _meshesForIntersections;
  89296. /**
  89297. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  89298. */
  89299. proceduralTexturesEnabled: boolean;
  89300. private _engine;
  89301. private _totalVertices;
  89302. /** @hidden */
  89303. _activeIndices: PerfCounter;
  89304. /** @hidden */
  89305. _activeParticles: PerfCounter;
  89306. /** @hidden */
  89307. _activeBones: PerfCounter;
  89308. private _animationRatio;
  89309. /** @hidden */
  89310. _animationTimeLast: number;
  89311. /** @hidden */
  89312. _animationTime: number;
  89313. /**
  89314. * Gets or sets a general scale for animation speed
  89315. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  89316. */
  89317. animationTimeScale: number;
  89318. /** @hidden */
  89319. _cachedMaterial: Nullable<Material>;
  89320. /** @hidden */
  89321. _cachedEffect: Nullable<Effect>;
  89322. /** @hidden */
  89323. _cachedVisibility: Nullable<number>;
  89324. private _renderId;
  89325. private _frameId;
  89326. private _executeWhenReadyTimeoutId;
  89327. private _intermediateRendering;
  89328. private _viewUpdateFlag;
  89329. private _projectionUpdateFlag;
  89330. private _alternateViewUpdateFlag;
  89331. private _alternateProjectionUpdateFlag;
  89332. /** @hidden */
  89333. _toBeDisposed: Nullable<IDisposable>[];
  89334. private _activeRequests;
  89335. /** @hidden */
  89336. _pendingData: any[];
  89337. private _isDisposed;
  89338. /**
  89339. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  89340. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  89341. */
  89342. dispatchAllSubMeshesOfActiveMeshes: boolean;
  89343. private _activeMeshes;
  89344. private _processedMaterials;
  89345. private _renderTargets;
  89346. /** @hidden */
  89347. _activeParticleSystems: SmartArray<IParticleSystem>;
  89348. private _activeSkeletons;
  89349. private _softwareSkinnedMeshes;
  89350. private _renderingManager;
  89351. /** @hidden */
  89352. _activeAnimatables: Animatable[];
  89353. private _transformMatrix;
  89354. private _sceneUbo;
  89355. private _alternateSceneUbo;
  89356. private _viewMatrix;
  89357. private _projectionMatrix;
  89358. private _alternateViewMatrix;
  89359. private _alternateProjectionMatrix;
  89360. private _alternateTransformMatrix;
  89361. private _useAlternateCameraConfiguration;
  89362. private _alternateRendering;
  89363. private _wheelEventName;
  89364. /** @hidden */
  89365. _forcedViewPosition: Nullable<Vector3>;
  89366. /** @hidden */
  89367. readonly _isAlternateRenderingEnabled: boolean;
  89368. private _frustumPlanes;
  89369. /**
  89370. * Gets the list of frustum planes (built from the active camera)
  89371. */
  89372. readonly frustumPlanes: Plane[];
  89373. /**
  89374. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  89375. * This is useful if there are more lights that the maximum simulteanous authorized
  89376. */
  89377. requireLightSorting: boolean;
  89378. /** @hidden */
  89379. readonly useMaterialMeshMap: boolean;
  89380. /** @hidden */
  89381. readonly useClonedMeshhMap: boolean;
  89382. private _pointerOverMesh;
  89383. private _pickedDownMesh;
  89384. private _pickedUpMesh;
  89385. private _externalData;
  89386. private _uid;
  89387. /**
  89388. * @hidden
  89389. * Backing store of defined scene components.
  89390. */
  89391. _components: ISceneComponent[];
  89392. /**
  89393. * @hidden
  89394. * Backing store of defined scene components.
  89395. */
  89396. _serializableComponents: ISceneSerializableComponent[];
  89397. /**
  89398. * List of components to register on the next registration step.
  89399. */
  89400. private _transientComponents;
  89401. /**
  89402. * Registers the transient components if needed.
  89403. */
  89404. private _registerTransientComponents;
  89405. /**
  89406. * @hidden
  89407. * Add a component to the scene.
  89408. * Note that the ccomponent could be registered on th next frame if this is called after
  89409. * the register component stage.
  89410. * @param component Defines the component to add to the scene
  89411. */
  89412. _addComponent(component: ISceneComponent): void;
  89413. /**
  89414. * @hidden
  89415. * Gets a component from the scene.
  89416. * @param name defines the name of the component to retrieve
  89417. * @returns the component or null if not present
  89418. */
  89419. _getComponent(name: string): Nullable<ISceneComponent>;
  89420. /**
  89421. * @hidden
  89422. * Defines the actions happening before camera updates.
  89423. */
  89424. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  89425. /**
  89426. * @hidden
  89427. * Defines the actions happening before clear the canvas.
  89428. */
  89429. _beforeClearStage: Stage<SimpleStageAction>;
  89430. /**
  89431. * @hidden
  89432. * Defines the actions when collecting render targets for the frame.
  89433. */
  89434. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  89435. /**
  89436. * @hidden
  89437. * Defines the actions happening for one camera in the frame.
  89438. */
  89439. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  89440. /**
  89441. * @hidden
  89442. * Defines the actions happening during the per mesh ready checks.
  89443. */
  89444. _isReadyForMeshStage: Stage<MeshStageAction>;
  89445. /**
  89446. * @hidden
  89447. * Defines the actions happening before evaluate active mesh checks.
  89448. */
  89449. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  89450. /**
  89451. * @hidden
  89452. * Defines the actions happening during the evaluate sub mesh checks.
  89453. */
  89454. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  89455. /**
  89456. * @hidden
  89457. * Defines the actions happening during the active mesh stage.
  89458. */
  89459. _activeMeshStage: Stage<ActiveMeshStageAction>;
  89460. /**
  89461. * @hidden
  89462. * Defines the actions happening during the per camera render target step.
  89463. */
  89464. _cameraDrawRenderTargetStage: Stage<CameraStageAction>;
  89465. /**
  89466. * @hidden
  89467. * Defines the actions happening just before the active camera is drawing.
  89468. */
  89469. _beforeCameraDrawStage: Stage<CameraStageAction>;
  89470. /**
  89471. * @hidden
  89472. * Defines the actions happening just before a render target is drawing.
  89473. */
  89474. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  89475. /**
  89476. * @hidden
  89477. * Defines the actions happening just before a rendering group is drawing.
  89478. */
  89479. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  89480. /**
  89481. * @hidden
  89482. * Defines the actions happening just before a mesh is drawing.
  89483. */
  89484. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  89485. /**
  89486. * @hidden
  89487. * Defines the actions happening just after a mesh has been drawn.
  89488. */
  89489. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  89490. /**
  89491. * @hidden
  89492. * Defines the actions happening just after a rendering group has been drawn.
  89493. */
  89494. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  89495. /**
  89496. * @hidden
  89497. * Defines the actions happening just after the active camera has been drawn.
  89498. */
  89499. _afterCameraDrawStage: Stage<CameraStageAction>;
  89500. /**
  89501. * @hidden
  89502. * Defines the actions happening just after a render target has been drawn.
  89503. */
  89504. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  89505. /**
  89506. * @hidden
  89507. * Defines the actions happening just after rendering all cameras and computing intersections.
  89508. */
  89509. _afterRenderStage: Stage<SimpleStageAction>;
  89510. /**
  89511. * @hidden
  89512. * Defines the actions happening when a pointer move event happens.
  89513. */
  89514. _pointerMoveStage: Stage<PointerMoveStageAction>;
  89515. /**
  89516. * @hidden
  89517. * Defines the actions happening when a pointer down event happens.
  89518. */
  89519. _pointerDownStage: Stage<PointerUpDownStageAction>;
  89520. /**
  89521. * @hidden
  89522. * Defines the actions happening when a pointer up event happens.
  89523. */
  89524. _pointerUpStage: Stage<PointerUpDownStageAction>;
  89525. /**
  89526. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  89527. */
  89528. private geometriesByUniqueId;
  89529. /**
  89530. * Creates a new Scene
  89531. * @param engine defines the engine to use to render this scene
  89532. * @param options defines the scene options
  89533. */
  89534. constructor(engine: Engine, options?: SceneOptions);
  89535. private _defaultMeshCandidates;
  89536. /**
  89537. * @hidden
  89538. */
  89539. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  89540. private _defaultSubMeshCandidates;
  89541. /**
  89542. * @hidden
  89543. */
  89544. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  89545. /**
  89546. * Sets the default candidate providers for the scene.
  89547. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  89548. * and getCollidingSubMeshCandidates to their default function
  89549. */
  89550. setDefaultCandidateProviders(): void;
  89551. /**
  89552. * Gets the mesh that is currently under the pointer
  89553. */
  89554. readonly meshUnderPointer: Nullable<AbstractMesh>;
  89555. /**
  89556. * Gets or sets the current on-screen X position of the pointer
  89557. */
  89558. pointerX: number;
  89559. /**
  89560. * Gets or sets the current on-screen Y position of the pointer
  89561. */
  89562. pointerY: number;
  89563. /**
  89564. * Gets the cached material (ie. the latest rendered one)
  89565. * @returns the cached material
  89566. */
  89567. getCachedMaterial(): Nullable<Material>;
  89568. /**
  89569. * Gets the cached effect (ie. the latest rendered one)
  89570. * @returns the cached effect
  89571. */
  89572. getCachedEffect(): Nullable<Effect>;
  89573. /**
  89574. * Gets the cached visibility state (ie. the latest rendered one)
  89575. * @returns the cached visibility state
  89576. */
  89577. getCachedVisibility(): Nullable<number>;
  89578. /**
  89579. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  89580. * @param material defines the current material
  89581. * @param effect defines the current effect
  89582. * @param visibility defines the current visibility state
  89583. * @returns true if one parameter is not cached
  89584. */
  89585. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  89586. /**
  89587. * Gets the engine associated with the scene
  89588. * @returns an Engine
  89589. */
  89590. getEngine(): Engine;
  89591. /**
  89592. * Gets the total number of vertices rendered per frame
  89593. * @returns the total number of vertices rendered per frame
  89594. */
  89595. getTotalVertices(): number;
  89596. /**
  89597. * Gets the performance counter for total vertices
  89598. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  89599. */
  89600. readonly totalVerticesPerfCounter: PerfCounter;
  89601. /**
  89602. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  89603. * @returns the total number of active indices rendered per frame
  89604. */
  89605. getActiveIndices(): number;
  89606. /**
  89607. * Gets the performance counter for active indices
  89608. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  89609. */
  89610. readonly totalActiveIndicesPerfCounter: PerfCounter;
  89611. /**
  89612. * Gets the total number of active particles rendered per frame
  89613. * @returns the total number of active particles rendered per frame
  89614. */
  89615. getActiveParticles(): number;
  89616. /**
  89617. * Gets the performance counter for active particles
  89618. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  89619. */
  89620. readonly activeParticlesPerfCounter: PerfCounter;
  89621. /**
  89622. * Gets the total number of active bones rendered per frame
  89623. * @returns the total number of active bones rendered per frame
  89624. */
  89625. getActiveBones(): number;
  89626. /**
  89627. * Gets the performance counter for active bones
  89628. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  89629. */
  89630. readonly activeBonesPerfCounter: PerfCounter;
  89631. /**
  89632. * Gets the array of active meshes
  89633. * @returns an array of AbstractMesh
  89634. */
  89635. getActiveMeshes(): SmartArray<AbstractMesh>;
  89636. /**
  89637. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  89638. * @returns a number
  89639. */
  89640. getAnimationRatio(): number;
  89641. /**
  89642. * Gets an unique Id for the current render phase
  89643. * @returns a number
  89644. */
  89645. getRenderId(): number;
  89646. /**
  89647. * Gets an unique Id for the current frame
  89648. * @returns a number
  89649. */
  89650. getFrameId(): number;
  89651. /** Call this function if you want to manually increment the render Id*/
  89652. incrementRenderId(): void;
  89653. private _updatePointerPosition;
  89654. private _createUbo;
  89655. private _createAlternateUbo;
  89656. private _setRayOnPointerInfo;
  89657. /**
  89658. * Use this method to simulate a pointer move on a mesh
  89659. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  89660. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  89661. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  89662. * @returns the current scene
  89663. */
  89664. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  89665. private _processPointerMove;
  89666. private _checkPrePointerObservable;
  89667. /**
  89668. * Use this method to simulate a pointer down on a mesh
  89669. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  89670. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  89671. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  89672. * @returns the current scene
  89673. */
  89674. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  89675. private _processPointerDown;
  89676. /**
  89677. * Use this method to simulate a pointer up on a mesh
  89678. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  89679. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  89680. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  89681. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  89682. * @returns the current scene
  89683. */
  89684. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  89685. private _processPointerUp;
  89686. /**
  89687. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  89688. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  89689. * @returns true if the pointer was captured
  89690. */
  89691. isPointerCaptured(pointerId?: number): boolean;
  89692. /** @hidden */
  89693. _isPointerSwiping(): boolean;
  89694. /**
  89695. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  89696. * @param attachUp defines if you want to attach events to pointerup
  89697. * @param attachDown defines if you want to attach events to pointerdown
  89698. * @param attachMove defines if you want to attach events to pointermove
  89699. */
  89700. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  89701. /** Detaches all event handlers*/
  89702. detachControl(): void;
  89703. /**
  89704. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  89705. * Delay loaded resources are not taking in account
  89706. * @return true if all required resources are ready
  89707. */
  89708. isReady(): boolean;
  89709. /** Resets all cached information relative to material (including effect and visibility) */
  89710. resetCachedMaterial(): void;
  89711. /**
  89712. * Registers a function to be called before every frame render
  89713. * @param func defines the function to register
  89714. */
  89715. registerBeforeRender(func: () => void): void;
  89716. /**
  89717. * Unregisters a function called before every frame render
  89718. * @param func defines the function to unregister
  89719. */
  89720. unregisterBeforeRender(func: () => void): void;
  89721. /**
  89722. * Registers a function to be called after every frame render
  89723. * @param func defines the function to register
  89724. */
  89725. registerAfterRender(func: () => void): void;
  89726. /**
  89727. * Unregisters a function called after every frame render
  89728. * @param func defines the function to unregister
  89729. */
  89730. unregisterAfterRender(func: () => void): void;
  89731. private _executeOnceBeforeRender;
  89732. /**
  89733. * The provided function will run before render once and will be disposed afterwards.
  89734. * A timeout delay can be provided so that the function will be executed in N ms.
  89735. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  89736. * @param func The function to be executed.
  89737. * @param timeout optional delay in ms
  89738. */
  89739. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  89740. /** @hidden */
  89741. _addPendingData(data: any): void;
  89742. /** @hidden */
  89743. _removePendingData(data: any): void;
  89744. /**
  89745. * Returns the number of items waiting to be loaded
  89746. * @returns the number of items waiting to be loaded
  89747. */
  89748. getWaitingItemsCount(): number;
  89749. /**
  89750. * Returns a boolean indicating if the scene is still loading data
  89751. */
  89752. readonly isLoading: boolean;
  89753. /**
  89754. * Registers a function to be executed when the scene is ready
  89755. * @param {Function} func - the function to be executed
  89756. */
  89757. executeWhenReady(func: () => void): void;
  89758. /**
  89759. * Returns a promise that resolves when the scene is ready
  89760. * @returns A promise that resolves when the scene is ready
  89761. */
  89762. whenReadyAsync(): Promise<void>;
  89763. /** @hidden */
  89764. _checkIsReady(): void;
  89765. /**
  89766. * Gets all animatable attached to the scene
  89767. */
  89768. readonly animatables: Animatable[];
  89769. /**
  89770. * Resets the last animation time frame.
  89771. * Useful to override when animations start running when loading a scene for the first time.
  89772. */
  89773. resetLastAnimationTimeFrame(): void;
  89774. /** @hidden */
  89775. _switchToAlternateCameraConfiguration(active: boolean): void;
  89776. /**
  89777. * Gets the current view matrix
  89778. * @returns a Matrix
  89779. */
  89780. getViewMatrix(): Matrix;
  89781. /**
  89782. * Gets the current projection matrix
  89783. * @returns a Matrix
  89784. */
  89785. getProjectionMatrix(): Matrix;
  89786. /**
  89787. * Gets the current transform matrix
  89788. * @returns a Matrix made of View * Projection
  89789. */
  89790. getTransformMatrix(): Matrix;
  89791. /**
  89792. * Sets the current transform matrix
  89793. * @param view defines the View matrix to use
  89794. * @param projection defines the Projection matrix to use
  89795. */
  89796. setTransformMatrix(view: Matrix, projection: Matrix): void;
  89797. /** @hidden */
  89798. _setAlternateTransformMatrix(view: Matrix, projection: Matrix): void;
  89799. /**
  89800. * Gets the uniform buffer used to store scene data
  89801. * @returns a UniformBuffer
  89802. */
  89803. getSceneUniformBuffer(): UniformBuffer;
  89804. /**
  89805. * Gets an unique (relatively to the current scene) Id
  89806. * @returns an unique number for the scene
  89807. */
  89808. getUniqueId(): number;
  89809. /**
  89810. * Add a mesh to the list of scene's meshes
  89811. * @param newMesh defines the mesh to add
  89812. * @param recursive if all child meshes should also be added to the scene
  89813. */
  89814. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  89815. /**
  89816. * Remove a mesh for the list of scene's meshes
  89817. * @param toRemove defines the mesh to remove
  89818. * @param recursive if all child meshes should also be removed from the scene
  89819. * @returns the index where the mesh was in the mesh list
  89820. */
  89821. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  89822. /**
  89823. * Add a transform node to the list of scene's transform nodes
  89824. * @param newTransformNode defines the transform node to add
  89825. */
  89826. addTransformNode(newTransformNode: TransformNode): void;
  89827. /**
  89828. * Remove a transform node for the list of scene's transform nodes
  89829. * @param toRemove defines the transform node to remove
  89830. * @returns the index where the transform node was in the transform node list
  89831. */
  89832. removeTransformNode(toRemove: TransformNode): number;
  89833. /**
  89834. * Remove a skeleton for the list of scene's skeletons
  89835. * @param toRemove defines the skeleton to remove
  89836. * @returns the index where the skeleton was in the skeleton list
  89837. */
  89838. removeSkeleton(toRemove: Skeleton): number;
  89839. /**
  89840. * Remove a morph target for the list of scene's morph targets
  89841. * @param toRemove defines the morph target to remove
  89842. * @returns the index where the morph target was in the morph target list
  89843. */
  89844. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  89845. /**
  89846. * Remove a light for the list of scene's lights
  89847. * @param toRemove defines the light to remove
  89848. * @returns the index where the light was in the light list
  89849. */
  89850. removeLight(toRemove: Light): number;
  89851. /**
  89852. * Remove a camera for the list of scene's cameras
  89853. * @param toRemove defines the camera to remove
  89854. * @returns the index where the camera was in the camera list
  89855. */
  89856. removeCamera(toRemove: Camera): number;
  89857. /**
  89858. * Remove a particle system for the list of scene's particle systems
  89859. * @param toRemove defines the particle system to remove
  89860. * @returns the index where the particle system was in the particle system list
  89861. */
  89862. removeParticleSystem(toRemove: IParticleSystem): number;
  89863. /**
  89864. * Remove a animation for the list of scene's animations
  89865. * @param toRemove defines the animation to remove
  89866. * @returns the index where the animation was in the animation list
  89867. */
  89868. removeAnimation(toRemove: Animation): number;
  89869. /**
  89870. * Removes the given animation group from this scene.
  89871. * @param toRemove The animation group to remove
  89872. * @returns The index of the removed animation group
  89873. */
  89874. removeAnimationGroup(toRemove: AnimationGroup): number;
  89875. /**
  89876. * Removes the given multi-material from this scene.
  89877. * @param toRemove The multi-material to remove
  89878. * @returns The index of the removed multi-material
  89879. */
  89880. removeMultiMaterial(toRemove: MultiMaterial): number;
  89881. /**
  89882. * Removes the given material from this scene.
  89883. * @param toRemove The material to remove
  89884. * @returns The index of the removed material
  89885. */
  89886. removeMaterial(toRemove: Material): number;
  89887. /**
  89888. * Removes the given action manager from this scene.
  89889. * @param toRemove The action manager to remove
  89890. * @returns The index of the removed action manager
  89891. */
  89892. removeActionManager(toRemove: AbstractActionManager): number;
  89893. /**
  89894. * Removes the given texture from this scene.
  89895. * @param toRemove The texture to remove
  89896. * @returns The index of the removed texture
  89897. */
  89898. removeTexture(toRemove: BaseTexture): number;
  89899. /**
  89900. * Adds the given light to this scene
  89901. * @param newLight The light to add
  89902. */
  89903. addLight(newLight: Light): void;
  89904. /**
  89905. * Sorts the list list based on light priorities
  89906. */
  89907. sortLightsByPriority(): void;
  89908. /**
  89909. * Adds the given camera to this scene
  89910. * @param newCamera The camera to add
  89911. */
  89912. addCamera(newCamera: Camera): void;
  89913. /**
  89914. * Adds the given skeleton to this scene
  89915. * @param newSkeleton The skeleton to add
  89916. */
  89917. addSkeleton(newSkeleton: Skeleton): void;
  89918. /**
  89919. * Adds the given particle system to this scene
  89920. * @param newParticleSystem The particle system to add
  89921. */
  89922. addParticleSystem(newParticleSystem: IParticleSystem): void;
  89923. /**
  89924. * Adds the given animation to this scene
  89925. * @param newAnimation The animation to add
  89926. */
  89927. addAnimation(newAnimation: Animation): void;
  89928. /**
  89929. * Adds the given animation group to this scene.
  89930. * @param newAnimationGroup The animation group to add
  89931. */
  89932. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  89933. /**
  89934. * Adds the given multi-material to this scene
  89935. * @param newMultiMaterial The multi-material to add
  89936. */
  89937. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  89938. /**
  89939. * Adds the given material to this scene
  89940. * @param newMaterial The material to add
  89941. */
  89942. addMaterial(newMaterial: Material): void;
  89943. /**
  89944. * Adds the given morph target to this scene
  89945. * @param newMorphTargetManager The morph target to add
  89946. */
  89947. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  89948. /**
  89949. * Adds the given geometry to this scene
  89950. * @param newGeometry The geometry to add
  89951. */
  89952. addGeometry(newGeometry: Geometry): void;
  89953. /**
  89954. * Adds the given action manager to this scene
  89955. * @param newActionManager The action manager to add
  89956. */
  89957. addActionManager(newActionManager: AbstractActionManager): void;
  89958. /**
  89959. * Adds the given texture to this scene.
  89960. * @param newTexture The texture to add
  89961. */
  89962. addTexture(newTexture: BaseTexture): void;
  89963. /**
  89964. * Switch active camera
  89965. * @param newCamera defines the new active camera
  89966. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  89967. */
  89968. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  89969. /**
  89970. * sets the active camera of the scene using its ID
  89971. * @param id defines the camera's ID
  89972. * @return the new active camera or null if none found.
  89973. */
  89974. setActiveCameraByID(id: string): Nullable<Camera>;
  89975. /**
  89976. * sets the active camera of the scene using its name
  89977. * @param name defines the camera's name
  89978. * @returns the new active camera or null if none found.
  89979. */
  89980. setActiveCameraByName(name: string): Nullable<Camera>;
  89981. /**
  89982. * get an animation group using its name
  89983. * @param name defines the material's name
  89984. * @return the animation group or null if none found.
  89985. */
  89986. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  89987. /**
  89988. * get a material using its id
  89989. * @param id defines the material's ID
  89990. * @return the material or null if none found.
  89991. */
  89992. getMaterialByID(id: string): Nullable<Material>;
  89993. /**
  89994. * Gets a material using its name
  89995. * @param name defines the material's name
  89996. * @return the material or null if none found.
  89997. */
  89998. getMaterialByName(name: string): Nullable<Material>;
  89999. /**
  90000. * Gets a camera using its id
  90001. * @param id defines the id to look for
  90002. * @returns the camera or null if not found
  90003. */
  90004. getCameraByID(id: string): Nullable<Camera>;
  90005. /**
  90006. * Gets a camera using its unique id
  90007. * @param uniqueId defines the unique id to look for
  90008. * @returns the camera or null if not found
  90009. */
  90010. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  90011. /**
  90012. * Gets a camera using its name
  90013. * @param name defines the camera's name
  90014. * @return the camera or null if none found.
  90015. */
  90016. getCameraByName(name: string): Nullable<Camera>;
  90017. /**
  90018. * Gets a bone using its id
  90019. * @param id defines the bone's id
  90020. * @return the bone or null if not found
  90021. */
  90022. getBoneByID(id: string): Nullable<Bone>;
  90023. /**
  90024. * Gets a bone using its id
  90025. * @param name defines the bone's name
  90026. * @return the bone or null if not found
  90027. */
  90028. getBoneByName(name: string): Nullable<Bone>;
  90029. /**
  90030. * Gets a light node using its name
  90031. * @param name defines the the light's name
  90032. * @return the light or null if none found.
  90033. */
  90034. getLightByName(name: string): Nullable<Light>;
  90035. /**
  90036. * Gets a light node using its id
  90037. * @param id defines the light's id
  90038. * @return the light or null if none found.
  90039. */
  90040. getLightByID(id: string): Nullable<Light>;
  90041. /**
  90042. * Gets a light node using its scene-generated unique ID
  90043. * @param uniqueId defines the light's unique id
  90044. * @return the light or null if none found.
  90045. */
  90046. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  90047. /**
  90048. * Gets a particle system by id
  90049. * @param id defines the particle system id
  90050. * @return the corresponding system or null if none found
  90051. */
  90052. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  90053. /**
  90054. * Gets a geometry using its ID
  90055. * @param id defines the geometry's id
  90056. * @return the geometry or null if none found.
  90057. */
  90058. getGeometryByID(id: string): Nullable<Geometry>;
  90059. private _getGeometryByUniqueID;
  90060. /**
  90061. * Add a new geometry to this scene
  90062. * @param geometry defines the geometry to be added to the scene.
  90063. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  90064. * @return a boolean defining if the geometry was added or not
  90065. */
  90066. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  90067. /**
  90068. * Removes an existing geometry
  90069. * @param geometry defines the geometry to be removed from the scene
  90070. * @return a boolean defining if the geometry was removed or not
  90071. */
  90072. removeGeometry(geometry: Geometry): boolean;
  90073. /**
  90074. * Gets the list of geometries attached to the scene
  90075. * @returns an array of Geometry
  90076. */
  90077. getGeometries(): Geometry[];
  90078. /**
  90079. * Gets the first added mesh found of a given ID
  90080. * @param id defines the id to search for
  90081. * @return the mesh found or null if not found at all
  90082. */
  90083. getMeshByID(id: string): Nullable<AbstractMesh>;
  90084. /**
  90085. * Gets a list of meshes using their id
  90086. * @param id defines the id to search for
  90087. * @returns a list of meshes
  90088. */
  90089. getMeshesByID(id: string): Array<AbstractMesh>;
  90090. /**
  90091. * Gets the first added transform node found of a given ID
  90092. * @param id defines the id to search for
  90093. * @return the found transform node or null if not found at all.
  90094. */
  90095. getTransformNodeByID(id: string): Nullable<TransformNode>;
  90096. /**
  90097. * Gets a list of transform nodes using their id
  90098. * @param id defines the id to search for
  90099. * @returns a list of transform nodes
  90100. */
  90101. getTransformNodesByID(id: string): Array<TransformNode>;
  90102. /**
  90103. * Gets a mesh with its auto-generated unique id
  90104. * @param uniqueId defines the unique id to search for
  90105. * @return the found mesh or null if not found at all.
  90106. */
  90107. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  90108. /**
  90109. * Gets a the last added mesh using a given id
  90110. * @param id defines the id to search for
  90111. * @return the found mesh or null if not found at all.
  90112. */
  90113. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  90114. /**
  90115. * Gets a the last added node (Mesh, Camera, Light) using a given id
  90116. * @param id defines the id to search for
  90117. * @return the found node or null if not found at all
  90118. */
  90119. getLastEntryByID(id: string): Nullable<Node>;
  90120. /**
  90121. * Gets a node (Mesh, Camera, Light) using a given id
  90122. * @param id defines the id to search for
  90123. * @return the found node or null if not found at all
  90124. */
  90125. getNodeByID(id: string): Nullable<Node>;
  90126. /**
  90127. * Gets a node (Mesh, Camera, Light) using a given name
  90128. * @param name defines the name to search for
  90129. * @return the found node or null if not found at all.
  90130. */
  90131. getNodeByName(name: string): Nullable<Node>;
  90132. /**
  90133. * Gets a mesh using a given name
  90134. * @param name defines the name to search for
  90135. * @return the found mesh or null if not found at all.
  90136. */
  90137. getMeshByName(name: string): Nullable<AbstractMesh>;
  90138. /**
  90139. * Gets a transform node using a given name
  90140. * @param name defines the name to search for
  90141. * @return the found transform node or null if not found at all.
  90142. */
  90143. getTransformNodeByName(name: string): Nullable<TransformNode>;
  90144. /**
  90145. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  90146. * @param id defines the id to search for
  90147. * @return the found skeleton or null if not found at all.
  90148. */
  90149. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  90150. /**
  90151. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  90152. * @param id defines the id to search for
  90153. * @return the found skeleton or null if not found at all.
  90154. */
  90155. getSkeletonById(id: string): Nullable<Skeleton>;
  90156. /**
  90157. * Gets a skeleton using a given name
  90158. * @param name defines the name to search for
  90159. * @return the found skeleton or null if not found at all.
  90160. */
  90161. getSkeletonByName(name: string): Nullable<Skeleton>;
  90162. /**
  90163. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  90164. * @param id defines the id to search for
  90165. * @return the found morph target manager or null if not found at all.
  90166. */
  90167. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  90168. /**
  90169. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  90170. * @param id defines the id to search for
  90171. * @return the found morph target or null if not found at all.
  90172. */
  90173. getMorphTargetById(id: string): Nullable<MorphTarget>;
  90174. /**
  90175. * Gets a boolean indicating if the given mesh is active
  90176. * @param mesh defines the mesh to look for
  90177. * @returns true if the mesh is in the active list
  90178. */
  90179. isActiveMesh(mesh: AbstractMesh): boolean;
  90180. /**
  90181. * Return a unique id as a string which can serve as an identifier for the scene
  90182. */
  90183. readonly uid: string;
  90184. /**
  90185. * Add an externaly attached data from its key.
  90186. * This method call will fail and return false, if such key already exists.
  90187. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  90188. * @param key the unique key that identifies the data
  90189. * @param data the data object to associate to the key for this Engine instance
  90190. * @return true if no such key were already present and the data was added successfully, false otherwise
  90191. */
  90192. addExternalData<T>(key: string, data: T): boolean;
  90193. /**
  90194. * Get an externaly attached data from its key
  90195. * @param key the unique key that identifies the data
  90196. * @return the associated data, if present (can be null), or undefined if not present
  90197. */
  90198. getExternalData<T>(key: string): Nullable<T>;
  90199. /**
  90200. * Get an externaly attached data from its key, create it using a factory if it's not already present
  90201. * @param key the unique key that identifies the data
  90202. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  90203. * @return the associated data, can be null if the factory returned null.
  90204. */
  90205. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  90206. /**
  90207. * Remove an externaly attached data from the Engine instance
  90208. * @param key the unique key that identifies the data
  90209. * @return true if the data was successfully removed, false if it doesn't exist
  90210. */
  90211. removeExternalData(key: string): boolean;
  90212. private _evaluateSubMesh;
  90213. /**
  90214. * Clear the processed materials smart array preventing retention point in material dispose.
  90215. */
  90216. freeProcessedMaterials(): void;
  90217. private _preventFreeActiveMeshesAndRenderingGroups;
  90218. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  90219. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  90220. * when disposing several meshes in a row or a hierarchy of meshes.
  90221. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  90222. */
  90223. blockfreeActiveMeshesAndRenderingGroups: boolean;
  90224. /**
  90225. * Clear the active meshes smart array preventing retention point in mesh dispose.
  90226. */
  90227. freeActiveMeshes(): void;
  90228. /**
  90229. * Clear the info related to rendering groups preventing retention points during dispose.
  90230. */
  90231. freeRenderingGroups(): void;
  90232. /** @hidden */
  90233. _isInIntermediateRendering(): boolean;
  90234. /**
  90235. * Lambda returning the list of potentially active meshes.
  90236. */
  90237. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  90238. /**
  90239. * Lambda returning the list of potentially active sub meshes.
  90240. */
  90241. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  90242. /**
  90243. * Lambda returning the list of potentially intersecting sub meshes.
  90244. */
  90245. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  90246. /**
  90247. * Lambda returning the list of potentially colliding sub meshes.
  90248. */
  90249. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  90250. private _activeMeshesFrozen;
  90251. /**
  90252. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  90253. * @returns the current scene
  90254. */
  90255. freezeActiveMeshes(): Scene;
  90256. /**
  90257. * Use this function to restart evaluating active meshes on every frame
  90258. * @returns the current scene
  90259. */
  90260. unfreezeActiveMeshes(): Scene;
  90261. private _evaluateActiveMeshes;
  90262. private _activeMesh;
  90263. /**
  90264. * Update the transform matrix to update from the current active camera
  90265. * @param force defines a boolean used to force the update even if cache is up to date
  90266. */
  90267. updateTransformMatrix(force?: boolean): void;
  90268. /**
  90269. * 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)
  90270. * @param alternateCamera defines the camera to use
  90271. */
  90272. updateAlternateTransformMatrix(alternateCamera: Camera): void;
  90273. /** @hidden */
  90274. _allowPostProcessClearColor: boolean;
  90275. private _renderForCamera;
  90276. private _processSubCameras;
  90277. private _checkIntersections;
  90278. /** @hidden */
  90279. _advancePhysicsEngineStep(step: number): void;
  90280. /**
  90281. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  90282. */
  90283. getDeterministicFrameTime: () => number;
  90284. /** @hidden */
  90285. _animate(): void;
  90286. /**
  90287. * Render the scene
  90288. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  90289. */
  90290. render(updateCameras?: boolean): void;
  90291. /**
  90292. * Freeze all materials
  90293. * A frozen material will not be updatable but should be faster to render
  90294. */
  90295. freezeMaterials(): void;
  90296. /**
  90297. * Unfreeze all materials
  90298. * A frozen material will not be updatable but should be faster to render
  90299. */
  90300. unfreezeMaterials(): void;
  90301. /**
  90302. * Releases all held ressources
  90303. */
  90304. dispose(): void;
  90305. /**
  90306. * Gets if the scene is already disposed
  90307. */
  90308. readonly isDisposed: boolean;
  90309. /**
  90310. * Call this function to reduce memory footprint of the scene.
  90311. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  90312. */
  90313. clearCachedVertexData(): void;
  90314. /**
  90315. * This function will remove the local cached buffer data from texture.
  90316. * It will save memory but will prevent the texture from being rebuilt
  90317. */
  90318. cleanCachedTextureBuffer(): void;
  90319. /**
  90320. * Get the world extend vectors with an optional filter
  90321. *
  90322. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  90323. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  90324. */
  90325. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  90326. min: Vector3;
  90327. max: Vector3;
  90328. };
  90329. /**
  90330. * Creates a ray that can be used to pick in the scene
  90331. * @param x defines the x coordinate of the origin (on-screen)
  90332. * @param y defines the y coordinate of the origin (on-screen)
  90333. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  90334. * @param camera defines the camera to use for the picking
  90335. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  90336. * @returns a Ray
  90337. */
  90338. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  90339. /**
  90340. * Creates a ray that can be used to pick in the scene
  90341. * @param x defines the x coordinate of the origin (on-screen)
  90342. * @param y defines the y coordinate of the origin (on-screen)
  90343. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  90344. * @param result defines the ray where to store the picking ray
  90345. * @param camera defines the camera to use for the picking
  90346. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  90347. * @returns the current scene
  90348. */
  90349. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  90350. /**
  90351. * Creates a ray that can be used to pick in the scene
  90352. * @param x defines the x coordinate of the origin (on-screen)
  90353. * @param y defines the y coordinate of the origin (on-screen)
  90354. * @param camera defines the camera to use for the picking
  90355. * @returns a Ray
  90356. */
  90357. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  90358. /**
  90359. * Creates a ray that can be used to pick in the scene
  90360. * @param x defines the x coordinate of the origin (on-screen)
  90361. * @param y defines the y coordinate of the origin (on-screen)
  90362. * @param result defines the ray where to store the picking ray
  90363. * @param camera defines the camera to use for the picking
  90364. * @returns the current scene
  90365. */
  90366. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  90367. /** Launch a ray to try to pick a mesh in the scene
  90368. * @param x position on screen
  90369. * @param y position on screen
  90370. * @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
  90371. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  90372. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  90373. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  90374. * @returns a PickingInfo
  90375. */
  90376. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: (p0: Vector3, p1: Vector3, p2: Vector3) => boolean): Nullable<PickingInfo>;
  90377. /** Use the given ray to pick a mesh in the scene
  90378. * @param ray The ray to use to pick meshes
  90379. * @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
  90380. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  90381. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  90382. * @returns a PickingInfo
  90383. */
  90384. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  90385. /**
  90386. * Launch a ray to try to pick a mesh in the scene
  90387. * @param x X position on screen
  90388. * @param y Y position on screen
  90389. * @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
  90390. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  90391. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  90392. * @returns an array of PickingInfo
  90393. */
  90394. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  90395. /**
  90396. * Launch a ray to try to pick a mesh in the scene
  90397. * @param ray Ray to use
  90398. * @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
  90399. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  90400. * @returns an array of PickingInfo
  90401. */
  90402. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  90403. /**
  90404. * Force the value of meshUnderPointer
  90405. * @param mesh defines the mesh to use
  90406. */
  90407. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  90408. /**
  90409. * Gets the mesh under the pointer
  90410. * @returns a Mesh or null if no mesh is under the pointer
  90411. */
  90412. getPointerOverMesh(): Nullable<AbstractMesh>;
  90413. /** @hidden */
  90414. _rebuildGeometries(): void;
  90415. /** @hidden */
  90416. _rebuildTextures(): void;
  90417. private _getByTags;
  90418. /**
  90419. * Get a list of meshes by tags
  90420. * @param tagsQuery defines the tags query to use
  90421. * @param forEach defines a predicate used to filter results
  90422. * @returns an array of Mesh
  90423. */
  90424. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  90425. /**
  90426. * Get a list of cameras by tags
  90427. * @param tagsQuery defines the tags query to use
  90428. * @param forEach defines a predicate used to filter results
  90429. * @returns an array of Camera
  90430. */
  90431. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  90432. /**
  90433. * Get a list of lights by tags
  90434. * @param tagsQuery defines the tags query to use
  90435. * @param forEach defines a predicate used to filter results
  90436. * @returns an array of Light
  90437. */
  90438. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  90439. /**
  90440. * Get a list of materials by tags
  90441. * @param tagsQuery defines the tags query to use
  90442. * @param forEach defines a predicate used to filter results
  90443. * @returns an array of Material
  90444. */
  90445. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  90446. /**
  90447. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  90448. * This allowed control for front to back rendering or reversly depending of the special needs.
  90449. *
  90450. * @param renderingGroupId The rendering group id corresponding to its index
  90451. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  90452. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  90453. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  90454. */
  90455. 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;
  90456. /**
  90457. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  90458. *
  90459. * @param renderingGroupId The rendering group id corresponding to its index
  90460. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  90461. * @param depth Automatically clears depth between groups if true and autoClear is true.
  90462. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  90463. */
  90464. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  90465. /**
  90466. * Gets the current auto clear configuration for one rendering group of the rendering
  90467. * manager.
  90468. * @param index the rendering group index to get the information for
  90469. * @returns The auto clear setup for the requested rendering group
  90470. */
  90471. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  90472. private _blockMaterialDirtyMechanism;
  90473. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  90474. blockMaterialDirtyMechanism: boolean;
  90475. /**
  90476. * Will flag all materials as dirty to trigger new shader compilation
  90477. * @param flag defines the flag used to specify which material part must be marked as dirty
  90478. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  90479. */
  90480. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  90481. /** @hidden */
  90482. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (request?: XMLHttpRequest, exception?: any) => void): IFileRequest;
  90483. /** @hidden */
  90484. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  90485. }
  90486. }
  90487. declare module BABYLON {
  90488. /**
  90489. * Set of assets to keep when moving a scene into an asset container.
  90490. */
  90491. export class KeepAssets extends AbstractScene {
  90492. }
  90493. /**
  90494. * Container with a set of assets that can be added or removed from a scene.
  90495. */
  90496. export class AssetContainer extends AbstractScene {
  90497. /**
  90498. * The scene the AssetContainer belongs to.
  90499. */
  90500. scene: Scene;
  90501. /**
  90502. * Instantiates an AssetContainer.
  90503. * @param scene The scene the AssetContainer belongs to.
  90504. */
  90505. constructor(scene: Scene);
  90506. /**
  90507. * Adds all the assets from the container to the scene.
  90508. */
  90509. addAllToScene(): void;
  90510. /**
  90511. * Removes all the assets in the container from the scene
  90512. */
  90513. removeAllFromScene(): void;
  90514. /**
  90515. * Disposes all the assets in the container
  90516. */
  90517. dispose(): void;
  90518. private _moveAssets;
  90519. /**
  90520. * Removes all the assets contained in the scene and adds them to the container.
  90521. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  90522. */
  90523. moveAllFromScene(keepAssets?: KeepAssets): void;
  90524. /**
  90525. * 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.
  90526. * @returns the root mesh
  90527. */
  90528. createRootMesh(): Mesh;
  90529. }
  90530. }
  90531. declare module BABYLON {
  90532. /**
  90533. * Defines how the parser contract is defined.
  90534. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  90535. */
  90536. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  90537. /**
  90538. * Defines how the individual parser contract is defined.
  90539. * These parser can parse an individual asset
  90540. */
  90541. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  90542. /**
  90543. * Base class of the scene acting as a container for the different elements composing a scene.
  90544. * This class is dynamically extended by the different components of the scene increasing
  90545. * flexibility and reducing coupling
  90546. */
  90547. export abstract class AbstractScene {
  90548. /**
  90549. * Stores the list of available parsers in the application.
  90550. */
  90551. private static _BabylonFileParsers;
  90552. /**
  90553. * Stores the list of available individual parsers in the application.
  90554. */
  90555. private static _IndividualBabylonFileParsers;
  90556. /**
  90557. * Adds a parser in the list of available ones
  90558. * @param name Defines the name of the parser
  90559. * @param parser Defines the parser to add
  90560. */
  90561. static AddParser(name: string, parser: BabylonFileParser): void;
  90562. /**
  90563. * Gets a general parser from the list of avaialble ones
  90564. * @param name Defines the name of the parser
  90565. * @returns the requested parser or null
  90566. */
  90567. static GetParser(name: string): Nullable<BabylonFileParser>;
  90568. /**
  90569. * Adds n individual parser in the list of available ones
  90570. * @param name Defines the name of the parser
  90571. * @param parser Defines the parser to add
  90572. */
  90573. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  90574. /**
  90575. * Gets an individual parser from the list of avaialble ones
  90576. * @param name Defines the name of the parser
  90577. * @returns the requested parser or null
  90578. */
  90579. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  90580. /**
  90581. * Parser json data and populate both a scene and its associated container object
  90582. * @param jsonData Defines the data to parse
  90583. * @param scene Defines the scene to parse the data for
  90584. * @param container Defines the container attached to the parsing sequence
  90585. * @param rootUrl Defines the root url of the data
  90586. */
  90587. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  90588. /**
  90589. * Gets the list of root nodes (ie. nodes with no parent)
  90590. */
  90591. rootNodes: Node[];
  90592. /** All of the cameras added to this scene
  90593. * @see http://doc.babylonjs.com/babylon101/cameras
  90594. */
  90595. cameras: Camera[];
  90596. /**
  90597. * All of the lights added to this scene
  90598. * @see http://doc.babylonjs.com/babylon101/lights
  90599. */
  90600. lights: Light[];
  90601. /**
  90602. * All of the (abstract) meshes added to this scene
  90603. */
  90604. meshes: AbstractMesh[];
  90605. /**
  90606. * The list of skeletons added to the scene
  90607. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  90608. */
  90609. skeletons: Skeleton[];
  90610. /**
  90611. * All of the particle systems added to this scene
  90612. * @see http://doc.babylonjs.com/babylon101/particles
  90613. */
  90614. particleSystems: IParticleSystem[];
  90615. /**
  90616. * Gets a list of Animations associated with the scene
  90617. */
  90618. animations: Animation[];
  90619. /**
  90620. * All of the animation groups added to this scene
  90621. * @see http://doc.babylonjs.com/how_to/group
  90622. */
  90623. animationGroups: AnimationGroup[];
  90624. /**
  90625. * All of the multi-materials added to this scene
  90626. * @see http://doc.babylonjs.com/how_to/multi_materials
  90627. */
  90628. multiMaterials: MultiMaterial[];
  90629. /**
  90630. * All of the materials added to this scene
  90631. * In the context of a Scene, it is not supposed to be modified manually.
  90632. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  90633. * Note also that the order of the Material wihin the array is not significant and might change.
  90634. * @see http://doc.babylonjs.com/babylon101/materials
  90635. */
  90636. materials: Material[];
  90637. /**
  90638. * The list of morph target managers added to the scene
  90639. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  90640. */
  90641. morphTargetManagers: MorphTargetManager[];
  90642. /**
  90643. * The list of geometries used in the scene.
  90644. */
  90645. geometries: Geometry[];
  90646. /**
  90647. * All of the tranform nodes added to this scene
  90648. * In the context of a Scene, it is not supposed to be modified manually.
  90649. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  90650. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  90651. * @see http://doc.babylonjs.com/how_to/transformnode
  90652. */
  90653. transformNodes: TransformNode[];
  90654. /**
  90655. * ActionManagers available on the scene.
  90656. */
  90657. actionManagers: AbstractActionManager[];
  90658. /**
  90659. * Textures to keep.
  90660. */
  90661. textures: BaseTexture[];
  90662. }
  90663. }
  90664. declare module BABYLON {
  90665. /**
  90666. * Defines a sound that can be played in the application.
  90667. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  90668. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  90669. */
  90670. export class Sound {
  90671. /**
  90672. * The name of the sound in the scene.
  90673. */
  90674. name: string;
  90675. /**
  90676. * Does the sound autoplay once loaded.
  90677. */
  90678. autoplay: boolean;
  90679. /**
  90680. * Does the sound loop after it finishes playing once.
  90681. */
  90682. loop: boolean;
  90683. /**
  90684. * Does the sound use a custom attenuation curve to simulate the falloff
  90685. * happening when the source gets further away from the camera.
  90686. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  90687. */
  90688. useCustomAttenuation: boolean;
  90689. /**
  90690. * The sound track id this sound belongs to.
  90691. */
  90692. soundTrackId: number;
  90693. /**
  90694. * Is this sound currently played.
  90695. */
  90696. isPlaying: boolean;
  90697. /**
  90698. * Is this sound currently paused.
  90699. */
  90700. isPaused: boolean;
  90701. /**
  90702. * Does this sound enables spatial sound.
  90703. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  90704. */
  90705. spatialSound: boolean;
  90706. /**
  90707. * Define the reference distance the sound should be heard perfectly.
  90708. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  90709. */
  90710. refDistance: number;
  90711. /**
  90712. * Define the roll off factor of spatial sounds.
  90713. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  90714. */
  90715. rolloffFactor: number;
  90716. /**
  90717. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  90718. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  90719. */
  90720. maxDistance: number;
  90721. /**
  90722. * Define the distance attenuation model the sound will follow.
  90723. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  90724. */
  90725. distanceModel: string;
  90726. /**
  90727. * @hidden
  90728. * Back Compat
  90729. **/
  90730. onended: () => any;
  90731. /**
  90732. * Observable event when the current playing sound finishes.
  90733. */
  90734. onEndedObservable: Observable<Sound>;
  90735. private _panningModel;
  90736. private _playbackRate;
  90737. private _streaming;
  90738. private _startTime;
  90739. private _startOffset;
  90740. private _position;
  90741. /** @hidden */
  90742. _positionInEmitterSpace: boolean;
  90743. private _localDirection;
  90744. private _volume;
  90745. private _isReadyToPlay;
  90746. private _isDirectional;
  90747. private _readyToPlayCallback;
  90748. private _audioBuffer;
  90749. private _soundSource;
  90750. private _streamingSource;
  90751. private _soundPanner;
  90752. private _soundGain;
  90753. private _inputAudioNode;
  90754. private _outputAudioNode;
  90755. private _coneInnerAngle;
  90756. private _coneOuterAngle;
  90757. private _coneOuterGain;
  90758. private _scene;
  90759. private _connectedTransformNode;
  90760. private _customAttenuationFunction;
  90761. private _registerFunc;
  90762. private _isOutputConnected;
  90763. private _htmlAudioElement;
  90764. private _urlType;
  90765. /** @hidden */
  90766. static _SceneComponentInitialization: (scene: Scene) => void;
  90767. /**
  90768. * Create a sound and attach it to a scene
  90769. * @param name Name of your sound
  90770. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  90771. * @param scene defines the scene the sound belongs to
  90772. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  90773. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  90774. */
  90775. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  90776. /**
  90777. * Release the sound and its associated resources
  90778. */
  90779. dispose(): void;
  90780. /**
  90781. * Gets if the sounds is ready to be played or not.
  90782. * @returns true if ready, otherwise false
  90783. */
  90784. isReady(): boolean;
  90785. private _soundLoaded;
  90786. /**
  90787. * Sets the data of the sound from an audiobuffer
  90788. * @param audioBuffer The audioBuffer containing the data
  90789. */
  90790. setAudioBuffer(audioBuffer: AudioBuffer): void;
  90791. /**
  90792. * Updates the current sounds options such as maxdistance, loop...
  90793. * @param options A JSON object containing values named as the object properties
  90794. */
  90795. updateOptions(options: any): void;
  90796. private _createSpatialParameters;
  90797. private _updateSpatialParameters;
  90798. /**
  90799. * Switch the panning model to HRTF:
  90800. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  90801. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  90802. */
  90803. switchPanningModelToHRTF(): void;
  90804. /**
  90805. * Switch the panning model to Equal Power:
  90806. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  90807. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  90808. */
  90809. switchPanningModelToEqualPower(): void;
  90810. private _switchPanningModel;
  90811. /**
  90812. * Connect this sound to a sound track audio node like gain...
  90813. * @param soundTrackAudioNode the sound track audio node to connect to
  90814. */
  90815. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  90816. /**
  90817. * Transform this sound into a directional source
  90818. * @param coneInnerAngle Size of the inner cone in degree
  90819. * @param coneOuterAngle Size of the outer cone in degree
  90820. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  90821. */
  90822. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  90823. /**
  90824. * Gets or sets the inner angle for the directional cone.
  90825. */
  90826. /**
  90827. * Gets or sets the inner angle for the directional cone.
  90828. */
  90829. directionalConeInnerAngle: number;
  90830. /**
  90831. * Gets or sets the outer angle for the directional cone.
  90832. */
  90833. /**
  90834. * Gets or sets the outer angle for the directional cone.
  90835. */
  90836. directionalConeOuterAngle: number;
  90837. /**
  90838. * Sets the position of the emitter if spatial sound is enabled
  90839. * @param newPosition Defines the new posisiton
  90840. */
  90841. setPosition(newPosition: Vector3): void;
  90842. /**
  90843. * Sets the local direction of the emitter if spatial sound is enabled
  90844. * @param newLocalDirection Defines the new local direction
  90845. */
  90846. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  90847. private _updateDirection;
  90848. /** @hidden */
  90849. updateDistanceFromListener(): void;
  90850. /**
  90851. * Sets a new custom attenuation function for the sound.
  90852. * @param callback Defines the function used for the attenuation
  90853. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  90854. */
  90855. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  90856. /**
  90857. * Play the sound
  90858. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  90859. * @param offset (optional) Start the sound setting it at a specific time
  90860. */
  90861. play(time?: number, offset?: number): void;
  90862. private _onended;
  90863. /**
  90864. * Stop the sound
  90865. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  90866. */
  90867. stop(time?: number): void;
  90868. /**
  90869. * Put the sound in pause
  90870. */
  90871. pause(): void;
  90872. /**
  90873. * Sets a dedicated volume for this sounds
  90874. * @param newVolume Define the new volume of the sound
  90875. * @param time Define in how long the sound should be at this value
  90876. */
  90877. setVolume(newVolume: number, time?: number): void;
  90878. /**
  90879. * Set the sound play back rate
  90880. * @param newPlaybackRate Define the playback rate the sound should be played at
  90881. */
  90882. setPlaybackRate(newPlaybackRate: number): void;
  90883. /**
  90884. * Gets the volume of the sound.
  90885. * @returns the volume of the sound
  90886. */
  90887. getVolume(): number;
  90888. /**
  90889. * Attach the sound to a dedicated mesh
  90890. * @param transformNode The transform node to connect the sound with
  90891. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  90892. */
  90893. attachToMesh(transformNode: TransformNode): void;
  90894. /**
  90895. * Detach the sound from the previously attached mesh
  90896. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  90897. */
  90898. detachFromMesh(): void;
  90899. private _onRegisterAfterWorldMatrixUpdate;
  90900. /**
  90901. * Clone the current sound in the scene.
  90902. * @returns the new sound clone
  90903. */
  90904. clone(): Nullable<Sound>;
  90905. /**
  90906. * Gets the current underlying audio buffer containing the data
  90907. * @returns the audio buffer
  90908. */
  90909. getAudioBuffer(): Nullable<AudioBuffer>;
  90910. /**
  90911. * Serializes the Sound in a JSON representation
  90912. * @returns the JSON representation of the sound
  90913. */
  90914. serialize(): any;
  90915. /**
  90916. * Parse a JSON representation of a sound to innstantiate in a given scene
  90917. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  90918. * @param scene Define the scene the new parsed sound should be created in
  90919. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  90920. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  90921. * @returns the newly parsed sound
  90922. */
  90923. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  90924. }
  90925. }
  90926. declare module BABYLON {
  90927. /**
  90928. * This defines an action helpful to play a defined sound on a triggered action.
  90929. */
  90930. export class PlaySoundAction extends Action {
  90931. private _sound;
  90932. /**
  90933. * Instantiate the action
  90934. * @param triggerOptions defines the trigger options
  90935. * @param sound defines the sound to play
  90936. * @param condition defines the trigger related conditions
  90937. */
  90938. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  90939. /** @hidden */
  90940. _prepare(): void;
  90941. /**
  90942. * Execute the action and play the sound.
  90943. */
  90944. execute(): void;
  90945. /**
  90946. * Serializes the actions and its related information.
  90947. * @param parent defines the object to serialize in
  90948. * @returns the serialized object
  90949. */
  90950. serialize(parent: any): any;
  90951. }
  90952. /**
  90953. * This defines an action helpful to stop a defined sound on a triggered action.
  90954. */
  90955. export class StopSoundAction extends Action {
  90956. private _sound;
  90957. /**
  90958. * Instantiate the action
  90959. * @param triggerOptions defines the trigger options
  90960. * @param sound defines the sound to stop
  90961. * @param condition defines the trigger related conditions
  90962. */
  90963. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  90964. /** @hidden */
  90965. _prepare(): void;
  90966. /**
  90967. * Execute the action and stop the sound.
  90968. */
  90969. execute(): void;
  90970. /**
  90971. * Serializes the actions and its related information.
  90972. * @param parent defines the object to serialize in
  90973. * @returns the serialized object
  90974. */
  90975. serialize(parent: any): any;
  90976. }
  90977. }
  90978. declare module BABYLON {
  90979. /**
  90980. * This defines an action responsible to change the value of a property
  90981. * by interpolating between its current value and the newly set one once triggered.
  90982. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90983. */
  90984. export class InterpolateValueAction extends Action {
  90985. /**
  90986. * Defines the path of the property where the value should be interpolated
  90987. */
  90988. propertyPath: string;
  90989. /**
  90990. * Defines the target value at the end of the interpolation.
  90991. */
  90992. value: any;
  90993. /**
  90994. * Defines the time it will take for the property to interpolate to the value.
  90995. */
  90996. duration: number;
  90997. /**
  90998. * Defines if the other scene animations should be stopped when the action has been triggered
  90999. */
  91000. stopOtherAnimations?: boolean;
  91001. /**
  91002. * Defines a callback raised once the interpolation animation has been done.
  91003. */
  91004. onInterpolationDone?: () => void;
  91005. /**
  91006. * Observable triggered once the interpolation animation has been done.
  91007. */
  91008. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  91009. private _target;
  91010. private _effectiveTarget;
  91011. private _property;
  91012. /**
  91013. * Instantiate the action
  91014. * @param triggerOptions defines the trigger options
  91015. * @param target defines the object containing the value to interpolate
  91016. * @param propertyPath defines the path to the property in the target object
  91017. * @param value defines the target value at the end of the interpolation
  91018. * @param duration deines the time it will take for the property to interpolate to the value.
  91019. * @param condition defines the trigger related conditions
  91020. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  91021. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  91022. */
  91023. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  91024. /** @hidden */
  91025. _prepare(): void;
  91026. /**
  91027. * Execute the action starts the value interpolation.
  91028. */
  91029. execute(): void;
  91030. /**
  91031. * Serializes the actions and its related information.
  91032. * @param parent defines the object to serialize in
  91033. * @returns the serialized object
  91034. */
  91035. serialize(parent: any): any;
  91036. }
  91037. }
  91038. declare module BABYLON {
  91039. /**
  91040. * Options allowed during the creation of a sound track.
  91041. */
  91042. export interface ISoundTrackOptions {
  91043. /**
  91044. * The volume the sound track should take during creation
  91045. */
  91046. volume?: number;
  91047. /**
  91048. * Define if the sound track is the main sound track of the scene
  91049. */
  91050. mainTrack?: boolean;
  91051. }
  91052. /**
  91053. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  91054. * It will be also used in a future release to apply effects on a specific track.
  91055. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  91056. */
  91057. export class SoundTrack {
  91058. /**
  91059. * The unique identifier of the sound track in the scene.
  91060. */
  91061. id: number;
  91062. /**
  91063. * The list of sounds included in the sound track.
  91064. */
  91065. soundCollection: Array<Sound>;
  91066. private _outputAudioNode;
  91067. private _scene;
  91068. private _isMainTrack;
  91069. private _connectedAnalyser;
  91070. private _options;
  91071. private _isInitialized;
  91072. /**
  91073. * Creates a new sound track.
  91074. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  91075. * @param scene Define the scene the sound track belongs to
  91076. * @param options
  91077. */
  91078. constructor(scene: Scene, options?: ISoundTrackOptions);
  91079. private _initializeSoundTrackAudioGraph;
  91080. /**
  91081. * Release the sound track and its associated resources
  91082. */
  91083. dispose(): void;
  91084. /**
  91085. * Adds a sound to this sound track
  91086. * @param sound define the cound to add
  91087. * @ignoreNaming
  91088. */
  91089. AddSound(sound: Sound): void;
  91090. /**
  91091. * Removes a sound to this sound track
  91092. * @param sound define the cound to remove
  91093. * @ignoreNaming
  91094. */
  91095. RemoveSound(sound: Sound): void;
  91096. /**
  91097. * Set a global volume for the full sound track.
  91098. * @param newVolume Define the new volume of the sound track
  91099. */
  91100. setVolume(newVolume: number): void;
  91101. /**
  91102. * Switch the panning model to HRTF:
  91103. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  91104. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  91105. */
  91106. switchPanningModelToHRTF(): void;
  91107. /**
  91108. * Switch the panning model to Equal Power:
  91109. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  91110. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  91111. */
  91112. switchPanningModelToEqualPower(): void;
  91113. /**
  91114. * Connect the sound track to an audio analyser allowing some amazing
  91115. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  91116. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  91117. * @param analyser The analyser to connect to the engine
  91118. */
  91119. connectToAnalyser(analyser: Analyser): void;
  91120. }
  91121. }
  91122. declare module BABYLON {
  91123. interface AbstractScene {
  91124. /**
  91125. * The list of sounds used in the scene.
  91126. */
  91127. sounds: Nullable<Array<Sound>>;
  91128. }
  91129. interface Scene {
  91130. /**
  91131. * @hidden
  91132. * Backing field
  91133. */
  91134. _mainSoundTrack: SoundTrack;
  91135. /**
  91136. * The main sound track played by the scene.
  91137. * It cotains your primary collection of sounds.
  91138. */
  91139. mainSoundTrack: SoundTrack;
  91140. /**
  91141. * The list of sound tracks added to the scene
  91142. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  91143. */
  91144. soundTracks: Nullable<Array<SoundTrack>>;
  91145. /**
  91146. * Gets a sound using a given name
  91147. * @param name defines the name to search for
  91148. * @return the found sound or null if not found at all.
  91149. */
  91150. getSoundByName(name: string): Nullable<Sound>;
  91151. /**
  91152. * Gets or sets if audio support is enabled
  91153. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  91154. */
  91155. audioEnabled: boolean;
  91156. /**
  91157. * Gets or sets if audio will be output to headphones
  91158. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  91159. */
  91160. headphone: boolean;
  91161. }
  91162. /**
  91163. * Defines the sound scene component responsible to manage any sounds
  91164. * in a given scene.
  91165. */
  91166. export class AudioSceneComponent implements ISceneSerializableComponent {
  91167. /**
  91168. * The component name helpfull to identify the component in the list of scene components.
  91169. */
  91170. readonly name: string;
  91171. /**
  91172. * The scene the component belongs to.
  91173. */
  91174. scene: Scene;
  91175. private _audioEnabled;
  91176. /**
  91177. * Gets whether audio is enabled or not.
  91178. * Please use related enable/disable method to switch state.
  91179. */
  91180. readonly audioEnabled: boolean;
  91181. private _headphone;
  91182. /**
  91183. * Gets whether audio is outputing to headphone or not.
  91184. * Please use the according Switch methods to change output.
  91185. */
  91186. readonly headphone: boolean;
  91187. /**
  91188. * Creates a new instance of the component for the given scene
  91189. * @param scene Defines the scene to register the component in
  91190. */
  91191. constructor(scene: Scene);
  91192. /**
  91193. * Registers the component in a given scene
  91194. */
  91195. register(): void;
  91196. /**
  91197. * Rebuilds the elements related to this component in case of
  91198. * context lost for instance.
  91199. */
  91200. rebuild(): void;
  91201. /**
  91202. * Serializes the component data to the specified json object
  91203. * @param serializationObject The object to serialize to
  91204. */
  91205. serialize(serializationObject: any): void;
  91206. /**
  91207. * Adds all the element from the container to the scene
  91208. * @param container the container holding the elements
  91209. */
  91210. addFromContainer(container: AbstractScene): void;
  91211. /**
  91212. * Removes all the elements in the container from the scene
  91213. * @param container contains the elements to remove
  91214. */
  91215. removeFromContainer(container: AbstractScene): void;
  91216. /**
  91217. * Disposes the component and the associated ressources.
  91218. */
  91219. dispose(): void;
  91220. /**
  91221. * Disables audio in the associated scene.
  91222. */
  91223. disableAudio(): void;
  91224. /**
  91225. * Enables audio in the associated scene.
  91226. */
  91227. enableAudio(): void;
  91228. /**
  91229. * Switch audio to headphone output.
  91230. */
  91231. switchAudioModeForHeadphones(): void;
  91232. /**
  91233. * Switch audio to normal speakers.
  91234. */
  91235. switchAudioModeForNormalSpeakers(): void;
  91236. private _afterRender;
  91237. }
  91238. }
  91239. declare module BABYLON {
  91240. /**
  91241. * Wraps one or more Sound objects and selects one with random weight for playback.
  91242. */
  91243. export class WeightedSound {
  91244. /** When true a Sound will be selected and played when the current playing Sound completes. */
  91245. loop: boolean;
  91246. private _coneInnerAngle;
  91247. private _coneOuterAngle;
  91248. private _volume;
  91249. /** A Sound is currently playing. */
  91250. isPlaying: boolean;
  91251. /** A Sound is currently paused. */
  91252. isPaused: boolean;
  91253. private _sounds;
  91254. private _weights;
  91255. private _currentIndex?;
  91256. /**
  91257. * Creates a new WeightedSound from the list of sounds given.
  91258. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  91259. * @param sounds Array of Sounds that will be selected from.
  91260. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  91261. */
  91262. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  91263. /**
  91264. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  91265. */
  91266. /**
  91267. * The size of cone in degress for a directional sound in which there will be no attenuation.
  91268. */
  91269. directionalConeInnerAngle: number;
  91270. /**
  91271. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  91272. * Listener angles between innerAngle and outerAngle will falloff linearly.
  91273. */
  91274. /**
  91275. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  91276. * Listener angles between innerAngle and outerAngle will falloff linearly.
  91277. */
  91278. directionalConeOuterAngle: number;
  91279. /**
  91280. * Playback volume.
  91281. */
  91282. /**
  91283. * Playback volume.
  91284. */
  91285. volume: number;
  91286. private _onended;
  91287. /**
  91288. * Suspend playback
  91289. */
  91290. pause(): void;
  91291. /**
  91292. * Stop playback
  91293. */
  91294. stop(): void;
  91295. /**
  91296. * Start playback.
  91297. * @param startOffset Position the clip head at a specific time in seconds.
  91298. */
  91299. play(startOffset?: number): void;
  91300. }
  91301. }
  91302. declare module BABYLON {
  91303. /**
  91304. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  91305. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  91306. */
  91307. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  91308. /**
  91309. * Gets the name of the behavior.
  91310. */
  91311. readonly name: string;
  91312. /**
  91313. * The easing function used by animations
  91314. */
  91315. static EasingFunction: BackEase;
  91316. /**
  91317. * The easing mode used by animations
  91318. */
  91319. static EasingMode: number;
  91320. /**
  91321. * The duration of the animation, in milliseconds
  91322. */
  91323. transitionDuration: number;
  91324. /**
  91325. * Length of the distance animated by the transition when lower radius is reached
  91326. */
  91327. lowerRadiusTransitionRange: number;
  91328. /**
  91329. * Length of the distance animated by the transition when upper radius is reached
  91330. */
  91331. upperRadiusTransitionRange: number;
  91332. private _autoTransitionRange;
  91333. /**
  91334. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  91335. */
  91336. /**
  91337. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  91338. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  91339. */
  91340. autoTransitionRange: boolean;
  91341. private _attachedCamera;
  91342. private _onAfterCheckInputsObserver;
  91343. private _onMeshTargetChangedObserver;
  91344. /**
  91345. * Initializes the behavior.
  91346. */
  91347. init(): void;
  91348. /**
  91349. * Attaches the behavior to its arc rotate camera.
  91350. * @param camera Defines the camera to attach the behavior to
  91351. */
  91352. attach(camera: ArcRotateCamera): void;
  91353. /**
  91354. * Detaches the behavior from its current arc rotate camera.
  91355. */
  91356. detach(): void;
  91357. private _radiusIsAnimating;
  91358. private _radiusBounceTransition;
  91359. private _animatables;
  91360. private _cachedWheelPrecision;
  91361. /**
  91362. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  91363. * @param radiusLimit The limit to check against.
  91364. * @return Bool to indicate if at limit.
  91365. */
  91366. private _isRadiusAtLimit;
  91367. /**
  91368. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  91369. * @param radiusDelta The delta by which to animate to. Can be negative.
  91370. */
  91371. private _applyBoundRadiusAnimation;
  91372. /**
  91373. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  91374. */
  91375. protected _clearAnimationLocks(): void;
  91376. /**
  91377. * Stops and removes all animations that have been applied to the camera
  91378. */
  91379. stopAllAnimations(): void;
  91380. }
  91381. }
  91382. declare module BABYLON {
  91383. /**
  91384. * 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.
  91385. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  91386. */
  91387. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  91388. /**
  91389. * Gets the name of the behavior.
  91390. */
  91391. readonly name: string;
  91392. private _mode;
  91393. private _radiusScale;
  91394. private _positionScale;
  91395. private _defaultElevation;
  91396. private _elevationReturnTime;
  91397. private _elevationReturnWaitTime;
  91398. private _zoomStopsAnimation;
  91399. private _framingTime;
  91400. /**
  91401. * The easing function used by animations
  91402. */
  91403. static EasingFunction: ExponentialEase;
  91404. /**
  91405. * The easing mode used by animations
  91406. */
  91407. static EasingMode: number;
  91408. /**
  91409. * Sets the current mode used by the behavior
  91410. */
  91411. /**
  91412. * Gets current mode used by the behavior.
  91413. */
  91414. mode: number;
  91415. /**
  91416. * Sets the scale applied to the radius (1 by default)
  91417. */
  91418. /**
  91419. * Gets the scale applied to the radius
  91420. */
  91421. radiusScale: number;
  91422. /**
  91423. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  91424. */
  91425. /**
  91426. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  91427. */
  91428. positionScale: number;
  91429. /**
  91430. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  91431. * behaviour is triggered, in radians.
  91432. */
  91433. /**
  91434. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  91435. * behaviour is triggered, in radians.
  91436. */
  91437. defaultElevation: number;
  91438. /**
  91439. * Sets the time (in milliseconds) taken to return to the default beta position.
  91440. * Negative value indicates camera should not return to default.
  91441. */
  91442. /**
  91443. * Gets the time (in milliseconds) taken to return to the default beta position.
  91444. * Negative value indicates camera should not return to default.
  91445. */
  91446. elevationReturnTime: number;
  91447. /**
  91448. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  91449. */
  91450. /**
  91451. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  91452. */
  91453. elevationReturnWaitTime: number;
  91454. /**
  91455. * Sets the flag that indicates if user zooming should stop animation.
  91456. */
  91457. /**
  91458. * Gets the flag that indicates if user zooming should stop animation.
  91459. */
  91460. zoomStopsAnimation: boolean;
  91461. /**
  91462. * Sets the transition time when framing the mesh, in milliseconds
  91463. */
  91464. /**
  91465. * Gets the transition time when framing the mesh, in milliseconds
  91466. */
  91467. framingTime: number;
  91468. /**
  91469. * Define if the behavior should automatically change the configured
  91470. * camera limits and sensibilities.
  91471. */
  91472. autoCorrectCameraLimitsAndSensibility: boolean;
  91473. private _onPrePointerObservableObserver;
  91474. private _onAfterCheckInputsObserver;
  91475. private _onMeshTargetChangedObserver;
  91476. private _attachedCamera;
  91477. private _isPointerDown;
  91478. private _lastInteractionTime;
  91479. /**
  91480. * Initializes the behavior.
  91481. */
  91482. init(): void;
  91483. /**
  91484. * Attaches the behavior to its arc rotate camera.
  91485. * @param camera Defines the camera to attach the behavior to
  91486. */
  91487. attach(camera: ArcRotateCamera): void;
  91488. /**
  91489. * Detaches the behavior from its current arc rotate camera.
  91490. */
  91491. detach(): void;
  91492. private _animatables;
  91493. private _betaIsAnimating;
  91494. private _betaTransition;
  91495. private _radiusTransition;
  91496. private _vectorTransition;
  91497. /**
  91498. * Targets the given mesh and updates zoom level accordingly.
  91499. * @param mesh The mesh to target.
  91500. * @param radius Optional. If a cached radius position already exists, overrides default.
  91501. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  91502. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  91503. * @param onAnimationEnd Callback triggered at the end of the framing animation
  91504. */
  91505. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  91506. /**
  91507. * Targets the given mesh with its children and updates zoom level accordingly.
  91508. * @param mesh The mesh to target.
  91509. * @param radius Optional. If a cached radius position already exists, overrides default.
  91510. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  91511. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  91512. * @param onAnimationEnd Callback triggered at the end of the framing animation
  91513. */
  91514. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  91515. /**
  91516. * Targets the given meshes with their children and updates zoom level accordingly.
  91517. * @param meshes The mesh to target.
  91518. * @param radius Optional. If a cached radius position already exists, overrides default.
  91519. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  91520. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  91521. * @param onAnimationEnd Callback triggered at the end of the framing animation
  91522. */
  91523. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  91524. /**
  91525. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  91526. * @param minimumWorld Determines the smaller position of the bounding box extend
  91527. * @param maximumWorld Determines the bigger position of the bounding box extend
  91528. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  91529. * @param onAnimationEnd Callback triggered at the end of the framing animation
  91530. */
  91531. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  91532. /**
  91533. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  91534. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  91535. * frustum width.
  91536. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  91537. * to fully enclose the mesh in the viewing frustum.
  91538. */
  91539. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  91540. /**
  91541. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  91542. * is automatically returned to its default position (expected to be above ground plane).
  91543. */
  91544. private _maintainCameraAboveGround;
  91545. /**
  91546. * Returns the frustum slope based on the canvas ratio and camera FOV
  91547. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  91548. */
  91549. private _getFrustumSlope;
  91550. /**
  91551. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  91552. */
  91553. private _clearAnimationLocks;
  91554. /**
  91555. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  91556. */
  91557. private _applyUserInteraction;
  91558. /**
  91559. * Stops and removes all animations that have been applied to the camera
  91560. */
  91561. stopAllAnimations(): void;
  91562. /**
  91563. * Gets a value indicating if the user is moving the camera
  91564. */
  91565. readonly isUserIsMoving: boolean;
  91566. /**
  91567. * The camera can move all the way towards the mesh.
  91568. */
  91569. static IgnoreBoundsSizeMode: number;
  91570. /**
  91571. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  91572. */
  91573. static FitFrustumSidesMode: number;
  91574. }
  91575. }
  91576. declare module BABYLON {
  91577. /**
  91578. * Base class for Camera Pointer Inputs.
  91579. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  91580. * for example usage.
  91581. */
  91582. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  91583. /**
  91584. * Defines the camera the input is attached to.
  91585. */
  91586. abstract camera: Camera;
  91587. /**
  91588. * Whether keyboard modifier keys are pressed at time of last mouse event.
  91589. */
  91590. protected _altKey: boolean;
  91591. protected _ctrlKey: boolean;
  91592. protected _metaKey: boolean;
  91593. protected _shiftKey: boolean;
  91594. /**
  91595. * Which mouse buttons were pressed at time of last mouse event.
  91596. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  91597. */
  91598. protected _buttonsPressed: number;
  91599. /**
  91600. * Defines the buttons associated with the input to handle camera move.
  91601. */
  91602. buttons: number[];
  91603. /**
  91604. * Attach the input controls to a specific dom element to get the input from.
  91605. * @param element Defines the element the controls should be listened from
  91606. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  91607. */
  91608. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  91609. /**
  91610. * Detach the current controls from the specified dom element.
  91611. * @param element Defines the element to stop listening the inputs from
  91612. */
  91613. detachControl(element: Nullable<HTMLElement>): void;
  91614. /**
  91615. * Gets the class name of the current input.
  91616. * @returns the class name
  91617. */
  91618. getClassName(): string;
  91619. /**
  91620. * Get the friendly name associated with the input class.
  91621. * @returns the input friendly name
  91622. */
  91623. getSimpleName(): string;
  91624. /**
  91625. * Called on pointer POINTERDOUBLETAP event.
  91626. * Override this method to provide functionality on POINTERDOUBLETAP event.
  91627. */
  91628. protected onDoubleTap(type: string): void;
  91629. /**
  91630. * Called on pointer POINTERMOVE event if only a single touch is active.
  91631. * Override this method to provide functionality.
  91632. */
  91633. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  91634. /**
  91635. * Called on pointer POINTERMOVE event if multiple touches are active.
  91636. * Override this method to provide functionality.
  91637. */
  91638. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  91639. /**
  91640. * Called on JS contextmenu event.
  91641. * Override this method to provide functionality.
  91642. */
  91643. protected onContextMenu(evt: PointerEvent): void;
  91644. /**
  91645. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  91646. * press.
  91647. * Override this method to provide functionality.
  91648. */
  91649. protected onButtonDown(evt: PointerEvent, buttonCount: number): void;
  91650. /**
  91651. * Called each time a new POINTERUP event occurs. Ie, for each button
  91652. * release.
  91653. * Override this method to provide functionality.
  91654. */
  91655. protected onButtonUp(evt: PointerEvent): void;
  91656. /**
  91657. * Called when window becomes inactive.
  91658. * Override this method to provide functionality.
  91659. */
  91660. protected onLostFocus(): void;
  91661. private _pointerInput;
  91662. private _observer;
  91663. private _onLostFocus;
  91664. }
  91665. }
  91666. declare module BABYLON {
  91667. /**
  91668. * Manage the pointers inputs to control an arc rotate camera.
  91669. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91670. */
  91671. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  91672. /**
  91673. * Defines the camera the input is attached to.
  91674. */
  91675. camera: ArcRotateCamera;
  91676. /**
  91677. * Gets the class name of the current input.
  91678. * @returns the class name
  91679. */
  91680. getClassName(): string;
  91681. /**
  91682. * Defines the buttons associated with the input to handle camera move.
  91683. */
  91684. buttons: number[];
  91685. /**
  91686. * Defines the pointer angular sensibility along the X axis or how fast is
  91687. * the camera rotating.
  91688. */
  91689. angularSensibilityX: number;
  91690. /**
  91691. * Defines the pointer angular sensibility along the Y axis or how fast is
  91692. * the camera rotating.
  91693. */
  91694. angularSensibilityY: number;
  91695. /**
  91696. * Defines the pointer pinch precision or how fast is the camera zooming.
  91697. */
  91698. pinchPrecision: number;
  91699. /**
  91700. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  91701. * from 0.
  91702. * It defines the percentage of current camera.radius to use as delta when
  91703. * pinch zoom is used.
  91704. */
  91705. pinchDeltaPercentage: number;
  91706. /**
  91707. * Defines the pointer panning sensibility or how fast is the camera moving.
  91708. */
  91709. panningSensibility: number;
  91710. /**
  91711. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  91712. */
  91713. multiTouchPanning: boolean;
  91714. /**
  91715. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  91716. * zoom (pinch) through multitouch.
  91717. */
  91718. multiTouchPanAndZoom: boolean;
  91719. /**
  91720. * Revers pinch action direction.
  91721. */
  91722. pinchInwards: boolean;
  91723. private _isPanClick;
  91724. private _twoFingerActivityCount;
  91725. private _isPinching;
  91726. /**
  91727. * Called on pointer POINTERMOVE event if only a single touch is active.
  91728. */
  91729. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  91730. /**
  91731. * Called on pointer POINTERDOUBLETAP event.
  91732. */
  91733. protected onDoubleTap(type: string): void;
  91734. /**
  91735. * Called on pointer POINTERMOVE event if multiple touches are active.
  91736. */
  91737. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  91738. /**
  91739. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  91740. * press.
  91741. */
  91742. protected onButtonDown(evt: PointerEvent, buttonCount: number): void;
  91743. /**
  91744. * Called each time a new POINTERUP event occurs. Ie, for each button
  91745. * release.
  91746. */
  91747. protected onButtonUp(evt: PointerEvent): void;
  91748. /**
  91749. * Called when window becomes inactive.
  91750. */
  91751. protected onLostFocus(): void;
  91752. }
  91753. }
  91754. declare module BABYLON {
  91755. /**
  91756. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  91757. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91758. */
  91759. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  91760. /**
  91761. * Defines the camera the input is attached to.
  91762. */
  91763. camera: ArcRotateCamera;
  91764. /**
  91765. * Defines the list of key codes associated with the up action (increase alpha)
  91766. */
  91767. keysUp: number[];
  91768. /**
  91769. * Defines the list of key codes associated with the down action (decrease alpha)
  91770. */
  91771. keysDown: number[];
  91772. /**
  91773. * Defines the list of key codes associated with the left action (increase beta)
  91774. */
  91775. keysLeft: number[];
  91776. /**
  91777. * Defines the list of key codes associated with the right action (decrease beta)
  91778. */
  91779. keysRight: number[];
  91780. /**
  91781. * Defines the list of key codes associated with the reset action.
  91782. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  91783. */
  91784. keysReset: number[];
  91785. /**
  91786. * Defines the panning sensibility of the inputs.
  91787. * (How fast is the camera paning)
  91788. */
  91789. panningSensibility: number;
  91790. /**
  91791. * Defines the zooming sensibility of the inputs.
  91792. * (How fast is the camera zooming)
  91793. */
  91794. zoomingSensibility: number;
  91795. /**
  91796. * Defines wether maintaining the alt key down switch the movement mode from
  91797. * orientation to zoom.
  91798. */
  91799. useAltToZoom: boolean;
  91800. /**
  91801. * Rotation speed of the camera
  91802. */
  91803. angularSpeed: number;
  91804. private _keys;
  91805. private _ctrlPressed;
  91806. private _altPressed;
  91807. private _onCanvasBlurObserver;
  91808. private _onKeyboardObserver;
  91809. private _engine;
  91810. private _scene;
  91811. /**
  91812. * Attach the input controls to a specific dom element to get the input from.
  91813. * @param element Defines the element the controls should be listened from
  91814. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  91815. */
  91816. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  91817. /**
  91818. * Detach the current controls from the specified dom element.
  91819. * @param element Defines the element to stop listening the inputs from
  91820. */
  91821. detachControl(element: Nullable<HTMLElement>): void;
  91822. /**
  91823. * Update the current camera state depending on the inputs that have been used this frame.
  91824. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  91825. */
  91826. checkInputs(): void;
  91827. /**
  91828. * Gets the class name of the current intput.
  91829. * @returns the class name
  91830. */
  91831. getClassName(): string;
  91832. /**
  91833. * Get the friendly name associated with the input class.
  91834. * @returns the input friendly name
  91835. */
  91836. getSimpleName(): string;
  91837. }
  91838. }
  91839. declare module BABYLON {
  91840. /**
  91841. * Manage the mouse wheel inputs to control an arc rotate camera.
  91842. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91843. */
  91844. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  91845. /**
  91846. * Defines the camera the input is attached to.
  91847. */
  91848. camera: ArcRotateCamera;
  91849. /**
  91850. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  91851. */
  91852. wheelPrecision: number;
  91853. /**
  91854. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  91855. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  91856. */
  91857. wheelDeltaPercentage: number;
  91858. private _wheel;
  91859. private _observer;
  91860. /**
  91861. * Attach the input controls to a specific dom element to get the input from.
  91862. * @param element Defines the element the controls should be listened from
  91863. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  91864. */
  91865. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  91866. /**
  91867. * Detach the current controls from the specified dom element.
  91868. * @param element Defines the element to stop listening the inputs from
  91869. */
  91870. detachControl(element: Nullable<HTMLElement>): void;
  91871. /**
  91872. * Gets the class name of the current intput.
  91873. * @returns the class name
  91874. */
  91875. getClassName(): string;
  91876. /**
  91877. * Get the friendly name associated with the input class.
  91878. * @returns the input friendly name
  91879. */
  91880. getSimpleName(): string;
  91881. }
  91882. }
  91883. declare module BABYLON {
  91884. /**
  91885. * Default Inputs manager for the ArcRotateCamera.
  91886. * It groups all the default supported inputs for ease of use.
  91887. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91888. */
  91889. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  91890. /**
  91891. * Instantiates a new ArcRotateCameraInputsManager.
  91892. * @param camera Defines the camera the inputs belong to
  91893. */
  91894. constructor(camera: ArcRotateCamera);
  91895. /**
  91896. * Add mouse wheel input support to the input manager.
  91897. * @returns the current input manager
  91898. */
  91899. addMouseWheel(): ArcRotateCameraInputsManager;
  91900. /**
  91901. * Add pointers input support to the input manager.
  91902. * @returns the current input manager
  91903. */
  91904. addPointers(): ArcRotateCameraInputsManager;
  91905. /**
  91906. * Add keyboard input support to the input manager.
  91907. * @returns the current input manager
  91908. */
  91909. addKeyboard(): ArcRotateCameraInputsManager;
  91910. }
  91911. }
  91912. declare module BABYLON {
  91913. /**
  91914. * This represents an orbital type of camera.
  91915. *
  91916. * 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.
  91917. * 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.
  91918. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  91919. */
  91920. export class ArcRotateCamera extends TargetCamera {
  91921. /**
  91922. * Defines the rotation angle of the camera along the longitudinal axis.
  91923. */
  91924. alpha: number;
  91925. /**
  91926. * Defines the rotation angle of the camera along the latitudinal axis.
  91927. */
  91928. beta: number;
  91929. /**
  91930. * Defines the radius of the camera from it s target point.
  91931. */
  91932. radius: number;
  91933. protected _target: Vector3;
  91934. protected _targetHost: Nullable<AbstractMesh>;
  91935. /**
  91936. * Defines the target point of the camera.
  91937. * The camera looks towards it form the radius distance.
  91938. */
  91939. target: Vector3;
  91940. /**
  91941. * Define the current local position of the camera in the scene
  91942. */
  91943. position: Vector3;
  91944. /**
  91945. * Current inertia value on the longitudinal axis.
  91946. * The bigger this number the longer it will take for the camera to stop.
  91947. */
  91948. inertialAlphaOffset: number;
  91949. /**
  91950. * Current inertia value on the latitudinal axis.
  91951. * The bigger this number the longer it will take for the camera to stop.
  91952. */
  91953. inertialBetaOffset: number;
  91954. /**
  91955. * Current inertia value on the radius axis.
  91956. * The bigger this number the longer it will take for the camera to stop.
  91957. */
  91958. inertialRadiusOffset: number;
  91959. /**
  91960. * Minimum allowed angle on the longitudinal axis.
  91961. * This can help limiting how the Camera is able to move in the scene.
  91962. */
  91963. lowerAlphaLimit: Nullable<number>;
  91964. /**
  91965. * Maximum allowed angle on the longitudinal axis.
  91966. * This can help limiting how the Camera is able to move in the scene.
  91967. */
  91968. upperAlphaLimit: Nullable<number>;
  91969. /**
  91970. * Minimum allowed angle on the latitudinal axis.
  91971. * This can help limiting how the Camera is able to move in the scene.
  91972. */
  91973. lowerBetaLimit: number;
  91974. /**
  91975. * Maximum allowed angle on the latitudinal axis.
  91976. * This can help limiting how the Camera is able to move in the scene.
  91977. */
  91978. upperBetaLimit: number;
  91979. /**
  91980. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  91981. * This can help limiting how the Camera is able to move in the scene.
  91982. */
  91983. lowerRadiusLimit: Nullable<number>;
  91984. /**
  91985. * Maximum allowed distance of the camera to the target (The camera can not get further).
  91986. * This can help limiting how the Camera is able to move in the scene.
  91987. */
  91988. upperRadiusLimit: Nullable<number>;
  91989. /**
  91990. * Defines the current inertia value used during panning of the camera along the X axis.
  91991. */
  91992. inertialPanningX: number;
  91993. /**
  91994. * Defines the current inertia value used during panning of the camera along the Y axis.
  91995. */
  91996. inertialPanningY: number;
  91997. /**
  91998. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  91999. * Basically if your fingers moves away from more than this distance you will be considered
  92000. * in pinch mode.
  92001. */
  92002. pinchToPanMaxDistance: number;
  92003. /**
  92004. * Defines the maximum distance the camera can pan.
  92005. * This could help keeping the cammera always in your scene.
  92006. */
  92007. panningDistanceLimit: Nullable<number>;
  92008. /**
  92009. * Defines the target of the camera before paning.
  92010. */
  92011. panningOriginTarget: Vector3;
  92012. /**
  92013. * Defines the value of the inertia used during panning.
  92014. * 0 would mean stop inertia and one would mean no decelleration at all.
  92015. */
  92016. panningInertia: number;
  92017. /**
  92018. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  92019. */
  92020. angularSensibilityX: number;
  92021. /**
  92022. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  92023. */
  92024. angularSensibilityY: number;
  92025. /**
  92026. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  92027. */
  92028. pinchPrecision: number;
  92029. /**
  92030. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  92031. * It will be used instead of pinchDeltaPrecision if different from 0.
  92032. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  92033. */
  92034. pinchDeltaPercentage: number;
  92035. /**
  92036. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  92037. */
  92038. panningSensibility: number;
  92039. /**
  92040. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  92041. */
  92042. keysUp: number[];
  92043. /**
  92044. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  92045. */
  92046. keysDown: number[];
  92047. /**
  92048. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  92049. */
  92050. keysLeft: number[];
  92051. /**
  92052. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  92053. */
  92054. keysRight: number[];
  92055. /**
  92056. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  92057. */
  92058. wheelPrecision: number;
  92059. /**
  92060. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  92061. * It will be used instead of pinchDeltaPrecision if different from 0.
  92062. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  92063. */
  92064. wheelDeltaPercentage: number;
  92065. /**
  92066. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  92067. */
  92068. zoomOnFactor: number;
  92069. /**
  92070. * Defines a screen offset for the camera position.
  92071. */
  92072. targetScreenOffset: Vector2;
  92073. /**
  92074. * Allows the camera to be completely reversed.
  92075. * If false the camera can not arrive upside down.
  92076. */
  92077. allowUpsideDown: boolean;
  92078. /**
  92079. * Define if double tap/click is used to restore the previously saved state of the camera.
  92080. */
  92081. useInputToRestoreState: boolean;
  92082. /** @hidden */
  92083. _viewMatrix: Matrix;
  92084. /** @hidden */
  92085. _useCtrlForPanning: boolean;
  92086. /** @hidden */
  92087. _panningMouseButton: number;
  92088. /**
  92089. * Defines the input associated to the camera.
  92090. */
  92091. inputs: ArcRotateCameraInputsManager;
  92092. /** @hidden */
  92093. _reset: () => void;
  92094. /**
  92095. * Defines the allowed panning axis.
  92096. */
  92097. panningAxis: Vector3;
  92098. protected _localDirection: Vector3;
  92099. protected _transformedDirection: Vector3;
  92100. private _bouncingBehavior;
  92101. /**
  92102. * Gets the bouncing behavior of the camera if it has been enabled.
  92103. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  92104. */
  92105. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  92106. /**
  92107. * Defines if the bouncing behavior of the camera is enabled on the camera.
  92108. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  92109. */
  92110. useBouncingBehavior: boolean;
  92111. private _framingBehavior;
  92112. /**
  92113. * Gets the framing behavior of the camera if it has been enabled.
  92114. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  92115. */
  92116. readonly framingBehavior: Nullable<FramingBehavior>;
  92117. /**
  92118. * Defines if the framing behavior of the camera is enabled on the camera.
  92119. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  92120. */
  92121. useFramingBehavior: boolean;
  92122. private _autoRotationBehavior;
  92123. /**
  92124. * Gets the auto rotation behavior of the camera if it has been enabled.
  92125. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  92126. */
  92127. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  92128. /**
  92129. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  92130. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  92131. */
  92132. useAutoRotationBehavior: boolean;
  92133. /**
  92134. * Observable triggered when the mesh target has been changed on the camera.
  92135. */
  92136. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  92137. /**
  92138. * Event raised when the camera is colliding with a mesh.
  92139. */
  92140. onCollide: (collidedMesh: AbstractMesh) => void;
  92141. /**
  92142. * Defines whether the camera should check collision with the objects oh the scene.
  92143. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  92144. */
  92145. checkCollisions: boolean;
  92146. /**
  92147. * Defines the collision radius of the camera.
  92148. * This simulates a sphere around the camera.
  92149. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  92150. */
  92151. collisionRadius: Vector3;
  92152. protected _collider: Collider;
  92153. protected _previousPosition: Vector3;
  92154. protected _collisionVelocity: Vector3;
  92155. protected _newPosition: Vector3;
  92156. protected _previousAlpha: number;
  92157. protected _previousBeta: number;
  92158. protected _previousRadius: number;
  92159. protected _collisionTriggered: boolean;
  92160. protected _targetBoundingCenter: Nullable<Vector3>;
  92161. private _computationVector;
  92162. private _tempAxisVector;
  92163. private _tempAxisRotationMatrix;
  92164. /**
  92165. * Instantiates a new ArcRotateCamera in a given scene
  92166. * @param name Defines the name of the camera
  92167. * @param alpha Defines the camera rotation along the logitudinal axis
  92168. * @param beta Defines the camera rotation along the latitudinal axis
  92169. * @param radius Defines the camera distance from its target
  92170. * @param target Defines the camera target
  92171. * @param scene Defines the scene the camera belongs to
  92172. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  92173. */
  92174. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  92175. /** @hidden */
  92176. _initCache(): void;
  92177. /** @hidden */
  92178. _updateCache(ignoreParentClass?: boolean): void;
  92179. protected _getTargetPosition(): Vector3;
  92180. private _storedAlpha;
  92181. private _storedBeta;
  92182. private _storedRadius;
  92183. private _storedTarget;
  92184. /**
  92185. * Stores the current state of the camera (alpha, beta, radius and target)
  92186. * @returns the camera itself
  92187. */
  92188. storeState(): Camera;
  92189. /**
  92190. * @hidden
  92191. * Restored camera state. You must call storeState() first
  92192. */
  92193. _restoreStateValues(): boolean;
  92194. /** @hidden */
  92195. _isSynchronizedViewMatrix(): boolean;
  92196. /**
  92197. * Attached controls to the current camera.
  92198. * @param element Defines the element the controls should be listened from
  92199. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  92200. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  92201. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  92202. */
  92203. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  92204. /**
  92205. * Detach the current controls from the camera.
  92206. * The camera will stop reacting to inputs.
  92207. * @param element Defines the element to stop listening the inputs from
  92208. */
  92209. detachControl(element: HTMLElement): void;
  92210. /** @hidden */
  92211. _checkInputs(): void;
  92212. protected _checkLimits(): void;
  92213. /**
  92214. * Rebuilds angles (alpha, beta) and radius from the give position and target
  92215. * @param updateView defines a boolean forcing the camera to update its position with a view matrix computation first (default is true)
  92216. */
  92217. rebuildAnglesAndRadius(updateView?: boolean): void;
  92218. /**
  92219. * Use a position to define the current camera related information like aplha, beta and radius
  92220. * @param position Defines the position to set the camera at
  92221. */
  92222. setPosition(position: Vector3): void;
  92223. /**
  92224. * Defines the target the camera should look at.
  92225. * This will automatically adapt alpha beta and radius to fit within the new target.
  92226. * @param target Defines the new target as a Vector or a mesh
  92227. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  92228. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  92229. */
  92230. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  92231. /** @hidden */
  92232. _getViewMatrix(): Matrix;
  92233. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  92234. /**
  92235. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  92236. * @param meshes Defines the mesh to zoom on
  92237. * @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)
  92238. */
  92239. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  92240. /**
  92241. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  92242. * The target will be changed but the radius
  92243. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  92244. * @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)
  92245. */
  92246. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  92247. min: Vector3;
  92248. max: Vector3;
  92249. distance: number;
  92250. }, doNotUpdateMaxZ?: boolean): void;
  92251. /**
  92252. * @override
  92253. * Override Camera.createRigCamera
  92254. */
  92255. createRigCamera(name: string, cameraIndex: number): Camera;
  92256. /**
  92257. * @hidden
  92258. * @override
  92259. * Override Camera._updateRigCameras
  92260. */
  92261. _updateRigCameras(): void;
  92262. /**
  92263. * Destroy the camera and release the current resources hold by it.
  92264. */
  92265. dispose(): void;
  92266. /**
  92267. * Gets the current object class name.
  92268. * @return the class name
  92269. */
  92270. getClassName(): string;
  92271. }
  92272. }
  92273. declare module BABYLON {
  92274. /**
  92275. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  92276. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  92277. */
  92278. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  92279. /**
  92280. * Gets the name of the behavior.
  92281. */
  92282. readonly name: string;
  92283. private _zoomStopsAnimation;
  92284. private _idleRotationSpeed;
  92285. private _idleRotationWaitTime;
  92286. private _idleRotationSpinupTime;
  92287. /**
  92288. * Sets the flag that indicates if user zooming should stop animation.
  92289. */
  92290. /**
  92291. * Gets the flag that indicates if user zooming should stop animation.
  92292. */
  92293. zoomStopsAnimation: boolean;
  92294. /**
  92295. * Sets the default speed at which the camera rotates around the model.
  92296. */
  92297. /**
  92298. * Gets the default speed at which the camera rotates around the model.
  92299. */
  92300. idleRotationSpeed: number;
  92301. /**
  92302. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  92303. */
  92304. /**
  92305. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  92306. */
  92307. idleRotationWaitTime: number;
  92308. /**
  92309. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  92310. */
  92311. /**
  92312. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  92313. */
  92314. idleRotationSpinupTime: number;
  92315. /**
  92316. * Gets a value indicating if the camera is currently rotating because of this behavior
  92317. */
  92318. readonly rotationInProgress: boolean;
  92319. private _onPrePointerObservableObserver;
  92320. private _onAfterCheckInputsObserver;
  92321. private _attachedCamera;
  92322. private _isPointerDown;
  92323. private _lastFrameTime;
  92324. private _lastInteractionTime;
  92325. private _cameraRotationSpeed;
  92326. /**
  92327. * Initializes the behavior.
  92328. */
  92329. init(): void;
  92330. /**
  92331. * Attaches the behavior to its arc rotate camera.
  92332. * @param camera Defines the camera to attach the behavior to
  92333. */
  92334. attach(camera: ArcRotateCamera): void;
  92335. /**
  92336. * Detaches the behavior from its current arc rotate camera.
  92337. */
  92338. detach(): void;
  92339. /**
  92340. * Returns true if user is scrolling.
  92341. * @return true if user is scrolling.
  92342. */
  92343. private _userIsZooming;
  92344. private _lastFrameRadius;
  92345. private _shouldAnimationStopForInteraction;
  92346. /**
  92347. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  92348. */
  92349. private _applyUserInteraction;
  92350. private _userIsMoving;
  92351. }
  92352. }
  92353. declare module BABYLON {
  92354. /**
  92355. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  92356. */
  92357. export class AttachToBoxBehavior implements Behavior<Mesh> {
  92358. private ui;
  92359. /**
  92360. * The name of the behavior
  92361. */
  92362. name: string;
  92363. /**
  92364. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  92365. */
  92366. distanceAwayFromFace: number;
  92367. /**
  92368. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  92369. */
  92370. distanceAwayFromBottomOfFace: number;
  92371. private _faceVectors;
  92372. private _target;
  92373. private _scene;
  92374. private _onRenderObserver;
  92375. private _tmpMatrix;
  92376. private _tmpVector;
  92377. /**
  92378. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  92379. * @param ui The transform node that should be attched to the mesh
  92380. */
  92381. constructor(ui: TransformNode);
  92382. /**
  92383. * Initializes the behavior
  92384. */
  92385. init(): void;
  92386. private _closestFace;
  92387. private _zeroVector;
  92388. private _lookAtTmpMatrix;
  92389. private _lookAtToRef;
  92390. /**
  92391. * Attaches the AttachToBoxBehavior to the passed in mesh
  92392. * @param target The mesh that the specified node will be attached to
  92393. */
  92394. attach(target: Mesh): void;
  92395. /**
  92396. * Detaches the behavior from the mesh
  92397. */
  92398. detach(): void;
  92399. }
  92400. }
  92401. declare module BABYLON {
  92402. /**
  92403. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  92404. */
  92405. export class FadeInOutBehavior implements Behavior<Mesh> {
  92406. /**
  92407. * Time in milliseconds to delay before fading in (Default: 0)
  92408. */
  92409. delay: number;
  92410. /**
  92411. * Time in milliseconds for the mesh to fade in (Default: 300)
  92412. */
  92413. fadeInTime: number;
  92414. private _millisecondsPerFrame;
  92415. private _hovered;
  92416. private _hoverValue;
  92417. private _ownerNode;
  92418. /**
  92419. * Instatiates the FadeInOutBehavior
  92420. */
  92421. constructor();
  92422. /**
  92423. * The name of the behavior
  92424. */
  92425. readonly name: string;
  92426. /**
  92427. * Initializes the behavior
  92428. */
  92429. init(): void;
  92430. /**
  92431. * Attaches the fade behavior on the passed in mesh
  92432. * @param ownerNode The mesh that will be faded in/out once attached
  92433. */
  92434. attach(ownerNode: Mesh): void;
  92435. /**
  92436. * Detaches the behavior from the mesh
  92437. */
  92438. detach(): void;
  92439. /**
  92440. * Triggers the mesh to begin fading in or out
  92441. * @param value if the object should fade in or out (true to fade in)
  92442. */
  92443. fadeIn(value: boolean): void;
  92444. private _update;
  92445. private _setAllVisibility;
  92446. }
  92447. }
  92448. declare module BABYLON {
  92449. /**
  92450. * Class containing a set of static utilities functions for managing Pivots
  92451. * @hidden
  92452. */
  92453. export class PivotTools {
  92454. private static _PivotCached;
  92455. private static _OldPivotPoint;
  92456. private static _PivotTranslation;
  92457. private static _PivotTmpVector;
  92458. /** @hidden */
  92459. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  92460. /** @hidden */
  92461. static _RestorePivotPoint(mesh: AbstractMesh): void;
  92462. }
  92463. }
  92464. declare module BABYLON {
  92465. /**
  92466. * Class containing static functions to help procedurally build meshes
  92467. */
  92468. export class PlaneBuilder {
  92469. /**
  92470. * Creates a plane mesh
  92471. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  92472. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  92473. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  92474. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  92475. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  92476. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  92477. * @param name defines the name of the mesh
  92478. * @param options defines the options used to create the mesh
  92479. * @param scene defines the hosting scene
  92480. * @returns the plane mesh
  92481. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  92482. */
  92483. static CreatePlane(name: string, options: {
  92484. size?: number;
  92485. width?: number;
  92486. height?: number;
  92487. sideOrientation?: number;
  92488. frontUVs?: Vector4;
  92489. backUVs?: Vector4;
  92490. updatable?: boolean;
  92491. sourcePlane?: Plane;
  92492. }, scene: Scene): Mesh;
  92493. }
  92494. }
  92495. declare module BABYLON {
  92496. /**
  92497. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  92498. */
  92499. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  92500. private static _AnyMouseID;
  92501. private _attachedNode;
  92502. private _dragPlane;
  92503. private _scene;
  92504. private _pointerObserver;
  92505. private _beforeRenderObserver;
  92506. private static _planeScene;
  92507. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  92508. /**
  92509. * 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)
  92510. */
  92511. maxDragAngle: number;
  92512. /**
  92513. * @hidden
  92514. */
  92515. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  92516. /**
  92517. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  92518. */
  92519. currentDraggingPointerID: number;
  92520. /**
  92521. * The last position where the pointer hit the drag plane in world space
  92522. */
  92523. lastDragPosition: Vector3;
  92524. /**
  92525. * If the behavior is currently in a dragging state
  92526. */
  92527. dragging: boolean;
  92528. /**
  92529. * 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)
  92530. */
  92531. dragDeltaRatio: number;
  92532. /**
  92533. * If the drag plane orientation should be updated during the dragging (Default: true)
  92534. */
  92535. updateDragPlane: boolean;
  92536. private _debugMode;
  92537. private _moving;
  92538. /**
  92539. * Fires each time the attached mesh is dragged with the pointer
  92540. * * delta between last drag position and current drag position in world space
  92541. * * dragDistance along the drag axis
  92542. * * dragPlaneNormal normal of the current drag plane used during the drag
  92543. * * dragPlanePoint in world space where the drag intersects the drag plane
  92544. */
  92545. onDragObservable: Observable<{
  92546. delta: Vector3;
  92547. dragPlanePoint: Vector3;
  92548. dragPlaneNormal: Vector3;
  92549. dragDistance: number;
  92550. pointerId: number;
  92551. }>;
  92552. /**
  92553. * Fires each time a drag begins (eg. mouse down on mesh)
  92554. */
  92555. onDragStartObservable: Observable<{
  92556. dragPlanePoint: Vector3;
  92557. pointerId: number;
  92558. }>;
  92559. /**
  92560. * Fires each time a drag ends (eg. mouse release after drag)
  92561. */
  92562. onDragEndObservable: Observable<{
  92563. dragPlanePoint: Vector3;
  92564. pointerId: number;
  92565. }>;
  92566. /**
  92567. * If the attached mesh should be moved when dragged
  92568. */
  92569. moveAttached: boolean;
  92570. /**
  92571. * If the drag behavior will react to drag events (Default: true)
  92572. */
  92573. enabled: boolean;
  92574. /**
  92575. * If camera controls should be detached during the drag
  92576. */
  92577. detachCameraControls: boolean;
  92578. /**
  92579. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  92580. */
  92581. useObjectOrienationForDragging: boolean;
  92582. private _options;
  92583. /**
  92584. * Creates a pointer drag behavior that can be attached to a mesh
  92585. * @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)
  92586. */
  92587. constructor(options?: {
  92588. dragAxis?: Vector3;
  92589. dragPlaneNormal?: Vector3;
  92590. });
  92591. /**
  92592. * Predicate to determine if it is valid to move the object to a new position when it is moved
  92593. */
  92594. validateDrag: (targetPosition: Vector3) => boolean;
  92595. /**
  92596. * The name of the behavior
  92597. */
  92598. readonly name: string;
  92599. /**
  92600. * Initializes the behavior
  92601. */
  92602. init(): void;
  92603. private _tmpVector;
  92604. private _alternatePickedPoint;
  92605. private _worldDragAxis;
  92606. private _targetPosition;
  92607. private _attachedElement;
  92608. /**
  92609. * Attaches the drag behavior the passed in mesh
  92610. * @param ownerNode The mesh that will be dragged around once attached
  92611. */
  92612. attach(ownerNode: AbstractMesh): void;
  92613. /**
  92614. * Force relase the drag action by code.
  92615. */
  92616. releaseDrag(): void;
  92617. private _startDragRay;
  92618. private _lastPointerRay;
  92619. /**
  92620. * Simulates the start of a pointer drag event on the behavior
  92621. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  92622. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  92623. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  92624. */
  92625. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  92626. private _startDrag;
  92627. private _dragDelta;
  92628. private _moveDrag;
  92629. private _pickWithRayOnDragPlane;
  92630. private _pointA;
  92631. private _pointB;
  92632. private _pointC;
  92633. private _lineA;
  92634. private _lineB;
  92635. private _localAxis;
  92636. private _lookAt;
  92637. private _updateDragPlanePosition;
  92638. /**
  92639. * Detaches the behavior from the mesh
  92640. */
  92641. detach(): void;
  92642. }
  92643. }
  92644. declare module BABYLON {
  92645. /**
  92646. * A behavior that when attached to a mesh will allow the mesh to be scaled
  92647. */
  92648. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  92649. private _dragBehaviorA;
  92650. private _dragBehaviorB;
  92651. private _startDistance;
  92652. private _initialScale;
  92653. private _targetScale;
  92654. private _ownerNode;
  92655. private _sceneRenderObserver;
  92656. /**
  92657. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  92658. */
  92659. constructor();
  92660. /**
  92661. * The name of the behavior
  92662. */
  92663. readonly name: string;
  92664. /**
  92665. * Initializes the behavior
  92666. */
  92667. init(): void;
  92668. private _getCurrentDistance;
  92669. /**
  92670. * Attaches the scale behavior the passed in mesh
  92671. * @param ownerNode The mesh that will be scaled around once attached
  92672. */
  92673. attach(ownerNode: Mesh): void;
  92674. /**
  92675. * Detaches the behavior from the mesh
  92676. */
  92677. detach(): void;
  92678. }
  92679. }
  92680. declare module BABYLON {
  92681. /**
  92682. * 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
  92683. */
  92684. export class SixDofDragBehavior implements Behavior<Mesh> {
  92685. private static _virtualScene;
  92686. private _ownerNode;
  92687. private _sceneRenderObserver;
  92688. private _scene;
  92689. private _targetPosition;
  92690. private _virtualOriginMesh;
  92691. private _virtualDragMesh;
  92692. private _pointerObserver;
  92693. private _moving;
  92694. private _startingOrientation;
  92695. /**
  92696. * 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)
  92697. */
  92698. private zDragFactor;
  92699. /**
  92700. * If the object should rotate to face the drag origin
  92701. */
  92702. rotateDraggedObject: boolean;
  92703. /**
  92704. * If the behavior is currently in a dragging state
  92705. */
  92706. dragging: boolean;
  92707. /**
  92708. * 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)
  92709. */
  92710. dragDeltaRatio: number;
  92711. /**
  92712. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  92713. */
  92714. currentDraggingPointerID: number;
  92715. /**
  92716. * If camera controls should be detached during the drag
  92717. */
  92718. detachCameraControls: boolean;
  92719. /**
  92720. * Fires each time a drag starts
  92721. */
  92722. onDragStartObservable: Observable<{}>;
  92723. /**
  92724. * Fires each time a drag ends (eg. mouse release after drag)
  92725. */
  92726. onDragEndObservable: Observable<{}>;
  92727. /**
  92728. * 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
  92729. */
  92730. constructor();
  92731. /**
  92732. * The name of the behavior
  92733. */
  92734. readonly name: string;
  92735. /**
  92736. * Initializes the behavior
  92737. */
  92738. init(): void;
  92739. /**
  92740. * Attaches the scale behavior the passed in mesh
  92741. * @param ownerNode The mesh that will be scaled around once attached
  92742. */
  92743. attach(ownerNode: Mesh): void;
  92744. /**
  92745. * Detaches the behavior from the mesh
  92746. */
  92747. detach(): void;
  92748. }
  92749. }
  92750. declare module BABYLON {
  92751. /**
  92752. * Class used to apply inverse kinematics to bones
  92753. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  92754. */
  92755. export class BoneIKController {
  92756. private static _tmpVecs;
  92757. private static _tmpQuat;
  92758. private static _tmpMats;
  92759. /**
  92760. * Gets or sets the target mesh
  92761. */
  92762. targetMesh: AbstractMesh;
  92763. /** Gets or sets the mesh used as pole */
  92764. poleTargetMesh: AbstractMesh;
  92765. /**
  92766. * Gets or sets the bone used as pole
  92767. */
  92768. poleTargetBone: Nullable<Bone>;
  92769. /**
  92770. * Gets or sets the target position
  92771. */
  92772. targetPosition: Vector3;
  92773. /**
  92774. * Gets or sets the pole target position
  92775. */
  92776. poleTargetPosition: Vector3;
  92777. /**
  92778. * Gets or sets the pole target local offset
  92779. */
  92780. poleTargetLocalOffset: Vector3;
  92781. /**
  92782. * Gets or sets the pole angle
  92783. */
  92784. poleAngle: number;
  92785. /**
  92786. * Gets or sets the mesh associated with the controller
  92787. */
  92788. mesh: AbstractMesh;
  92789. /**
  92790. * 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)
  92791. */
  92792. slerpAmount: number;
  92793. private _bone1Quat;
  92794. private _bone1Mat;
  92795. private _bone2Ang;
  92796. private _bone1;
  92797. private _bone2;
  92798. private _bone1Length;
  92799. private _bone2Length;
  92800. private _maxAngle;
  92801. private _maxReach;
  92802. private _rightHandedSystem;
  92803. private _bendAxis;
  92804. private _slerping;
  92805. private _adjustRoll;
  92806. /**
  92807. * Gets or sets maximum allowed angle
  92808. */
  92809. maxAngle: number;
  92810. /**
  92811. * Creates a new BoneIKController
  92812. * @param mesh defines the mesh to control
  92813. * @param bone defines the bone to control
  92814. * @param options defines options to set up the controller
  92815. */
  92816. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  92817. targetMesh?: AbstractMesh;
  92818. poleTargetMesh?: AbstractMesh;
  92819. poleTargetBone?: Bone;
  92820. poleTargetLocalOffset?: Vector3;
  92821. poleAngle?: number;
  92822. bendAxis?: Vector3;
  92823. maxAngle?: number;
  92824. slerpAmount?: number;
  92825. });
  92826. private _setMaxAngle;
  92827. /**
  92828. * Force the controller to update the bones
  92829. */
  92830. update(): void;
  92831. }
  92832. }
  92833. declare module BABYLON {
  92834. /**
  92835. * Class used to make a bone look toward a point in space
  92836. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  92837. */
  92838. export class BoneLookController {
  92839. private static _tmpVecs;
  92840. private static _tmpQuat;
  92841. private static _tmpMats;
  92842. /**
  92843. * The target Vector3 that the bone will look at
  92844. */
  92845. target: Vector3;
  92846. /**
  92847. * The mesh that the bone is attached to
  92848. */
  92849. mesh: AbstractMesh;
  92850. /**
  92851. * The bone that will be looking to the target
  92852. */
  92853. bone: Bone;
  92854. /**
  92855. * The up axis of the coordinate system that is used when the bone is rotated
  92856. */
  92857. upAxis: Vector3;
  92858. /**
  92859. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  92860. */
  92861. upAxisSpace: Space;
  92862. /**
  92863. * Used to make an adjustment to the yaw of the bone
  92864. */
  92865. adjustYaw: number;
  92866. /**
  92867. * Used to make an adjustment to the pitch of the bone
  92868. */
  92869. adjustPitch: number;
  92870. /**
  92871. * Used to make an adjustment to the roll of the bone
  92872. */
  92873. adjustRoll: number;
  92874. /**
  92875. * 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)
  92876. */
  92877. slerpAmount: number;
  92878. private _minYaw;
  92879. private _maxYaw;
  92880. private _minPitch;
  92881. private _maxPitch;
  92882. private _minYawSin;
  92883. private _minYawCos;
  92884. private _maxYawSin;
  92885. private _maxYawCos;
  92886. private _midYawConstraint;
  92887. private _minPitchTan;
  92888. private _maxPitchTan;
  92889. private _boneQuat;
  92890. private _slerping;
  92891. private _transformYawPitch;
  92892. private _transformYawPitchInv;
  92893. private _firstFrameSkipped;
  92894. private _yawRange;
  92895. private _fowardAxis;
  92896. /**
  92897. * Gets or sets the minimum yaw angle that the bone can look to
  92898. */
  92899. minYaw: number;
  92900. /**
  92901. * Gets or sets the maximum yaw angle that the bone can look to
  92902. */
  92903. maxYaw: number;
  92904. /**
  92905. * Gets or sets the minimum pitch angle that the bone can look to
  92906. */
  92907. minPitch: number;
  92908. /**
  92909. * Gets or sets the maximum pitch angle that the bone can look to
  92910. */
  92911. maxPitch: number;
  92912. /**
  92913. * Create a BoneLookController
  92914. * @param mesh the mesh that the bone belongs to
  92915. * @param bone the bone that will be looking to the target
  92916. * @param target the target Vector3 to look at
  92917. * @param options optional settings:
  92918. * * maxYaw: the maximum angle the bone will yaw to
  92919. * * minYaw: the minimum angle the bone will yaw to
  92920. * * maxPitch: the maximum angle the bone will pitch to
  92921. * * minPitch: the minimum angle the bone will yaw to
  92922. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  92923. * * upAxis: the up axis of the coordinate system
  92924. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  92925. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  92926. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  92927. * * adjustYaw: used to make an adjustment to the yaw of the bone
  92928. * * adjustPitch: used to make an adjustment to the pitch of the bone
  92929. * * adjustRoll: used to make an adjustment to the roll of the bone
  92930. **/
  92931. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  92932. maxYaw?: number;
  92933. minYaw?: number;
  92934. maxPitch?: number;
  92935. minPitch?: number;
  92936. slerpAmount?: number;
  92937. upAxis?: Vector3;
  92938. upAxisSpace?: Space;
  92939. yawAxis?: Vector3;
  92940. pitchAxis?: Vector3;
  92941. adjustYaw?: number;
  92942. adjustPitch?: number;
  92943. adjustRoll?: number;
  92944. });
  92945. /**
  92946. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  92947. */
  92948. update(): void;
  92949. private _getAngleDiff;
  92950. private _getAngleBetween;
  92951. private _isAngleBetween;
  92952. }
  92953. }
  92954. declare module BABYLON {
  92955. /**
  92956. * Manage the gamepad inputs to control an arc rotate camera.
  92957. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  92958. */
  92959. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  92960. /**
  92961. * Defines the camera the input is attached to.
  92962. */
  92963. camera: ArcRotateCamera;
  92964. /**
  92965. * Defines the gamepad the input is gathering event from.
  92966. */
  92967. gamepad: Nullable<Gamepad>;
  92968. /**
  92969. * Defines the gamepad rotation sensiblity.
  92970. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  92971. */
  92972. gamepadRotationSensibility: number;
  92973. /**
  92974. * Defines the gamepad move sensiblity.
  92975. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  92976. */
  92977. gamepadMoveSensibility: number;
  92978. private _onGamepadConnectedObserver;
  92979. private _onGamepadDisconnectedObserver;
  92980. /**
  92981. * Attach the input controls to a specific dom element to get the input from.
  92982. * @param element Defines the element the controls should be listened from
  92983. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  92984. */
  92985. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  92986. /**
  92987. * Detach the current controls from the specified dom element.
  92988. * @param element Defines the element to stop listening the inputs from
  92989. */
  92990. detachControl(element: Nullable<HTMLElement>): void;
  92991. /**
  92992. * Update the current camera state depending on the inputs that have been used this frame.
  92993. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  92994. */
  92995. checkInputs(): void;
  92996. /**
  92997. * Gets the class name of the current intput.
  92998. * @returns the class name
  92999. */
  93000. getClassName(): string;
  93001. /**
  93002. * Get the friendly name associated with the input class.
  93003. * @returns the input friendly name
  93004. */
  93005. getSimpleName(): string;
  93006. }
  93007. }
  93008. declare module BABYLON {
  93009. interface ArcRotateCameraInputsManager {
  93010. /**
  93011. * Add orientation input support to the input manager.
  93012. * @returns the current input manager
  93013. */
  93014. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  93015. }
  93016. /**
  93017. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  93018. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93019. */
  93020. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  93021. /**
  93022. * Defines the camera the input is attached to.
  93023. */
  93024. camera: ArcRotateCamera;
  93025. /**
  93026. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  93027. */
  93028. alphaCorrection: number;
  93029. /**
  93030. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  93031. */
  93032. gammaCorrection: number;
  93033. private _alpha;
  93034. private _gamma;
  93035. private _dirty;
  93036. private _deviceOrientationHandler;
  93037. /**
  93038. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  93039. */
  93040. constructor();
  93041. /**
  93042. * Attach the input controls to a specific dom element to get the input from.
  93043. * @param element Defines the element the controls should be listened from
  93044. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  93045. */
  93046. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93047. /** @hidden */
  93048. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  93049. /**
  93050. * Update the current camera state depending on the inputs that have been used this frame.
  93051. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  93052. */
  93053. checkInputs(): void;
  93054. /**
  93055. * Detach the current controls from the specified dom element.
  93056. * @param element Defines the element to stop listening the inputs from
  93057. */
  93058. detachControl(element: Nullable<HTMLElement>): void;
  93059. /**
  93060. * Gets the class name of the current intput.
  93061. * @returns the class name
  93062. */
  93063. getClassName(): string;
  93064. /**
  93065. * Get the friendly name associated with the input class.
  93066. * @returns the input friendly name
  93067. */
  93068. getSimpleName(): string;
  93069. }
  93070. }
  93071. declare module BABYLON {
  93072. /**
  93073. * Listen to mouse events to control the camera.
  93074. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93075. */
  93076. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  93077. /**
  93078. * Defines the camera the input is attached to.
  93079. */
  93080. camera: FlyCamera;
  93081. /**
  93082. * Defines if touch is enabled. (Default is true.)
  93083. */
  93084. touchEnabled: boolean;
  93085. /**
  93086. * Defines the buttons associated with the input to handle camera rotation.
  93087. */
  93088. buttons: number[];
  93089. /**
  93090. * Assign buttons for Yaw control.
  93091. */
  93092. buttonsYaw: number[];
  93093. /**
  93094. * Assign buttons for Pitch control.
  93095. */
  93096. buttonsPitch: number[];
  93097. /**
  93098. * Assign buttons for Roll control.
  93099. */
  93100. buttonsRoll: number[];
  93101. /**
  93102. * Detect if any button is being pressed while mouse is moved.
  93103. * -1 = Mouse locked.
  93104. * 0 = Left button.
  93105. * 1 = Middle Button.
  93106. * 2 = Right Button.
  93107. */
  93108. activeButton: number;
  93109. /**
  93110. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  93111. * Higher values reduce its sensitivity.
  93112. */
  93113. angularSensibility: number;
  93114. private _mousemoveCallback;
  93115. private _observer;
  93116. private _rollObserver;
  93117. private previousPosition;
  93118. private noPreventDefault;
  93119. private element;
  93120. /**
  93121. * Listen to mouse events to control the camera.
  93122. * @param touchEnabled Define if touch is enabled. (Default is true.)
  93123. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93124. */
  93125. constructor(touchEnabled?: boolean);
  93126. /**
  93127. * Attach the mouse control to the HTML DOM element.
  93128. * @param element Defines the element that listens to the input events.
  93129. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  93130. */
  93131. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93132. /**
  93133. * Detach the current controls from the specified dom element.
  93134. * @param element Defines the element to stop listening the inputs from
  93135. */
  93136. detachControl(element: Nullable<HTMLElement>): void;
  93137. /**
  93138. * Gets the class name of the current input.
  93139. * @returns the class name.
  93140. */
  93141. getClassName(): string;
  93142. /**
  93143. * Get the friendly name associated with the input class.
  93144. * @returns the input's friendly name.
  93145. */
  93146. getSimpleName(): string;
  93147. private _pointerInput;
  93148. private _onMouseMove;
  93149. /**
  93150. * Rotate camera by mouse offset.
  93151. */
  93152. private rotateCamera;
  93153. }
  93154. }
  93155. declare module BABYLON {
  93156. /**
  93157. * Default Inputs manager for the FlyCamera.
  93158. * It groups all the default supported inputs for ease of use.
  93159. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93160. */
  93161. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  93162. /**
  93163. * Instantiates a new FlyCameraInputsManager.
  93164. * @param camera Defines the camera the inputs belong to.
  93165. */
  93166. constructor(camera: FlyCamera);
  93167. /**
  93168. * Add keyboard input support to the input manager.
  93169. * @returns the new FlyCameraKeyboardMoveInput().
  93170. */
  93171. addKeyboard(): FlyCameraInputsManager;
  93172. /**
  93173. * Add mouse input support to the input manager.
  93174. * @param touchEnabled Enable touch screen support.
  93175. * @returns the new FlyCameraMouseInput().
  93176. */
  93177. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  93178. }
  93179. }
  93180. declare module BABYLON {
  93181. /**
  93182. * This is a flying camera, designed for 3D movement and rotation in all directions,
  93183. * such as in a 3D Space Shooter or a Flight Simulator.
  93184. */
  93185. export class FlyCamera extends TargetCamera {
  93186. /**
  93187. * Define the collision ellipsoid of the camera.
  93188. * This is helpful for simulating a camera body, like a player's body.
  93189. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  93190. */
  93191. ellipsoid: Vector3;
  93192. /**
  93193. * Define an offset for the position of the ellipsoid around the camera.
  93194. * This can be helpful if the camera is attached away from the player's body center,
  93195. * such as at its head.
  93196. */
  93197. ellipsoidOffset: Vector3;
  93198. /**
  93199. * Enable or disable collisions of the camera with the rest of the scene objects.
  93200. */
  93201. checkCollisions: boolean;
  93202. /**
  93203. * Enable or disable gravity on the camera.
  93204. */
  93205. applyGravity: boolean;
  93206. /**
  93207. * Define the current direction the camera is moving to.
  93208. */
  93209. cameraDirection: Vector3;
  93210. /**
  93211. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  93212. * This overrides and empties cameraRotation.
  93213. */
  93214. rotationQuaternion: Quaternion;
  93215. /**
  93216. * Track Roll to maintain the wanted Rolling when looking around.
  93217. */
  93218. _trackRoll: number;
  93219. /**
  93220. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  93221. */
  93222. rollCorrect: number;
  93223. /**
  93224. * Mimic a banked turn, Rolling the camera when Yawing.
  93225. * It's recommended to use rollCorrect = 10 for faster banking correction.
  93226. */
  93227. bankedTurn: boolean;
  93228. /**
  93229. * Limit in radians for how much Roll banking will add. (Default: 90°)
  93230. */
  93231. bankedTurnLimit: number;
  93232. /**
  93233. * Value of 0 disables the banked Roll.
  93234. * Value of 1 is equal to the Yaw angle in radians.
  93235. */
  93236. bankedTurnMultiplier: number;
  93237. /**
  93238. * The inputs manager loads all the input sources, such as keyboard and mouse.
  93239. */
  93240. inputs: FlyCameraInputsManager;
  93241. /**
  93242. * Gets the input sensibility for mouse input.
  93243. * Higher values reduce sensitivity.
  93244. */
  93245. /**
  93246. * Sets the input sensibility for a mouse input.
  93247. * Higher values reduce sensitivity.
  93248. */
  93249. angularSensibility: number;
  93250. /**
  93251. * Get the keys for camera movement forward.
  93252. */
  93253. /**
  93254. * Set the keys for camera movement forward.
  93255. */
  93256. keysForward: number[];
  93257. /**
  93258. * Get the keys for camera movement backward.
  93259. */
  93260. keysBackward: number[];
  93261. /**
  93262. * Get the keys for camera movement up.
  93263. */
  93264. /**
  93265. * Set the keys for camera movement up.
  93266. */
  93267. keysUp: number[];
  93268. /**
  93269. * Get the keys for camera movement down.
  93270. */
  93271. /**
  93272. * Set the keys for camera movement down.
  93273. */
  93274. keysDown: number[];
  93275. /**
  93276. * Get the keys for camera movement left.
  93277. */
  93278. /**
  93279. * Set the keys for camera movement left.
  93280. */
  93281. keysLeft: number[];
  93282. /**
  93283. * Set the keys for camera movement right.
  93284. */
  93285. /**
  93286. * Set the keys for camera movement right.
  93287. */
  93288. keysRight: number[];
  93289. /**
  93290. * Event raised when the camera collides with a mesh in the scene.
  93291. */
  93292. onCollide: (collidedMesh: AbstractMesh) => void;
  93293. private _collider;
  93294. private _needMoveForGravity;
  93295. private _oldPosition;
  93296. private _diffPosition;
  93297. private _newPosition;
  93298. /** @hidden */
  93299. _localDirection: Vector3;
  93300. /** @hidden */
  93301. _transformedDirection: Vector3;
  93302. /**
  93303. * Instantiates a FlyCamera.
  93304. * This is a flying camera, designed for 3D movement and rotation in all directions,
  93305. * such as in a 3D Space Shooter or a Flight Simulator.
  93306. * @param name Define the name of the camera in the scene.
  93307. * @param position Define the starting position of the camera in the scene.
  93308. * @param scene Define the scene the camera belongs to.
  93309. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  93310. */
  93311. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  93312. /**
  93313. * Attach a control to the HTML DOM element.
  93314. * @param element Defines the element that listens to the input events.
  93315. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  93316. */
  93317. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93318. /**
  93319. * Detach a control from the HTML DOM element.
  93320. * The camera will stop reacting to that input.
  93321. * @param element Defines the element that listens to the input events.
  93322. */
  93323. detachControl(element: HTMLElement): void;
  93324. private _collisionMask;
  93325. /**
  93326. * Get the mask that the camera ignores in collision events.
  93327. */
  93328. /**
  93329. * Set the mask that the camera ignores in collision events.
  93330. */
  93331. collisionMask: number;
  93332. /** @hidden */
  93333. _collideWithWorld(displacement: Vector3): void;
  93334. /** @hidden */
  93335. private _onCollisionPositionChange;
  93336. /** @hidden */
  93337. _checkInputs(): void;
  93338. /** @hidden */
  93339. _decideIfNeedsToMove(): boolean;
  93340. /** @hidden */
  93341. _updatePosition(): void;
  93342. /**
  93343. * Restore the Roll to its target value at the rate specified.
  93344. * @param rate - Higher means slower restoring.
  93345. * @hidden
  93346. */
  93347. restoreRoll(rate: number): void;
  93348. /**
  93349. * Destroy the camera and release the current resources held by it.
  93350. */
  93351. dispose(): void;
  93352. /**
  93353. * Get the current object class name.
  93354. * @returns the class name.
  93355. */
  93356. getClassName(): string;
  93357. }
  93358. }
  93359. declare module BABYLON {
  93360. /**
  93361. * Listen to keyboard events to control the camera.
  93362. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93363. */
  93364. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  93365. /**
  93366. * Defines the camera the input is attached to.
  93367. */
  93368. camera: FlyCamera;
  93369. /**
  93370. * The list of keyboard keys used to control the forward move of the camera.
  93371. */
  93372. keysForward: number[];
  93373. /**
  93374. * The list of keyboard keys used to control the backward move of the camera.
  93375. */
  93376. keysBackward: number[];
  93377. /**
  93378. * The list of keyboard keys used to control the forward move of the camera.
  93379. */
  93380. keysUp: number[];
  93381. /**
  93382. * The list of keyboard keys used to control the backward move of the camera.
  93383. */
  93384. keysDown: number[];
  93385. /**
  93386. * The list of keyboard keys used to control the right strafe move of the camera.
  93387. */
  93388. keysRight: number[];
  93389. /**
  93390. * The list of keyboard keys used to control the left strafe move of the camera.
  93391. */
  93392. keysLeft: number[];
  93393. private _keys;
  93394. private _onCanvasBlurObserver;
  93395. private _onKeyboardObserver;
  93396. private _engine;
  93397. private _scene;
  93398. /**
  93399. * Attach the input controls to a specific dom element to get the input from.
  93400. * @param element Defines the element the controls should be listened from
  93401. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  93402. */
  93403. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93404. /**
  93405. * Detach the current controls from the specified dom element.
  93406. * @param element Defines the element to stop listening the inputs from
  93407. */
  93408. detachControl(element: Nullable<HTMLElement>): void;
  93409. /**
  93410. * Gets the class name of the current intput.
  93411. * @returns the class name
  93412. */
  93413. getClassName(): string;
  93414. /** @hidden */
  93415. _onLostFocus(e: FocusEvent): void;
  93416. /**
  93417. * Get the friendly name associated with the input class.
  93418. * @returns the input friendly name
  93419. */
  93420. getSimpleName(): string;
  93421. /**
  93422. * Update the current camera state depending on the inputs that have been used this frame.
  93423. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  93424. */
  93425. checkInputs(): void;
  93426. }
  93427. }
  93428. declare module BABYLON {
  93429. /**
  93430. * Manage the mouse wheel inputs to control a follow camera.
  93431. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93432. */
  93433. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  93434. /**
  93435. * Defines the camera the input is attached to.
  93436. */
  93437. camera: FollowCamera;
  93438. /**
  93439. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  93440. */
  93441. axisControlRadius: boolean;
  93442. /**
  93443. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  93444. */
  93445. axisControlHeight: boolean;
  93446. /**
  93447. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  93448. */
  93449. axisControlRotation: boolean;
  93450. /**
  93451. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  93452. * relation to mouseWheel events.
  93453. */
  93454. wheelPrecision: number;
  93455. /**
  93456. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  93457. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  93458. */
  93459. wheelDeltaPercentage: number;
  93460. private _wheel;
  93461. private _observer;
  93462. /**
  93463. * Attach the input controls to a specific dom element to get the input from.
  93464. * @param element Defines the element the controls should be listened from
  93465. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  93466. */
  93467. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93468. /**
  93469. * Detach the current controls from the specified dom element.
  93470. * @param element Defines the element to stop listening the inputs from
  93471. */
  93472. detachControl(element: Nullable<HTMLElement>): void;
  93473. /**
  93474. * Gets the class name of the current intput.
  93475. * @returns the class name
  93476. */
  93477. getClassName(): string;
  93478. /**
  93479. * Get the friendly name associated with the input class.
  93480. * @returns the input friendly name
  93481. */
  93482. getSimpleName(): string;
  93483. }
  93484. }
  93485. declare module BABYLON {
  93486. /**
  93487. * Manage the pointers inputs to control an follow camera.
  93488. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93489. */
  93490. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  93491. /**
  93492. * Defines the camera the input is attached to.
  93493. */
  93494. camera: FollowCamera;
  93495. /**
  93496. * Gets the class name of the current input.
  93497. * @returns the class name
  93498. */
  93499. getClassName(): string;
  93500. /**
  93501. * Defines the pointer angular sensibility along the X axis or how fast is
  93502. * the camera rotating.
  93503. * A negative number will reverse the axis direction.
  93504. */
  93505. angularSensibilityX: number;
  93506. /**
  93507. * Defines the pointer angular sensibility along the Y axis or how fast is
  93508. * the camera rotating.
  93509. * A negative number will reverse the axis direction.
  93510. */
  93511. angularSensibilityY: number;
  93512. /**
  93513. * Defines the pointer pinch precision or how fast is the camera zooming.
  93514. * A negative number will reverse the axis direction.
  93515. */
  93516. pinchPrecision: number;
  93517. /**
  93518. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  93519. * from 0.
  93520. * It defines the percentage of current camera.radius to use as delta when
  93521. * pinch zoom is used.
  93522. */
  93523. pinchDeltaPercentage: number;
  93524. /**
  93525. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  93526. */
  93527. axisXControlRadius: boolean;
  93528. /**
  93529. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  93530. */
  93531. axisXControlHeight: boolean;
  93532. /**
  93533. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  93534. */
  93535. axisXControlRotation: boolean;
  93536. /**
  93537. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  93538. */
  93539. axisYControlRadius: boolean;
  93540. /**
  93541. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  93542. */
  93543. axisYControlHeight: boolean;
  93544. /**
  93545. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  93546. */
  93547. axisYControlRotation: boolean;
  93548. /**
  93549. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  93550. */
  93551. axisPinchControlRadius: boolean;
  93552. /**
  93553. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  93554. */
  93555. axisPinchControlHeight: boolean;
  93556. /**
  93557. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  93558. */
  93559. axisPinchControlRotation: boolean;
  93560. /**
  93561. * Log error messages if basic misconfiguration has occurred.
  93562. */
  93563. warningEnable: boolean;
  93564. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  93565. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  93566. private _warningCounter;
  93567. private _warning;
  93568. }
  93569. }
  93570. declare module BABYLON {
  93571. /**
  93572. * Default Inputs manager for the FollowCamera.
  93573. * It groups all the default supported inputs for ease of use.
  93574. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93575. */
  93576. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  93577. /**
  93578. * Instantiates a new FollowCameraInputsManager.
  93579. * @param camera Defines the camera the inputs belong to
  93580. */
  93581. constructor(camera: FollowCamera);
  93582. /**
  93583. * Add keyboard input support to the input manager.
  93584. * @returns the current input manager
  93585. */
  93586. addKeyboard(): FollowCameraInputsManager;
  93587. /**
  93588. * Add mouse wheel input support to the input manager.
  93589. * @returns the current input manager
  93590. */
  93591. addMouseWheel(): FollowCameraInputsManager;
  93592. /**
  93593. * Add pointers input support to the input manager.
  93594. * @returns the current input manager
  93595. */
  93596. addPointers(): FollowCameraInputsManager;
  93597. /**
  93598. * Add orientation input support to the input manager.
  93599. * @returns the current input manager
  93600. */
  93601. addVRDeviceOrientation(): FollowCameraInputsManager;
  93602. }
  93603. }
  93604. declare module BABYLON {
  93605. /**
  93606. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  93607. * an arc rotate version arcFollowCamera are available.
  93608. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  93609. */
  93610. export class FollowCamera extends TargetCamera {
  93611. /**
  93612. * Distance the follow camera should follow an object at
  93613. */
  93614. radius: number;
  93615. /**
  93616. * Minimum allowed distance of the camera to the axis of rotation
  93617. * (The camera can not get closer).
  93618. * This can help limiting how the Camera is able to move in the scene.
  93619. */
  93620. lowerRadiusLimit: Nullable<number>;
  93621. /**
  93622. * Maximum allowed distance of the camera to the axis of rotation
  93623. * (The camera can not get further).
  93624. * This can help limiting how the Camera is able to move in the scene.
  93625. */
  93626. upperRadiusLimit: Nullable<number>;
  93627. /**
  93628. * Define a rotation offset between the camera and the object it follows
  93629. */
  93630. rotationOffset: number;
  93631. /**
  93632. * Minimum allowed angle to camera position relative to target object.
  93633. * This can help limiting how the Camera is able to move in the scene.
  93634. */
  93635. lowerRotationOffsetLimit: Nullable<number>;
  93636. /**
  93637. * Maximum allowed angle to camera position relative to target object.
  93638. * This can help limiting how the Camera is able to move in the scene.
  93639. */
  93640. upperRotationOffsetLimit: Nullable<number>;
  93641. /**
  93642. * Define a height offset between the camera and the object it follows.
  93643. * It can help following an object from the top (like a car chaing a plane)
  93644. */
  93645. heightOffset: number;
  93646. /**
  93647. * Minimum allowed height of camera position relative to target object.
  93648. * This can help limiting how the Camera is able to move in the scene.
  93649. */
  93650. lowerHeightOffsetLimit: Nullable<number>;
  93651. /**
  93652. * Maximum allowed height of camera position relative to target object.
  93653. * This can help limiting how the Camera is able to move in the scene.
  93654. */
  93655. upperHeightOffsetLimit: Nullable<number>;
  93656. /**
  93657. * Define how fast the camera can accelerate to follow it s target.
  93658. */
  93659. cameraAcceleration: number;
  93660. /**
  93661. * Define the speed limit of the camera following an object.
  93662. */
  93663. maxCameraSpeed: number;
  93664. /**
  93665. * Define the target of the camera.
  93666. */
  93667. lockedTarget: Nullable<AbstractMesh>;
  93668. /**
  93669. * Defines the input associated with the camera.
  93670. */
  93671. inputs: FollowCameraInputsManager;
  93672. /**
  93673. * Instantiates the follow camera.
  93674. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  93675. * @param name Define the name of the camera in the scene
  93676. * @param position Define the position of the camera
  93677. * @param scene Define the scene the camera belong to
  93678. * @param lockedTarget Define the target of the camera
  93679. */
  93680. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  93681. private _follow;
  93682. /**
  93683. * Attached controls to the current camera.
  93684. * @param element Defines the element the controls should be listened from
  93685. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  93686. */
  93687. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93688. /**
  93689. * Detach the current controls from the camera.
  93690. * The camera will stop reacting to inputs.
  93691. * @param element Defines the element to stop listening the inputs from
  93692. */
  93693. detachControl(element: HTMLElement): void;
  93694. /** @hidden */
  93695. _checkInputs(): void;
  93696. private _checkLimits;
  93697. /**
  93698. * Gets the camera class name.
  93699. * @returns the class name
  93700. */
  93701. getClassName(): string;
  93702. }
  93703. /**
  93704. * Arc Rotate version of the follow camera.
  93705. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  93706. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  93707. */
  93708. export class ArcFollowCamera extends TargetCamera {
  93709. /** The longitudinal angle of the camera */
  93710. alpha: number;
  93711. /** The latitudinal angle of the camera */
  93712. beta: number;
  93713. /** The radius of the camera from its target */
  93714. radius: number;
  93715. /** Define the camera target (the messh it should follow) */
  93716. target: Nullable<AbstractMesh>;
  93717. private _cartesianCoordinates;
  93718. /**
  93719. * Instantiates a new ArcFollowCamera
  93720. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  93721. * @param name Define the name of the camera
  93722. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  93723. * @param beta Define the rotation angle of the camera around the elevation axis
  93724. * @param radius Define the radius of the camera from its target point
  93725. * @param target Define the target of the camera
  93726. * @param scene Define the scene the camera belongs to
  93727. */
  93728. constructor(name: string,
  93729. /** The longitudinal angle of the camera */
  93730. alpha: number,
  93731. /** The latitudinal angle of the camera */
  93732. beta: number,
  93733. /** The radius of the camera from its target */
  93734. radius: number,
  93735. /** Define the camera target (the messh it should follow) */
  93736. target: Nullable<AbstractMesh>, scene: Scene);
  93737. private _follow;
  93738. /** @hidden */
  93739. _checkInputs(): void;
  93740. /**
  93741. * Returns the class name of the object.
  93742. * It is mostly used internally for serialization purposes.
  93743. */
  93744. getClassName(): string;
  93745. }
  93746. }
  93747. declare module BABYLON {
  93748. /**
  93749. * Manage the keyboard inputs to control the movement of a follow camera.
  93750. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93751. */
  93752. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  93753. /**
  93754. * Defines the camera the input is attached to.
  93755. */
  93756. camera: FollowCamera;
  93757. /**
  93758. * Defines the list of key codes associated with the up action (increase heightOffset)
  93759. */
  93760. keysHeightOffsetIncr: number[];
  93761. /**
  93762. * Defines the list of key codes associated with the down action (decrease heightOffset)
  93763. */
  93764. keysHeightOffsetDecr: number[];
  93765. /**
  93766. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  93767. */
  93768. keysHeightOffsetModifierAlt: boolean;
  93769. /**
  93770. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  93771. */
  93772. keysHeightOffsetModifierCtrl: boolean;
  93773. /**
  93774. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  93775. */
  93776. keysHeightOffsetModifierShift: boolean;
  93777. /**
  93778. * Defines the list of key codes associated with the left action (increase rotationOffset)
  93779. */
  93780. keysRotationOffsetIncr: number[];
  93781. /**
  93782. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  93783. */
  93784. keysRotationOffsetDecr: number[];
  93785. /**
  93786. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  93787. */
  93788. keysRotationOffsetModifierAlt: boolean;
  93789. /**
  93790. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  93791. */
  93792. keysRotationOffsetModifierCtrl: boolean;
  93793. /**
  93794. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  93795. */
  93796. keysRotationOffsetModifierShift: boolean;
  93797. /**
  93798. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  93799. */
  93800. keysRadiusIncr: number[];
  93801. /**
  93802. * Defines the list of key codes associated with the zoom-out action (increase radius)
  93803. */
  93804. keysRadiusDecr: number[];
  93805. /**
  93806. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  93807. */
  93808. keysRadiusModifierAlt: boolean;
  93809. /**
  93810. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  93811. */
  93812. keysRadiusModifierCtrl: boolean;
  93813. /**
  93814. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  93815. */
  93816. keysRadiusModifierShift: boolean;
  93817. /**
  93818. * Defines the rate of change of heightOffset.
  93819. */
  93820. heightSensibility: number;
  93821. /**
  93822. * Defines the rate of change of rotationOffset.
  93823. */
  93824. rotationSensibility: number;
  93825. /**
  93826. * Defines the rate of change of radius.
  93827. */
  93828. radiusSensibility: number;
  93829. private _keys;
  93830. private _ctrlPressed;
  93831. private _altPressed;
  93832. private _shiftPressed;
  93833. private _onCanvasBlurObserver;
  93834. private _onKeyboardObserver;
  93835. private _engine;
  93836. private _scene;
  93837. /**
  93838. * Attach the input controls to a specific dom element to get the input from.
  93839. * @param element Defines the element the controls should be listened from
  93840. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  93841. */
  93842. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93843. /**
  93844. * Detach the current controls from the specified dom element.
  93845. * @param element Defines the element to stop listening the inputs from
  93846. */
  93847. detachControl(element: Nullable<HTMLElement>): void;
  93848. /**
  93849. * Update the current camera state depending on the inputs that have been used this frame.
  93850. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  93851. */
  93852. checkInputs(): void;
  93853. /**
  93854. * Gets the class name of the current input.
  93855. * @returns the class name
  93856. */
  93857. getClassName(): string;
  93858. /**
  93859. * Get the friendly name associated with the input class.
  93860. * @returns the input friendly name
  93861. */
  93862. getSimpleName(): string;
  93863. /**
  93864. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  93865. * allow modification of the heightOffset value.
  93866. */
  93867. private _modifierHeightOffset;
  93868. /**
  93869. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  93870. * allow modification of the rotationOffset value.
  93871. */
  93872. private _modifierRotationOffset;
  93873. /**
  93874. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  93875. * allow modification of the radius value.
  93876. */
  93877. private _modifierRadius;
  93878. }
  93879. }
  93880. declare module BABYLON {
  93881. interface FreeCameraInputsManager {
  93882. /**
  93883. * Add orientation input support to the input manager.
  93884. * @returns the current input manager
  93885. */
  93886. addDeviceOrientation(): FreeCameraInputsManager;
  93887. }
  93888. /**
  93889. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  93890. * Screen rotation is taken into account.
  93891. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93892. */
  93893. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  93894. private _camera;
  93895. private _screenOrientationAngle;
  93896. private _constantTranform;
  93897. private _screenQuaternion;
  93898. private _alpha;
  93899. private _beta;
  93900. private _gamma;
  93901. /**
  93902. * Instantiates a new input
  93903. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93904. */
  93905. constructor();
  93906. /**
  93907. * Define the camera controlled by the input.
  93908. */
  93909. camera: FreeCamera;
  93910. /**
  93911. * Attach the input controls to a specific dom element to get the input from.
  93912. * @param element Defines the element the controls should be listened from
  93913. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  93914. */
  93915. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93916. private _orientationChanged;
  93917. private _deviceOrientation;
  93918. /**
  93919. * Detach the current controls from the specified dom element.
  93920. * @param element Defines the element to stop listening the inputs from
  93921. */
  93922. detachControl(element: Nullable<HTMLElement>): void;
  93923. /**
  93924. * Update the current camera state depending on the inputs that have been used this frame.
  93925. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  93926. */
  93927. checkInputs(): void;
  93928. /**
  93929. * Gets the class name of the current intput.
  93930. * @returns the class name
  93931. */
  93932. getClassName(): string;
  93933. /**
  93934. * Get the friendly name associated with the input class.
  93935. * @returns the input friendly name
  93936. */
  93937. getSimpleName(): string;
  93938. }
  93939. }
  93940. declare module BABYLON {
  93941. /**
  93942. * Manage the gamepad inputs to control a free camera.
  93943. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93944. */
  93945. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  93946. /**
  93947. * Define the camera the input is attached to.
  93948. */
  93949. camera: FreeCamera;
  93950. /**
  93951. * Define the Gamepad controlling the input
  93952. */
  93953. gamepad: Nullable<Gamepad>;
  93954. /**
  93955. * Defines the gamepad rotation sensiblity.
  93956. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  93957. */
  93958. gamepadAngularSensibility: number;
  93959. /**
  93960. * Defines the gamepad move sensiblity.
  93961. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  93962. */
  93963. gamepadMoveSensibility: number;
  93964. private _onGamepadConnectedObserver;
  93965. private _onGamepadDisconnectedObserver;
  93966. private _cameraTransform;
  93967. private _deltaTransform;
  93968. private _vector3;
  93969. private _vector2;
  93970. /**
  93971. * Attach the input controls to a specific dom element to get the input from.
  93972. * @param element Defines the element the controls should be listened from
  93973. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  93974. */
  93975. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93976. /**
  93977. * Detach the current controls from the specified dom element.
  93978. * @param element Defines the element to stop listening the inputs from
  93979. */
  93980. detachControl(element: Nullable<HTMLElement>): void;
  93981. /**
  93982. * Update the current camera state depending on the inputs that have been used this frame.
  93983. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  93984. */
  93985. checkInputs(): void;
  93986. /**
  93987. * Gets the class name of the current intput.
  93988. * @returns the class name
  93989. */
  93990. getClassName(): string;
  93991. /**
  93992. * Get the friendly name associated with the input class.
  93993. * @returns the input friendly name
  93994. */
  93995. getSimpleName(): string;
  93996. }
  93997. }
  93998. declare module BABYLON {
  93999. /**
  94000. * Defines the potential axis of a Joystick
  94001. */
  94002. export enum JoystickAxis {
  94003. /** X axis */
  94004. X = 0,
  94005. /** Y axis */
  94006. Y = 1,
  94007. /** Z axis */
  94008. Z = 2
  94009. }
  94010. /**
  94011. * Class used to define virtual joystick (used in touch mode)
  94012. */
  94013. export class VirtualJoystick {
  94014. /**
  94015. * Gets or sets a boolean indicating that left and right values must be inverted
  94016. */
  94017. reverseLeftRight: boolean;
  94018. /**
  94019. * Gets or sets a boolean indicating that up and down values must be inverted
  94020. */
  94021. reverseUpDown: boolean;
  94022. /**
  94023. * Gets the offset value for the position (ie. the change of the position value)
  94024. */
  94025. deltaPosition: Vector3;
  94026. /**
  94027. * Gets a boolean indicating if the virtual joystick was pressed
  94028. */
  94029. pressed: boolean;
  94030. /**
  94031. * Canvas the virtual joystick will render onto, default z-index of this is 5
  94032. */
  94033. static Canvas: Nullable<HTMLCanvasElement>;
  94034. private static _globalJoystickIndex;
  94035. private static vjCanvasContext;
  94036. private static vjCanvasWidth;
  94037. private static vjCanvasHeight;
  94038. private static halfWidth;
  94039. private _action;
  94040. private _axisTargetedByLeftAndRight;
  94041. private _axisTargetedByUpAndDown;
  94042. private _joystickSensibility;
  94043. private _inversedSensibility;
  94044. private _joystickPointerID;
  94045. private _joystickColor;
  94046. private _joystickPointerPos;
  94047. private _joystickPreviousPointerPos;
  94048. private _joystickPointerStartPos;
  94049. private _deltaJoystickVector;
  94050. private _leftJoystick;
  94051. private _touches;
  94052. private _onPointerDownHandlerRef;
  94053. private _onPointerMoveHandlerRef;
  94054. private _onPointerUpHandlerRef;
  94055. private _onResize;
  94056. /**
  94057. * Creates a new virtual joystick
  94058. * @param leftJoystick defines that the joystick is for left hand (false by default)
  94059. */
  94060. constructor(leftJoystick?: boolean);
  94061. /**
  94062. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  94063. * @param newJoystickSensibility defines the new sensibility
  94064. */
  94065. setJoystickSensibility(newJoystickSensibility: number): void;
  94066. private _onPointerDown;
  94067. private _onPointerMove;
  94068. private _onPointerUp;
  94069. /**
  94070. * Change the color of the virtual joystick
  94071. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  94072. */
  94073. setJoystickColor(newColor: string): void;
  94074. /**
  94075. * Defines a callback to call when the joystick is touched
  94076. * @param action defines the callback
  94077. */
  94078. setActionOnTouch(action: () => any): void;
  94079. /**
  94080. * Defines which axis you'd like to control for left & right
  94081. * @param axis defines the axis to use
  94082. */
  94083. setAxisForLeftRight(axis: JoystickAxis): void;
  94084. /**
  94085. * Defines which axis you'd like to control for up & down
  94086. * @param axis defines the axis to use
  94087. */
  94088. setAxisForUpDown(axis: JoystickAxis): void;
  94089. private _drawVirtualJoystick;
  94090. /**
  94091. * Release internal HTML canvas
  94092. */
  94093. releaseCanvas(): void;
  94094. }
  94095. }
  94096. declare module BABYLON {
  94097. interface FreeCameraInputsManager {
  94098. /**
  94099. * Add virtual joystick input support to the input manager.
  94100. * @returns the current input manager
  94101. */
  94102. addVirtualJoystick(): FreeCameraInputsManager;
  94103. }
  94104. /**
  94105. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  94106. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94107. */
  94108. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  94109. /**
  94110. * Defines the camera the input is attached to.
  94111. */
  94112. camera: FreeCamera;
  94113. private _leftjoystick;
  94114. private _rightjoystick;
  94115. /**
  94116. * Gets the left stick of the virtual joystick.
  94117. * @returns The virtual Joystick
  94118. */
  94119. getLeftJoystick(): VirtualJoystick;
  94120. /**
  94121. * Gets the right stick of the virtual joystick.
  94122. * @returns The virtual Joystick
  94123. */
  94124. getRightJoystick(): VirtualJoystick;
  94125. /**
  94126. * Update the current camera state depending on the inputs that have been used this frame.
  94127. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  94128. */
  94129. checkInputs(): void;
  94130. /**
  94131. * Attach the input controls to a specific dom element to get the input from.
  94132. * @param element Defines the element the controls should be listened from
  94133. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  94134. */
  94135. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  94136. /**
  94137. * Detach the current controls from the specified dom element.
  94138. * @param element Defines the element to stop listening the inputs from
  94139. */
  94140. detachControl(element: Nullable<HTMLElement>): void;
  94141. /**
  94142. * Gets the class name of the current intput.
  94143. * @returns the class name
  94144. */
  94145. getClassName(): string;
  94146. /**
  94147. * Get the friendly name associated with the input class.
  94148. * @returns the input friendly name
  94149. */
  94150. getSimpleName(): string;
  94151. }
  94152. }
  94153. declare module BABYLON {
  94154. /**
  94155. * This represents a FPS type of camera controlled by touch.
  94156. * This is like a universal camera minus the Gamepad controls.
  94157. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  94158. */
  94159. export class TouchCamera extends FreeCamera {
  94160. /**
  94161. * Defines the touch sensibility for rotation.
  94162. * The higher the faster.
  94163. */
  94164. touchAngularSensibility: number;
  94165. /**
  94166. * Defines the touch sensibility for move.
  94167. * The higher the faster.
  94168. */
  94169. touchMoveSensibility: number;
  94170. /**
  94171. * Instantiates a new touch camera.
  94172. * This represents a FPS type of camera controlled by touch.
  94173. * This is like a universal camera minus the Gamepad controls.
  94174. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  94175. * @param name Define the name of the camera in the scene
  94176. * @param position Define the start position of the camera in the scene
  94177. * @param scene Define the scene the camera belongs to
  94178. */
  94179. constructor(name: string, position: Vector3, scene: Scene);
  94180. /**
  94181. * Gets the current object class name.
  94182. * @return the class name
  94183. */
  94184. getClassName(): string;
  94185. /** @hidden */
  94186. _setupInputs(): void;
  94187. }
  94188. }
  94189. declare module BABYLON {
  94190. /**
  94191. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  94192. * being tilted forward or back and left or right.
  94193. */
  94194. export class DeviceOrientationCamera extends FreeCamera {
  94195. private _initialQuaternion;
  94196. private _quaternionCache;
  94197. /**
  94198. * Creates a new device orientation camera
  94199. * @param name The name of the camera
  94200. * @param position The start position camera
  94201. * @param scene The scene the camera belongs to
  94202. */
  94203. constructor(name: string, position: Vector3, scene: Scene);
  94204. /**
  94205. * Gets the current instance class name ("DeviceOrientationCamera").
  94206. * This helps avoiding instanceof at run time.
  94207. * @returns the class name
  94208. */
  94209. getClassName(): string;
  94210. /**
  94211. * @hidden
  94212. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  94213. */
  94214. _checkInputs(): void;
  94215. /**
  94216. * Reset the camera to its default orientation on the specified axis only.
  94217. * @param axis The axis to reset
  94218. */
  94219. resetToCurrentRotation(axis?: Axis): void;
  94220. }
  94221. }
  94222. declare module BABYLON {
  94223. /**
  94224. * 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,
  94225. * which still works and will still be found in many Playgrounds.
  94226. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  94227. */
  94228. export class UniversalCamera extends TouchCamera {
  94229. /**
  94230. * Defines the gamepad rotation sensiblity.
  94231. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  94232. */
  94233. gamepadAngularSensibility: number;
  94234. /**
  94235. * Defines the gamepad move sensiblity.
  94236. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  94237. */
  94238. gamepadMoveSensibility: number;
  94239. /**
  94240. * 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,
  94241. * which still works and will still be found in many Playgrounds.
  94242. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  94243. * @param name Define the name of the camera in the scene
  94244. * @param position Define the start position of the camera in the scene
  94245. * @param scene Define the scene the camera belongs to
  94246. */
  94247. constructor(name: string, position: Vector3, scene: Scene);
  94248. /**
  94249. * Gets the current object class name.
  94250. * @return the class name
  94251. */
  94252. getClassName(): string;
  94253. }
  94254. }
  94255. declare module BABYLON {
  94256. /**
  94257. * This represents a FPS type of camera. This is only here for back compat purpose.
  94258. * Please use the UniversalCamera instead as both are identical.
  94259. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  94260. */
  94261. export class GamepadCamera extends UniversalCamera {
  94262. /**
  94263. * Instantiates a new Gamepad Camera
  94264. * This represents a FPS type of camera. This is only here for back compat purpose.
  94265. * Please use the UniversalCamera instead as both are identical.
  94266. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  94267. * @param name Define the name of the camera in the scene
  94268. * @param position Define the start position of the camera in the scene
  94269. * @param scene Define the scene the camera belongs to
  94270. */
  94271. constructor(name: string, position: Vector3, scene: Scene);
  94272. /**
  94273. * Gets the current object class name.
  94274. * @return the class name
  94275. */
  94276. getClassName(): string;
  94277. }
  94278. }
  94279. declare module BABYLON {
  94280. /** @hidden */
  94281. export var passPixelShader: {
  94282. name: string;
  94283. shader: string;
  94284. };
  94285. }
  94286. declare module BABYLON {
  94287. /** @hidden */
  94288. export var passCubePixelShader: {
  94289. name: string;
  94290. shader: string;
  94291. };
  94292. }
  94293. declare module BABYLON {
  94294. /**
  94295. * PassPostProcess which produces an output the same as it's input
  94296. */
  94297. export class PassPostProcess extends PostProcess {
  94298. /**
  94299. * Creates the PassPostProcess
  94300. * @param name The name of the effect.
  94301. * @param options The required width/height ratio to downsize to before computing the render pass.
  94302. * @param camera The camera to apply the render pass to.
  94303. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  94304. * @param engine The engine which the post process will be applied. (default: current engine)
  94305. * @param reusable If the post process can be reused on the same frame. (default: false)
  94306. * @param textureType The type of texture to be used when performing the post processing.
  94307. * @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)
  94308. */
  94309. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  94310. }
  94311. /**
  94312. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  94313. */
  94314. export class PassCubePostProcess extends PostProcess {
  94315. private _face;
  94316. /**
  94317. * Gets or sets the cube face to display.
  94318. * * 0 is +X
  94319. * * 1 is -X
  94320. * * 2 is +Y
  94321. * * 3 is -Y
  94322. * * 4 is +Z
  94323. * * 5 is -Z
  94324. */
  94325. face: number;
  94326. /**
  94327. * Creates the PassCubePostProcess
  94328. * @param name The name of the effect.
  94329. * @param options The required width/height ratio to downsize to before computing the render pass.
  94330. * @param camera The camera to apply the render pass to.
  94331. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  94332. * @param engine The engine which the post process will be applied. (default: current engine)
  94333. * @param reusable If the post process can be reused on the same frame. (default: false)
  94334. * @param textureType The type of texture to be used when performing the post processing.
  94335. * @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)
  94336. */
  94337. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  94338. }
  94339. }
  94340. declare module BABYLON {
  94341. /** @hidden */
  94342. export var anaglyphPixelShader: {
  94343. name: string;
  94344. shader: string;
  94345. };
  94346. }
  94347. declare module BABYLON {
  94348. /**
  94349. * Postprocess used to generate anaglyphic rendering
  94350. */
  94351. export class AnaglyphPostProcess extends PostProcess {
  94352. private _passedProcess;
  94353. /**
  94354. * Creates a new AnaglyphPostProcess
  94355. * @param name defines postprocess name
  94356. * @param options defines creation options or target ratio scale
  94357. * @param rigCameras defines cameras using this postprocess
  94358. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  94359. * @param engine defines hosting engine
  94360. * @param reusable defines if the postprocess will be reused multiple times per frame
  94361. */
  94362. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  94363. }
  94364. }
  94365. declare module BABYLON {
  94366. /**
  94367. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  94368. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  94369. */
  94370. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  94371. /**
  94372. * Creates a new AnaglyphArcRotateCamera
  94373. * @param name defines camera name
  94374. * @param alpha defines alpha angle (in radians)
  94375. * @param beta defines beta angle (in radians)
  94376. * @param radius defines radius
  94377. * @param target defines camera target
  94378. * @param interaxialDistance defines distance between each color axis
  94379. * @param scene defines the hosting scene
  94380. */
  94381. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  94382. /**
  94383. * Gets camera class name
  94384. * @returns AnaglyphArcRotateCamera
  94385. */
  94386. getClassName(): string;
  94387. }
  94388. }
  94389. declare module BABYLON {
  94390. /**
  94391. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  94392. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  94393. */
  94394. export class AnaglyphFreeCamera extends FreeCamera {
  94395. /**
  94396. * Creates a new AnaglyphFreeCamera
  94397. * @param name defines camera name
  94398. * @param position defines initial position
  94399. * @param interaxialDistance defines distance between each color axis
  94400. * @param scene defines the hosting scene
  94401. */
  94402. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  94403. /**
  94404. * Gets camera class name
  94405. * @returns AnaglyphFreeCamera
  94406. */
  94407. getClassName(): string;
  94408. }
  94409. }
  94410. declare module BABYLON {
  94411. /**
  94412. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  94413. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  94414. */
  94415. export class AnaglyphGamepadCamera extends GamepadCamera {
  94416. /**
  94417. * Creates a new AnaglyphGamepadCamera
  94418. * @param name defines camera name
  94419. * @param position defines initial position
  94420. * @param interaxialDistance defines distance between each color axis
  94421. * @param scene defines the hosting scene
  94422. */
  94423. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  94424. /**
  94425. * Gets camera class name
  94426. * @returns AnaglyphGamepadCamera
  94427. */
  94428. getClassName(): string;
  94429. }
  94430. }
  94431. declare module BABYLON {
  94432. /**
  94433. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  94434. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  94435. */
  94436. export class AnaglyphUniversalCamera extends UniversalCamera {
  94437. /**
  94438. * Creates a new AnaglyphUniversalCamera
  94439. * @param name defines camera name
  94440. * @param position defines initial position
  94441. * @param interaxialDistance defines distance between each color axis
  94442. * @param scene defines the hosting scene
  94443. */
  94444. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  94445. /**
  94446. * Gets camera class name
  94447. * @returns AnaglyphUniversalCamera
  94448. */
  94449. getClassName(): string;
  94450. }
  94451. }
  94452. declare module BABYLON {
  94453. /** @hidden */
  94454. export var stereoscopicInterlacePixelShader: {
  94455. name: string;
  94456. shader: string;
  94457. };
  94458. }
  94459. declare module BABYLON {
  94460. /**
  94461. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  94462. */
  94463. export class StereoscopicInterlacePostProcess extends PostProcess {
  94464. private _stepSize;
  94465. private _passedProcess;
  94466. /**
  94467. * Initializes a StereoscopicInterlacePostProcess
  94468. * @param name The name of the effect.
  94469. * @param rigCameras The rig cameras to be appled to the post process
  94470. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  94471. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  94472. * @param engine The engine which the post process will be applied. (default: current engine)
  94473. * @param reusable If the post process can be reused on the same frame. (default: false)
  94474. */
  94475. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  94476. }
  94477. }
  94478. declare module BABYLON {
  94479. /**
  94480. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  94481. * @see http://doc.babylonjs.com/features/cameras
  94482. */
  94483. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  94484. /**
  94485. * Creates a new StereoscopicArcRotateCamera
  94486. * @param name defines camera name
  94487. * @param alpha defines alpha angle (in radians)
  94488. * @param beta defines beta angle (in radians)
  94489. * @param radius defines radius
  94490. * @param target defines camera target
  94491. * @param interaxialDistance defines distance between each color axis
  94492. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  94493. * @param scene defines the hosting scene
  94494. */
  94495. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  94496. /**
  94497. * Gets camera class name
  94498. * @returns StereoscopicArcRotateCamera
  94499. */
  94500. getClassName(): string;
  94501. }
  94502. }
  94503. declare module BABYLON {
  94504. /**
  94505. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  94506. * @see http://doc.babylonjs.com/features/cameras
  94507. */
  94508. export class StereoscopicFreeCamera extends FreeCamera {
  94509. /**
  94510. * Creates a new StereoscopicFreeCamera
  94511. * @param name defines camera name
  94512. * @param position defines initial position
  94513. * @param interaxialDistance defines distance between each color axis
  94514. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  94515. * @param scene defines the hosting scene
  94516. */
  94517. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  94518. /**
  94519. * Gets camera class name
  94520. * @returns StereoscopicFreeCamera
  94521. */
  94522. getClassName(): string;
  94523. }
  94524. }
  94525. declare module BABYLON {
  94526. /**
  94527. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  94528. * @see http://doc.babylonjs.com/features/cameras
  94529. */
  94530. export class StereoscopicGamepadCamera extends GamepadCamera {
  94531. /**
  94532. * Creates a new StereoscopicGamepadCamera
  94533. * @param name defines camera name
  94534. * @param position defines initial position
  94535. * @param interaxialDistance defines distance between each color axis
  94536. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  94537. * @param scene defines the hosting scene
  94538. */
  94539. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  94540. /**
  94541. * Gets camera class name
  94542. * @returns StereoscopicGamepadCamera
  94543. */
  94544. getClassName(): string;
  94545. }
  94546. }
  94547. declare module BABYLON {
  94548. /**
  94549. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  94550. * @see http://doc.babylonjs.com/features/cameras
  94551. */
  94552. export class StereoscopicUniversalCamera extends UniversalCamera {
  94553. /**
  94554. * Creates a new StereoscopicUniversalCamera
  94555. * @param name defines camera name
  94556. * @param position defines initial position
  94557. * @param interaxialDistance defines distance between each color axis
  94558. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  94559. * @param scene defines the hosting scene
  94560. */
  94561. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  94562. /**
  94563. * Gets camera class name
  94564. * @returns StereoscopicUniversalCamera
  94565. */
  94566. getClassName(): string;
  94567. }
  94568. }
  94569. declare module BABYLON {
  94570. /**
  94571. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  94572. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  94573. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  94574. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  94575. */
  94576. export class VirtualJoysticksCamera extends FreeCamera {
  94577. /**
  94578. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  94579. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  94580. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  94581. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  94582. * @param name Define the name of the camera in the scene
  94583. * @param position Define the start position of the camera in the scene
  94584. * @param scene Define the scene the camera belongs to
  94585. */
  94586. constructor(name: string, position: Vector3, scene: Scene);
  94587. /**
  94588. * Gets the current object class name.
  94589. * @return the class name
  94590. */
  94591. getClassName(): string;
  94592. }
  94593. }
  94594. declare module BABYLON {
  94595. /**
  94596. * This represents all the required metrics to create a VR camera.
  94597. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  94598. */
  94599. export class VRCameraMetrics {
  94600. /**
  94601. * Define the horizontal resolution off the screen.
  94602. */
  94603. hResolution: number;
  94604. /**
  94605. * Define the vertical resolution off the screen.
  94606. */
  94607. vResolution: number;
  94608. /**
  94609. * Define the horizontal screen size.
  94610. */
  94611. hScreenSize: number;
  94612. /**
  94613. * Define the vertical screen size.
  94614. */
  94615. vScreenSize: number;
  94616. /**
  94617. * Define the vertical screen center position.
  94618. */
  94619. vScreenCenter: number;
  94620. /**
  94621. * Define the distance of the eyes to the screen.
  94622. */
  94623. eyeToScreenDistance: number;
  94624. /**
  94625. * Define the distance between both lenses
  94626. */
  94627. lensSeparationDistance: number;
  94628. /**
  94629. * Define the distance between both viewer's eyes.
  94630. */
  94631. interpupillaryDistance: number;
  94632. /**
  94633. * Define the distortion factor of the VR postprocess.
  94634. * Please, touch with care.
  94635. */
  94636. distortionK: number[];
  94637. /**
  94638. * Define the chromatic aberration correction factors for the VR post process.
  94639. */
  94640. chromaAbCorrection: number[];
  94641. /**
  94642. * Define the scale factor of the post process.
  94643. * The smaller the better but the slower.
  94644. */
  94645. postProcessScaleFactor: number;
  94646. /**
  94647. * Define an offset for the lens center.
  94648. */
  94649. lensCenterOffset: number;
  94650. /**
  94651. * Define if the current vr camera should compensate the distortion of the lense or not.
  94652. */
  94653. compensateDistortion: boolean;
  94654. /**
  94655. * Gets the rendering aspect ratio based on the provided resolutions.
  94656. */
  94657. readonly aspectRatio: number;
  94658. /**
  94659. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  94660. */
  94661. readonly aspectRatioFov: number;
  94662. /**
  94663. * @hidden
  94664. */
  94665. readonly leftHMatrix: Matrix;
  94666. /**
  94667. * @hidden
  94668. */
  94669. readonly rightHMatrix: Matrix;
  94670. /**
  94671. * @hidden
  94672. */
  94673. readonly leftPreViewMatrix: Matrix;
  94674. /**
  94675. * @hidden
  94676. */
  94677. readonly rightPreViewMatrix: Matrix;
  94678. /**
  94679. * Get the default VRMetrics based on the most generic setup.
  94680. * @returns the default vr metrics
  94681. */
  94682. static GetDefault(): VRCameraMetrics;
  94683. }
  94684. }
  94685. declare module BABYLON {
  94686. /** @hidden */
  94687. export var vrDistortionCorrectionPixelShader: {
  94688. name: string;
  94689. shader: string;
  94690. };
  94691. }
  94692. declare module BABYLON {
  94693. /**
  94694. * VRDistortionCorrectionPostProcess used for mobile VR
  94695. */
  94696. export class VRDistortionCorrectionPostProcess extends PostProcess {
  94697. private _isRightEye;
  94698. private _distortionFactors;
  94699. private _postProcessScaleFactor;
  94700. private _lensCenterOffset;
  94701. private _scaleIn;
  94702. private _scaleFactor;
  94703. private _lensCenter;
  94704. /**
  94705. * Initializes the VRDistortionCorrectionPostProcess
  94706. * @param name The name of the effect.
  94707. * @param camera The camera to apply the render pass to.
  94708. * @param isRightEye If this is for the right eye distortion
  94709. * @param vrMetrics All the required metrics for the VR camera
  94710. */
  94711. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  94712. }
  94713. }
  94714. declare module BABYLON {
  94715. /**
  94716. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  94717. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  94718. */
  94719. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  94720. /**
  94721. * Creates a new VRDeviceOrientationArcRotateCamera
  94722. * @param name defines camera name
  94723. * @param alpha defines the camera rotation along the logitudinal axis
  94724. * @param beta defines the camera rotation along the latitudinal axis
  94725. * @param radius defines the camera distance from its target
  94726. * @param target defines the camera target
  94727. * @param scene defines the scene the camera belongs to
  94728. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  94729. * @param vrCameraMetrics defines the vr metrics associated to the camera
  94730. */
  94731. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  94732. /**
  94733. * Gets camera class name
  94734. * @returns VRDeviceOrientationArcRotateCamera
  94735. */
  94736. getClassName(): string;
  94737. }
  94738. }
  94739. declare module BABYLON {
  94740. /**
  94741. * Camera used to simulate VR rendering (based on FreeCamera)
  94742. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  94743. */
  94744. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  94745. /**
  94746. * Creates a new VRDeviceOrientationFreeCamera
  94747. * @param name defines camera name
  94748. * @param position defines the start position of the camera
  94749. * @param scene defines the scene the camera belongs to
  94750. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  94751. * @param vrCameraMetrics defines the vr metrics associated to the camera
  94752. */
  94753. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  94754. /**
  94755. * Gets camera class name
  94756. * @returns VRDeviceOrientationFreeCamera
  94757. */
  94758. getClassName(): string;
  94759. }
  94760. }
  94761. declare module BABYLON {
  94762. /**
  94763. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  94764. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  94765. */
  94766. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  94767. /**
  94768. * Creates a new VRDeviceOrientationGamepadCamera
  94769. * @param name defines camera name
  94770. * @param position defines the start position of the camera
  94771. * @param scene defines the scene the camera belongs to
  94772. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  94773. * @param vrCameraMetrics defines the vr metrics associated to the camera
  94774. */
  94775. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  94776. /**
  94777. * Gets camera class name
  94778. * @returns VRDeviceOrientationGamepadCamera
  94779. */
  94780. getClassName(): string;
  94781. }
  94782. }
  94783. declare module BABYLON {
  94784. /**
  94785. * Defines supported buttons for XBox360 compatible gamepads
  94786. */
  94787. export enum Xbox360Button {
  94788. /** A */
  94789. A = 0,
  94790. /** B */
  94791. B = 1,
  94792. /** X */
  94793. X = 2,
  94794. /** Y */
  94795. Y = 3,
  94796. /** Start */
  94797. Start = 4,
  94798. /** Back */
  94799. Back = 5,
  94800. /** Left button */
  94801. LB = 6,
  94802. /** Right button */
  94803. RB = 7,
  94804. /** Left stick */
  94805. LeftStick = 8,
  94806. /** Right stick */
  94807. RightStick = 9
  94808. }
  94809. /** Defines values for XBox360 DPad */
  94810. export enum Xbox360Dpad {
  94811. /** Up */
  94812. Up = 0,
  94813. /** Down */
  94814. Down = 1,
  94815. /** Left */
  94816. Left = 2,
  94817. /** Right */
  94818. Right = 3
  94819. }
  94820. /**
  94821. * Defines a XBox360 gamepad
  94822. */
  94823. export class Xbox360Pad extends Gamepad {
  94824. private _leftTrigger;
  94825. private _rightTrigger;
  94826. private _onlefttriggerchanged;
  94827. private _onrighttriggerchanged;
  94828. private _onbuttondown;
  94829. private _onbuttonup;
  94830. private _ondpaddown;
  94831. private _ondpadup;
  94832. /** Observable raised when a button is pressed */
  94833. onButtonDownObservable: Observable<Xbox360Button>;
  94834. /** Observable raised when a button is released */
  94835. onButtonUpObservable: Observable<Xbox360Button>;
  94836. /** Observable raised when a pad is pressed */
  94837. onPadDownObservable: Observable<Xbox360Dpad>;
  94838. /** Observable raised when a pad is released */
  94839. onPadUpObservable: Observable<Xbox360Dpad>;
  94840. private _buttonA;
  94841. private _buttonB;
  94842. private _buttonX;
  94843. private _buttonY;
  94844. private _buttonBack;
  94845. private _buttonStart;
  94846. private _buttonLB;
  94847. private _buttonRB;
  94848. private _buttonLeftStick;
  94849. private _buttonRightStick;
  94850. private _dPadUp;
  94851. private _dPadDown;
  94852. private _dPadLeft;
  94853. private _dPadRight;
  94854. private _isXboxOnePad;
  94855. /**
  94856. * Creates a new XBox360 gamepad object
  94857. * @param id defines the id of this gamepad
  94858. * @param index defines its index
  94859. * @param gamepad defines the internal HTML gamepad object
  94860. * @param xboxOne defines if it is a XBox One gamepad
  94861. */
  94862. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  94863. /**
  94864. * Defines the callback to call when left trigger is pressed
  94865. * @param callback defines the callback to use
  94866. */
  94867. onlefttriggerchanged(callback: (value: number) => void): void;
  94868. /**
  94869. * Defines the callback to call when right trigger is pressed
  94870. * @param callback defines the callback to use
  94871. */
  94872. onrighttriggerchanged(callback: (value: number) => void): void;
  94873. /**
  94874. * Gets the left trigger value
  94875. */
  94876. /**
  94877. * Sets the left trigger value
  94878. */
  94879. leftTrigger: number;
  94880. /**
  94881. * Gets the right trigger value
  94882. */
  94883. /**
  94884. * Sets the right trigger value
  94885. */
  94886. rightTrigger: number;
  94887. /**
  94888. * Defines the callback to call when a button is pressed
  94889. * @param callback defines the callback to use
  94890. */
  94891. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  94892. /**
  94893. * Defines the callback to call when a button is released
  94894. * @param callback defines the callback to use
  94895. */
  94896. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  94897. /**
  94898. * Defines the callback to call when a pad is pressed
  94899. * @param callback defines the callback to use
  94900. */
  94901. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  94902. /**
  94903. * Defines the callback to call when a pad is released
  94904. * @param callback defines the callback to use
  94905. */
  94906. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  94907. private _setButtonValue;
  94908. private _setDPadValue;
  94909. /**
  94910. * Gets the value of the `A` button
  94911. */
  94912. /**
  94913. * Sets the value of the `A` button
  94914. */
  94915. buttonA: number;
  94916. /**
  94917. * Gets the value of the `B` button
  94918. */
  94919. /**
  94920. * Sets the value of the `B` button
  94921. */
  94922. buttonB: number;
  94923. /**
  94924. * Gets the value of the `X` button
  94925. */
  94926. /**
  94927. * Sets the value of the `X` button
  94928. */
  94929. buttonX: number;
  94930. /**
  94931. * Gets the value of the `Y` button
  94932. */
  94933. /**
  94934. * Sets the value of the `Y` button
  94935. */
  94936. buttonY: number;
  94937. /**
  94938. * Gets the value of the `Start` button
  94939. */
  94940. /**
  94941. * Sets the value of the `Start` button
  94942. */
  94943. buttonStart: number;
  94944. /**
  94945. * Gets the value of the `Back` button
  94946. */
  94947. /**
  94948. * Sets the value of the `Back` button
  94949. */
  94950. buttonBack: number;
  94951. /**
  94952. * Gets the value of the `Left` button
  94953. */
  94954. /**
  94955. * Sets the value of the `Left` button
  94956. */
  94957. buttonLB: number;
  94958. /**
  94959. * Gets the value of the `Right` button
  94960. */
  94961. /**
  94962. * Sets the value of the `Right` button
  94963. */
  94964. buttonRB: number;
  94965. /**
  94966. * Gets the value of the Left joystick
  94967. */
  94968. /**
  94969. * Sets the value of the Left joystick
  94970. */
  94971. buttonLeftStick: number;
  94972. /**
  94973. * Gets the value of the Right joystick
  94974. */
  94975. /**
  94976. * Sets the value of the Right joystick
  94977. */
  94978. buttonRightStick: number;
  94979. /**
  94980. * Gets the value of D-pad up
  94981. */
  94982. /**
  94983. * Sets the value of D-pad up
  94984. */
  94985. dPadUp: number;
  94986. /**
  94987. * Gets the value of D-pad down
  94988. */
  94989. /**
  94990. * Sets the value of D-pad down
  94991. */
  94992. dPadDown: number;
  94993. /**
  94994. * Gets the value of D-pad left
  94995. */
  94996. /**
  94997. * Sets the value of D-pad left
  94998. */
  94999. dPadLeft: number;
  95000. /**
  95001. * Gets the value of D-pad right
  95002. */
  95003. /**
  95004. * Sets the value of D-pad right
  95005. */
  95006. dPadRight: number;
  95007. /**
  95008. * Force the gamepad to synchronize with device values
  95009. */
  95010. update(): void;
  95011. /**
  95012. * Disposes the gamepad
  95013. */
  95014. dispose(): void;
  95015. }
  95016. }
  95017. declare module BABYLON {
  95018. /**
  95019. * Base class of materials working in push mode in babylon JS
  95020. * @hidden
  95021. */
  95022. export class PushMaterial extends Material {
  95023. protected _activeEffect: Effect;
  95024. protected _normalMatrix: Matrix;
  95025. /**
  95026. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  95027. * This means that the material can keep using a previous shader while a new one is being compiled.
  95028. * This is mostly used when shader parallel compilation is supported (true by default)
  95029. */
  95030. allowShaderHotSwapping: boolean;
  95031. constructor(name: string, scene: Scene);
  95032. getEffect(): Effect;
  95033. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  95034. /**
  95035. * Binds the given world matrix to the active effect
  95036. *
  95037. * @param world the matrix to bind
  95038. */
  95039. bindOnlyWorldMatrix(world: Matrix): void;
  95040. /**
  95041. * Binds the given normal matrix to the active effect
  95042. *
  95043. * @param normalMatrix the matrix to bind
  95044. */
  95045. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  95046. bind(world: Matrix, mesh?: Mesh): void;
  95047. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  95048. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  95049. }
  95050. }
  95051. declare module BABYLON {
  95052. /**
  95053. * This groups all the flags used to control the materials channel.
  95054. */
  95055. export class MaterialFlags {
  95056. private static _DiffuseTextureEnabled;
  95057. /**
  95058. * Are diffuse textures enabled in the application.
  95059. */
  95060. static DiffuseTextureEnabled: boolean;
  95061. private static _AmbientTextureEnabled;
  95062. /**
  95063. * Are ambient textures enabled in the application.
  95064. */
  95065. static AmbientTextureEnabled: boolean;
  95066. private static _OpacityTextureEnabled;
  95067. /**
  95068. * Are opacity textures enabled in the application.
  95069. */
  95070. static OpacityTextureEnabled: boolean;
  95071. private static _ReflectionTextureEnabled;
  95072. /**
  95073. * Are reflection textures enabled in the application.
  95074. */
  95075. static ReflectionTextureEnabled: boolean;
  95076. private static _EmissiveTextureEnabled;
  95077. /**
  95078. * Are emissive textures enabled in the application.
  95079. */
  95080. static EmissiveTextureEnabled: boolean;
  95081. private static _SpecularTextureEnabled;
  95082. /**
  95083. * Are specular textures enabled in the application.
  95084. */
  95085. static SpecularTextureEnabled: boolean;
  95086. private static _BumpTextureEnabled;
  95087. /**
  95088. * Are bump textures enabled in the application.
  95089. */
  95090. static BumpTextureEnabled: boolean;
  95091. private static _LightmapTextureEnabled;
  95092. /**
  95093. * Are lightmap textures enabled in the application.
  95094. */
  95095. static LightmapTextureEnabled: boolean;
  95096. private static _RefractionTextureEnabled;
  95097. /**
  95098. * Are refraction textures enabled in the application.
  95099. */
  95100. static RefractionTextureEnabled: boolean;
  95101. private static _ColorGradingTextureEnabled;
  95102. /**
  95103. * Are color grading textures enabled in the application.
  95104. */
  95105. static ColorGradingTextureEnabled: boolean;
  95106. private static _FresnelEnabled;
  95107. /**
  95108. * Are fresnels enabled in the application.
  95109. */
  95110. static FresnelEnabled: boolean;
  95111. private static _ClearCoatTextureEnabled;
  95112. /**
  95113. * Are clear coat textures enabled in the application.
  95114. */
  95115. static ClearCoatTextureEnabled: boolean;
  95116. private static _ClearCoatBumpTextureEnabled;
  95117. /**
  95118. * Are clear coat bump textures enabled in the application.
  95119. */
  95120. static ClearCoatBumpTextureEnabled: boolean;
  95121. private static _ClearCoatTintTextureEnabled;
  95122. /**
  95123. * Are clear coat tint textures enabled in the application.
  95124. */
  95125. static ClearCoatTintTextureEnabled: boolean;
  95126. private static _SheenTextureEnabled;
  95127. /**
  95128. * Are sheen textures enabled in the application.
  95129. */
  95130. static SheenTextureEnabled: boolean;
  95131. private static _AnisotropicTextureEnabled;
  95132. /**
  95133. * Are anisotropic textures enabled in the application.
  95134. */
  95135. static AnisotropicTextureEnabled: boolean;
  95136. }
  95137. }
  95138. declare module BABYLON {
  95139. /** @hidden */
  95140. export var defaultFragmentDeclaration: {
  95141. name: string;
  95142. shader: string;
  95143. };
  95144. }
  95145. declare module BABYLON {
  95146. /** @hidden */
  95147. export var defaultUboDeclaration: {
  95148. name: string;
  95149. shader: string;
  95150. };
  95151. }
  95152. declare module BABYLON {
  95153. /** @hidden */
  95154. export var lightFragmentDeclaration: {
  95155. name: string;
  95156. shader: string;
  95157. };
  95158. }
  95159. declare module BABYLON {
  95160. /** @hidden */
  95161. export var lightUboDeclaration: {
  95162. name: string;
  95163. shader: string;
  95164. };
  95165. }
  95166. declare module BABYLON {
  95167. /** @hidden */
  95168. export var lightsFragmentFunctions: {
  95169. name: string;
  95170. shader: string;
  95171. };
  95172. }
  95173. declare module BABYLON {
  95174. /** @hidden */
  95175. export var shadowsFragmentFunctions: {
  95176. name: string;
  95177. shader: string;
  95178. };
  95179. }
  95180. declare module BABYLON {
  95181. /** @hidden */
  95182. export var fresnelFunction: {
  95183. name: string;
  95184. shader: string;
  95185. };
  95186. }
  95187. declare module BABYLON {
  95188. /** @hidden */
  95189. export var reflectionFunction: {
  95190. name: string;
  95191. shader: string;
  95192. };
  95193. }
  95194. declare module BABYLON {
  95195. /** @hidden */
  95196. export var bumpFragmentFunctions: {
  95197. name: string;
  95198. shader: string;
  95199. };
  95200. }
  95201. declare module BABYLON {
  95202. /** @hidden */
  95203. export var logDepthDeclaration: {
  95204. name: string;
  95205. shader: string;
  95206. };
  95207. }
  95208. declare module BABYLON {
  95209. /** @hidden */
  95210. export var bumpFragment: {
  95211. name: string;
  95212. shader: string;
  95213. };
  95214. }
  95215. declare module BABYLON {
  95216. /** @hidden */
  95217. export var depthPrePass: {
  95218. name: string;
  95219. shader: string;
  95220. };
  95221. }
  95222. declare module BABYLON {
  95223. /** @hidden */
  95224. export var lightFragment: {
  95225. name: string;
  95226. shader: string;
  95227. };
  95228. }
  95229. declare module BABYLON {
  95230. /** @hidden */
  95231. export var logDepthFragment: {
  95232. name: string;
  95233. shader: string;
  95234. };
  95235. }
  95236. declare module BABYLON {
  95237. /** @hidden */
  95238. export var defaultPixelShader: {
  95239. name: string;
  95240. shader: string;
  95241. };
  95242. }
  95243. declare module BABYLON {
  95244. /** @hidden */
  95245. export var defaultVertexDeclaration: {
  95246. name: string;
  95247. shader: string;
  95248. };
  95249. }
  95250. declare module BABYLON {
  95251. /** @hidden */
  95252. export var bumpVertexDeclaration: {
  95253. name: string;
  95254. shader: string;
  95255. };
  95256. }
  95257. declare module BABYLON {
  95258. /** @hidden */
  95259. export var bumpVertex: {
  95260. name: string;
  95261. shader: string;
  95262. };
  95263. }
  95264. declare module BABYLON {
  95265. /** @hidden */
  95266. export var fogVertex: {
  95267. name: string;
  95268. shader: string;
  95269. };
  95270. }
  95271. declare module BABYLON {
  95272. /** @hidden */
  95273. export var shadowsVertex: {
  95274. name: string;
  95275. shader: string;
  95276. };
  95277. }
  95278. declare module BABYLON {
  95279. /** @hidden */
  95280. export var pointCloudVertex: {
  95281. name: string;
  95282. shader: string;
  95283. };
  95284. }
  95285. declare module BABYLON {
  95286. /** @hidden */
  95287. export var logDepthVertex: {
  95288. name: string;
  95289. shader: string;
  95290. };
  95291. }
  95292. declare module BABYLON {
  95293. /** @hidden */
  95294. export var defaultVertexShader: {
  95295. name: string;
  95296. shader: string;
  95297. };
  95298. }
  95299. declare module BABYLON {
  95300. /** @hidden */
  95301. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  95302. MAINUV1: boolean;
  95303. MAINUV2: boolean;
  95304. DIFFUSE: boolean;
  95305. DIFFUSEDIRECTUV: number;
  95306. AMBIENT: boolean;
  95307. AMBIENTDIRECTUV: number;
  95308. OPACITY: boolean;
  95309. OPACITYDIRECTUV: number;
  95310. OPACITYRGB: boolean;
  95311. REFLECTION: boolean;
  95312. EMISSIVE: boolean;
  95313. EMISSIVEDIRECTUV: number;
  95314. SPECULAR: boolean;
  95315. SPECULARDIRECTUV: number;
  95316. BUMP: boolean;
  95317. BUMPDIRECTUV: number;
  95318. PARALLAX: boolean;
  95319. PARALLAXOCCLUSION: boolean;
  95320. SPECULAROVERALPHA: boolean;
  95321. CLIPPLANE: boolean;
  95322. CLIPPLANE2: boolean;
  95323. CLIPPLANE3: boolean;
  95324. CLIPPLANE4: boolean;
  95325. ALPHATEST: boolean;
  95326. DEPTHPREPASS: boolean;
  95327. ALPHAFROMDIFFUSE: boolean;
  95328. POINTSIZE: boolean;
  95329. FOG: boolean;
  95330. SPECULARTERM: boolean;
  95331. DIFFUSEFRESNEL: boolean;
  95332. OPACITYFRESNEL: boolean;
  95333. REFLECTIONFRESNEL: boolean;
  95334. REFRACTIONFRESNEL: boolean;
  95335. EMISSIVEFRESNEL: boolean;
  95336. FRESNEL: boolean;
  95337. NORMAL: boolean;
  95338. UV1: boolean;
  95339. UV2: boolean;
  95340. VERTEXCOLOR: boolean;
  95341. VERTEXALPHA: boolean;
  95342. NUM_BONE_INFLUENCERS: number;
  95343. BonesPerMesh: number;
  95344. BONETEXTURE: boolean;
  95345. INSTANCES: boolean;
  95346. GLOSSINESS: boolean;
  95347. ROUGHNESS: boolean;
  95348. EMISSIVEASILLUMINATION: boolean;
  95349. LINKEMISSIVEWITHDIFFUSE: boolean;
  95350. REFLECTIONFRESNELFROMSPECULAR: boolean;
  95351. LIGHTMAP: boolean;
  95352. LIGHTMAPDIRECTUV: number;
  95353. OBJECTSPACE_NORMALMAP: boolean;
  95354. USELIGHTMAPASSHADOWMAP: boolean;
  95355. REFLECTIONMAP_3D: boolean;
  95356. REFLECTIONMAP_SPHERICAL: boolean;
  95357. REFLECTIONMAP_PLANAR: boolean;
  95358. REFLECTIONMAP_CUBIC: boolean;
  95359. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  95360. REFLECTIONMAP_PROJECTION: boolean;
  95361. REFLECTIONMAP_SKYBOX: boolean;
  95362. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  95363. REFLECTIONMAP_EXPLICIT: boolean;
  95364. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  95365. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  95366. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  95367. INVERTCUBICMAP: boolean;
  95368. LOGARITHMICDEPTH: boolean;
  95369. REFRACTION: boolean;
  95370. REFRACTIONMAP_3D: boolean;
  95371. REFLECTIONOVERALPHA: boolean;
  95372. TWOSIDEDLIGHTING: boolean;
  95373. SHADOWFLOAT: boolean;
  95374. MORPHTARGETS: boolean;
  95375. MORPHTARGETS_NORMAL: boolean;
  95376. MORPHTARGETS_TANGENT: boolean;
  95377. NUM_MORPH_INFLUENCERS: number;
  95378. NONUNIFORMSCALING: boolean;
  95379. PREMULTIPLYALPHA: boolean;
  95380. IMAGEPROCESSING: boolean;
  95381. VIGNETTE: boolean;
  95382. VIGNETTEBLENDMODEMULTIPLY: boolean;
  95383. VIGNETTEBLENDMODEOPAQUE: boolean;
  95384. TONEMAPPING: boolean;
  95385. TONEMAPPING_ACES: boolean;
  95386. CONTRAST: boolean;
  95387. COLORCURVES: boolean;
  95388. COLORGRADING: boolean;
  95389. COLORGRADING3D: boolean;
  95390. SAMPLER3DGREENDEPTH: boolean;
  95391. SAMPLER3DBGRMAP: boolean;
  95392. IMAGEPROCESSINGPOSTPROCESS: boolean;
  95393. /**
  95394. * If the reflection texture on this material is in linear color space
  95395. * @hidden
  95396. */
  95397. IS_REFLECTION_LINEAR: boolean;
  95398. /**
  95399. * If the refraction texture on this material is in linear color space
  95400. * @hidden
  95401. */
  95402. IS_REFRACTION_LINEAR: boolean;
  95403. EXPOSURE: boolean;
  95404. constructor();
  95405. setReflectionMode(modeToEnable: string): void;
  95406. }
  95407. /**
  95408. * This is the default material used in Babylon. It is the best trade off between quality
  95409. * and performances.
  95410. * @see http://doc.babylonjs.com/babylon101/materials
  95411. */
  95412. export class StandardMaterial extends PushMaterial {
  95413. private _diffuseTexture;
  95414. /**
  95415. * The basic texture of the material as viewed under a light.
  95416. */
  95417. diffuseTexture: Nullable<BaseTexture>;
  95418. private _ambientTexture;
  95419. /**
  95420. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  95421. */
  95422. ambientTexture: Nullable<BaseTexture>;
  95423. private _opacityTexture;
  95424. /**
  95425. * Define the transparency of the material from a texture.
  95426. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  95427. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  95428. */
  95429. opacityTexture: Nullable<BaseTexture>;
  95430. private _reflectionTexture;
  95431. /**
  95432. * Define the texture used to display the reflection.
  95433. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  95434. */
  95435. reflectionTexture: Nullable<BaseTexture>;
  95436. private _emissiveTexture;
  95437. /**
  95438. * Define texture of the material as if self lit.
  95439. * This will be mixed in the final result even in the absence of light.
  95440. */
  95441. emissiveTexture: Nullable<BaseTexture>;
  95442. private _specularTexture;
  95443. /**
  95444. * Define how the color and intensity of the highlight given by the light in the material.
  95445. */
  95446. specularTexture: Nullable<BaseTexture>;
  95447. private _bumpTexture;
  95448. /**
  95449. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  95450. * 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.
  95451. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  95452. */
  95453. bumpTexture: Nullable<BaseTexture>;
  95454. private _lightmapTexture;
  95455. /**
  95456. * Complex lighting can be computationally expensive to compute at runtime.
  95457. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  95458. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  95459. */
  95460. lightmapTexture: Nullable<BaseTexture>;
  95461. private _refractionTexture;
  95462. /**
  95463. * Define the texture used to display the refraction.
  95464. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  95465. */
  95466. refractionTexture: Nullable<BaseTexture>;
  95467. /**
  95468. * The color of the material lit by the environmental background lighting.
  95469. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  95470. */
  95471. ambientColor: Color3;
  95472. /**
  95473. * The basic color of the material as viewed under a light.
  95474. */
  95475. diffuseColor: Color3;
  95476. /**
  95477. * Define how the color and intensity of the highlight given by the light in the material.
  95478. */
  95479. specularColor: Color3;
  95480. /**
  95481. * Define the color of the material as if self lit.
  95482. * This will be mixed in the final result even in the absence of light.
  95483. */
  95484. emissiveColor: Color3;
  95485. /**
  95486. * Defines how sharp are the highlights in the material.
  95487. * The bigger the value the sharper giving a more glossy feeling to the result.
  95488. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  95489. */
  95490. specularPower: number;
  95491. private _useAlphaFromDiffuseTexture;
  95492. /**
  95493. * Does the transparency come from the diffuse texture alpha channel.
  95494. */
  95495. useAlphaFromDiffuseTexture: boolean;
  95496. private _useEmissiveAsIllumination;
  95497. /**
  95498. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  95499. */
  95500. useEmissiveAsIllumination: boolean;
  95501. private _linkEmissiveWithDiffuse;
  95502. /**
  95503. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  95504. * the emissive level when the final color is close to one.
  95505. */
  95506. linkEmissiveWithDiffuse: boolean;
  95507. private _useSpecularOverAlpha;
  95508. /**
  95509. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  95510. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  95511. */
  95512. useSpecularOverAlpha: boolean;
  95513. private _useReflectionOverAlpha;
  95514. /**
  95515. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  95516. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  95517. */
  95518. useReflectionOverAlpha: boolean;
  95519. private _disableLighting;
  95520. /**
  95521. * Does lights from the scene impacts this material.
  95522. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  95523. */
  95524. disableLighting: boolean;
  95525. private _useObjectSpaceNormalMap;
  95526. /**
  95527. * Allows using an object space normal map (instead of tangent space).
  95528. */
  95529. useObjectSpaceNormalMap: boolean;
  95530. private _useParallax;
  95531. /**
  95532. * Is parallax enabled or not.
  95533. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  95534. */
  95535. useParallax: boolean;
  95536. private _useParallaxOcclusion;
  95537. /**
  95538. * Is parallax occlusion enabled or not.
  95539. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  95540. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  95541. */
  95542. useParallaxOcclusion: boolean;
  95543. /**
  95544. * 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.
  95545. */
  95546. parallaxScaleBias: number;
  95547. private _roughness;
  95548. /**
  95549. * Helps to define how blurry the reflections should appears in the material.
  95550. */
  95551. roughness: number;
  95552. /**
  95553. * In case of refraction, define the value of the indice of refraction.
  95554. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  95555. */
  95556. indexOfRefraction: number;
  95557. /**
  95558. * Invert the refraction texture alongside the y axis.
  95559. * It can be useful with procedural textures or probe for instance.
  95560. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  95561. */
  95562. invertRefractionY: boolean;
  95563. /**
  95564. * Defines the alpha limits in alpha test mode.
  95565. */
  95566. alphaCutOff: number;
  95567. private _useLightmapAsShadowmap;
  95568. /**
  95569. * In case of light mapping, define whether the map contains light or shadow informations.
  95570. */
  95571. useLightmapAsShadowmap: boolean;
  95572. private _diffuseFresnelParameters;
  95573. /**
  95574. * Define the diffuse fresnel parameters of the material.
  95575. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  95576. */
  95577. diffuseFresnelParameters: FresnelParameters;
  95578. private _opacityFresnelParameters;
  95579. /**
  95580. * Define the opacity fresnel parameters of the material.
  95581. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  95582. */
  95583. opacityFresnelParameters: FresnelParameters;
  95584. private _reflectionFresnelParameters;
  95585. /**
  95586. * Define the reflection fresnel parameters of the material.
  95587. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  95588. */
  95589. reflectionFresnelParameters: FresnelParameters;
  95590. private _refractionFresnelParameters;
  95591. /**
  95592. * Define the refraction fresnel parameters of the material.
  95593. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  95594. */
  95595. refractionFresnelParameters: FresnelParameters;
  95596. private _emissiveFresnelParameters;
  95597. /**
  95598. * Define the emissive fresnel parameters of the material.
  95599. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  95600. */
  95601. emissiveFresnelParameters: FresnelParameters;
  95602. private _useReflectionFresnelFromSpecular;
  95603. /**
  95604. * If true automatically deducts the fresnels values from the material specularity.
  95605. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  95606. */
  95607. useReflectionFresnelFromSpecular: boolean;
  95608. private _useGlossinessFromSpecularMapAlpha;
  95609. /**
  95610. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  95611. */
  95612. useGlossinessFromSpecularMapAlpha: boolean;
  95613. private _maxSimultaneousLights;
  95614. /**
  95615. * Defines the maximum number of lights that can be used in the material
  95616. */
  95617. maxSimultaneousLights: number;
  95618. private _invertNormalMapX;
  95619. /**
  95620. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  95621. */
  95622. invertNormalMapX: boolean;
  95623. private _invertNormalMapY;
  95624. /**
  95625. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  95626. */
  95627. invertNormalMapY: boolean;
  95628. private _twoSidedLighting;
  95629. /**
  95630. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  95631. */
  95632. twoSidedLighting: boolean;
  95633. /**
  95634. * Default configuration related to image processing available in the standard Material.
  95635. */
  95636. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  95637. /**
  95638. * Gets the image processing configuration used either in this material.
  95639. */
  95640. /**
  95641. * Sets the Default image processing configuration used either in the this material.
  95642. *
  95643. * If sets to null, the scene one is in use.
  95644. */
  95645. imageProcessingConfiguration: ImageProcessingConfiguration;
  95646. /**
  95647. * Keep track of the image processing observer to allow dispose and replace.
  95648. */
  95649. private _imageProcessingObserver;
  95650. /**
  95651. * Attaches a new image processing configuration to the Standard Material.
  95652. * @param configuration
  95653. */
  95654. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  95655. /**
  95656. * Gets wether the color curves effect is enabled.
  95657. */
  95658. /**
  95659. * Sets wether the color curves effect is enabled.
  95660. */
  95661. cameraColorCurvesEnabled: boolean;
  95662. /**
  95663. * Gets wether the color grading effect is enabled.
  95664. */
  95665. /**
  95666. * Gets wether the color grading effect is enabled.
  95667. */
  95668. cameraColorGradingEnabled: boolean;
  95669. /**
  95670. * Gets wether tonemapping is enabled or not.
  95671. */
  95672. /**
  95673. * Sets wether tonemapping is enabled or not
  95674. */
  95675. cameraToneMappingEnabled: boolean;
  95676. /**
  95677. * The camera exposure used on this material.
  95678. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  95679. * This corresponds to a photographic exposure.
  95680. */
  95681. /**
  95682. * The camera exposure used on this material.
  95683. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  95684. * This corresponds to a photographic exposure.
  95685. */
  95686. cameraExposure: number;
  95687. /**
  95688. * Gets The camera contrast used on this material.
  95689. */
  95690. /**
  95691. * Sets The camera contrast used on this material.
  95692. */
  95693. cameraContrast: number;
  95694. /**
  95695. * Gets the Color Grading 2D Lookup Texture.
  95696. */
  95697. /**
  95698. * Sets the Color Grading 2D Lookup Texture.
  95699. */
  95700. cameraColorGradingTexture: Nullable<BaseTexture>;
  95701. /**
  95702. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  95703. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  95704. * 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;
  95705. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  95706. */
  95707. /**
  95708. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  95709. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  95710. * 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;
  95711. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  95712. */
  95713. cameraColorCurves: Nullable<ColorCurves>;
  95714. /**
  95715. * Custom callback helping to override the default shader used in the material.
  95716. */
  95717. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  95718. protected _renderTargets: SmartArray<RenderTargetTexture>;
  95719. protected _worldViewProjectionMatrix: Matrix;
  95720. protected _globalAmbientColor: Color3;
  95721. protected _useLogarithmicDepth: boolean;
  95722. /**
  95723. * Instantiates a new standard material.
  95724. * This is the default material used in Babylon. It is the best trade off between quality
  95725. * and performances.
  95726. * @see http://doc.babylonjs.com/babylon101/materials
  95727. * @param name Define the name of the material in the scene
  95728. * @param scene Define the scene the material belong to
  95729. */
  95730. constructor(name: string, scene: Scene);
  95731. /**
  95732. * Gets a boolean indicating that current material needs to register RTT
  95733. */
  95734. readonly hasRenderTargetTextures: boolean;
  95735. /**
  95736. * Gets the current class name of the material e.g. "StandardMaterial"
  95737. * Mainly use in serialization.
  95738. * @returns the class name
  95739. */
  95740. getClassName(): string;
  95741. /**
  95742. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  95743. * You can try switching to logarithmic depth.
  95744. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  95745. */
  95746. useLogarithmicDepth: boolean;
  95747. /**
  95748. * Specifies if the material will require alpha blending
  95749. * @returns a boolean specifying if alpha blending is needed
  95750. */
  95751. needAlphaBlending(): boolean;
  95752. /**
  95753. * Specifies if this material should be rendered in alpha test mode
  95754. * @returns a boolean specifying if an alpha test is needed.
  95755. */
  95756. needAlphaTesting(): boolean;
  95757. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  95758. /**
  95759. * Get the texture used for alpha test purpose.
  95760. * @returns the diffuse texture in case of the standard material.
  95761. */
  95762. getAlphaTestTexture(): Nullable<BaseTexture>;
  95763. /**
  95764. * Get if the submesh is ready to be used and all its information available.
  95765. * Child classes can use it to update shaders
  95766. * @param mesh defines the mesh to check
  95767. * @param subMesh defines which submesh to check
  95768. * @param useInstances specifies that instances should be used
  95769. * @returns a boolean indicating that the submesh is ready or not
  95770. */
  95771. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  95772. /**
  95773. * Builds the material UBO layouts.
  95774. * Used internally during the effect preparation.
  95775. */
  95776. buildUniformLayout(): void;
  95777. /**
  95778. * Unbinds the material from the mesh
  95779. */
  95780. unbind(): void;
  95781. /**
  95782. * Binds the submesh to this material by preparing the effect and shader to draw
  95783. * @param world defines the world transformation matrix
  95784. * @param mesh defines the mesh containing the submesh
  95785. * @param subMesh defines the submesh to bind the material to
  95786. */
  95787. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  95788. /**
  95789. * Get the list of animatables in the material.
  95790. * @returns the list of animatables object used in the material
  95791. */
  95792. getAnimatables(): IAnimatable[];
  95793. /**
  95794. * Gets the active textures from the material
  95795. * @returns an array of textures
  95796. */
  95797. getActiveTextures(): BaseTexture[];
  95798. /**
  95799. * Specifies if the material uses a texture
  95800. * @param texture defines the texture to check against the material
  95801. * @returns a boolean specifying if the material uses the texture
  95802. */
  95803. hasTexture(texture: BaseTexture): boolean;
  95804. /**
  95805. * Disposes the material
  95806. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  95807. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  95808. */
  95809. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  95810. /**
  95811. * Makes a duplicate of the material, and gives it a new name
  95812. * @param name defines the new name for the duplicated material
  95813. * @returns the cloned material
  95814. */
  95815. clone(name: string): StandardMaterial;
  95816. /**
  95817. * Serializes this material in a JSON representation
  95818. * @returns the serialized material object
  95819. */
  95820. serialize(): any;
  95821. /**
  95822. * Creates a standard material from parsed material data
  95823. * @param source defines the JSON representation of the material
  95824. * @param scene defines the hosting scene
  95825. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  95826. * @returns a new standard material
  95827. */
  95828. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  95829. /**
  95830. * Are diffuse textures enabled in the application.
  95831. */
  95832. static DiffuseTextureEnabled: boolean;
  95833. /**
  95834. * Are ambient textures enabled in the application.
  95835. */
  95836. static AmbientTextureEnabled: boolean;
  95837. /**
  95838. * Are opacity textures enabled in the application.
  95839. */
  95840. static OpacityTextureEnabled: boolean;
  95841. /**
  95842. * Are reflection textures enabled in the application.
  95843. */
  95844. static ReflectionTextureEnabled: boolean;
  95845. /**
  95846. * Are emissive textures enabled in the application.
  95847. */
  95848. static EmissiveTextureEnabled: boolean;
  95849. /**
  95850. * Are specular textures enabled in the application.
  95851. */
  95852. static SpecularTextureEnabled: boolean;
  95853. /**
  95854. * Are bump textures enabled in the application.
  95855. */
  95856. static BumpTextureEnabled: boolean;
  95857. /**
  95858. * Are lightmap textures enabled in the application.
  95859. */
  95860. static LightmapTextureEnabled: boolean;
  95861. /**
  95862. * Are refraction textures enabled in the application.
  95863. */
  95864. static RefractionTextureEnabled: boolean;
  95865. /**
  95866. * Are color grading textures enabled in the application.
  95867. */
  95868. static ColorGradingTextureEnabled: boolean;
  95869. /**
  95870. * Are fresnels enabled in the application.
  95871. */
  95872. static FresnelEnabled: boolean;
  95873. }
  95874. }
  95875. declare module BABYLON {
  95876. /**
  95877. * A class extending Texture allowing drawing on a texture
  95878. * @see http://doc.babylonjs.com/how_to/dynamictexture
  95879. */
  95880. export class DynamicTexture extends Texture {
  95881. private _generateMipMaps;
  95882. private _canvas;
  95883. private _context;
  95884. private _engine;
  95885. /**
  95886. * Creates a DynamicTexture
  95887. * @param name defines the name of the texture
  95888. * @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
  95889. * @param scene defines the scene where you want the texture
  95890. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  95891. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  95892. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  95893. */
  95894. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  95895. /**
  95896. * Get the current class name of the texture useful for serialization or dynamic coding.
  95897. * @returns "DynamicTexture"
  95898. */
  95899. getClassName(): string;
  95900. /**
  95901. * Gets the current state of canRescale
  95902. */
  95903. readonly canRescale: boolean;
  95904. private _recreate;
  95905. /**
  95906. * Scales the texture
  95907. * @param ratio the scale factor to apply to both width and height
  95908. */
  95909. scale(ratio: number): void;
  95910. /**
  95911. * Resizes the texture
  95912. * @param width the new width
  95913. * @param height the new height
  95914. */
  95915. scaleTo(width: number, height: number): void;
  95916. /**
  95917. * Gets the context of the canvas used by the texture
  95918. * @returns the canvas context of the dynamic texture
  95919. */
  95920. getContext(): CanvasRenderingContext2D;
  95921. /**
  95922. * Clears the texture
  95923. */
  95924. clear(): void;
  95925. /**
  95926. * Updates the texture
  95927. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  95928. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  95929. */
  95930. update(invertY?: boolean, premulAlpha?: boolean): void;
  95931. /**
  95932. * Draws text onto the texture
  95933. * @param text defines the text to be drawn
  95934. * @param x defines the placement of the text from the left
  95935. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  95936. * @param font defines the font to be used with font-style, font-size, font-name
  95937. * @param color defines the color used for the text
  95938. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  95939. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  95940. * @param update defines whether texture is immediately update (default is true)
  95941. */
  95942. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  95943. /**
  95944. * Clones the texture
  95945. * @returns the clone of the texture.
  95946. */
  95947. clone(): DynamicTexture;
  95948. /**
  95949. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  95950. * @returns a serialized dynamic texture object
  95951. */
  95952. serialize(): any;
  95953. /** @hidden */
  95954. _rebuild(): void;
  95955. }
  95956. }
  95957. declare module BABYLON {
  95958. /** @hidden */
  95959. export var imageProcessingPixelShader: {
  95960. name: string;
  95961. shader: string;
  95962. };
  95963. }
  95964. declare module BABYLON {
  95965. /**
  95966. * ImageProcessingPostProcess
  95967. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  95968. */
  95969. export class ImageProcessingPostProcess extends PostProcess {
  95970. /**
  95971. * Default configuration related to image processing available in the PBR Material.
  95972. */
  95973. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  95974. /**
  95975. * Gets the image processing configuration used either in this material.
  95976. */
  95977. /**
  95978. * Sets the Default image processing configuration used either in the this material.
  95979. *
  95980. * If sets to null, the scene one is in use.
  95981. */
  95982. imageProcessingConfiguration: ImageProcessingConfiguration;
  95983. /**
  95984. * Keep track of the image processing observer to allow dispose and replace.
  95985. */
  95986. private _imageProcessingObserver;
  95987. /**
  95988. * Attaches a new image processing configuration to the PBR Material.
  95989. * @param configuration
  95990. */
  95991. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  95992. /**
  95993. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  95994. */
  95995. /**
  95996. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  95997. */
  95998. colorCurves: Nullable<ColorCurves>;
  95999. /**
  96000. * Gets wether the color curves effect is enabled.
  96001. */
  96002. /**
  96003. * Sets wether the color curves effect is enabled.
  96004. */
  96005. colorCurvesEnabled: boolean;
  96006. /**
  96007. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  96008. */
  96009. /**
  96010. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  96011. */
  96012. colorGradingTexture: Nullable<BaseTexture>;
  96013. /**
  96014. * Gets wether the color grading effect is enabled.
  96015. */
  96016. /**
  96017. * Gets wether the color grading effect is enabled.
  96018. */
  96019. colorGradingEnabled: boolean;
  96020. /**
  96021. * Gets exposure used in the effect.
  96022. */
  96023. /**
  96024. * Sets exposure used in the effect.
  96025. */
  96026. exposure: number;
  96027. /**
  96028. * Gets wether tonemapping is enabled or not.
  96029. */
  96030. /**
  96031. * Sets wether tonemapping is enabled or not
  96032. */
  96033. toneMappingEnabled: boolean;
  96034. /**
  96035. * Gets the type of tone mapping effect.
  96036. */
  96037. /**
  96038. * Sets the type of tone mapping effect.
  96039. */
  96040. toneMappingType: number;
  96041. /**
  96042. * Gets contrast used in the effect.
  96043. */
  96044. /**
  96045. * Sets contrast used in the effect.
  96046. */
  96047. contrast: number;
  96048. /**
  96049. * Gets Vignette stretch size.
  96050. */
  96051. /**
  96052. * Sets Vignette stretch size.
  96053. */
  96054. vignetteStretch: number;
  96055. /**
  96056. * Gets Vignette centre X Offset.
  96057. */
  96058. /**
  96059. * Sets Vignette centre X Offset.
  96060. */
  96061. vignetteCentreX: number;
  96062. /**
  96063. * Gets Vignette centre Y Offset.
  96064. */
  96065. /**
  96066. * Sets Vignette centre Y Offset.
  96067. */
  96068. vignetteCentreY: number;
  96069. /**
  96070. * Gets Vignette weight or intensity of the vignette effect.
  96071. */
  96072. /**
  96073. * Sets Vignette weight or intensity of the vignette effect.
  96074. */
  96075. vignetteWeight: number;
  96076. /**
  96077. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  96078. * if vignetteEnabled is set to true.
  96079. */
  96080. /**
  96081. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  96082. * if vignetteEnabled is set to true.
  96083. */
  96084. vignetteColor: Color4;
  96085. /**
  96086. * Gets Camera field of view used by the Vignette effect.
  96087. */
  96088. /**
  96089. * Sets Camera field of view used by the Vignette effect.
  96090. */
  96091. vignetteCameraFov: number;
  96092. /**
  96093. * Gets the vignette blend mode allowing different kind of effect.
  96094. */
  96095. /**
  96096. * Sets the vignette blend mode allowing different kind of effect.
  96097. */
  96098. vignetteBlendMode: number;
  96099. /**
  96100. * Gets wether the vignette effect is enabled.
  96101. */
  96102. /**
  96103. * Sets wether the vignette effect is enabled.
  96104. */
  96105. vignetteEnabled: boolean;
  96106. private _fromLinearSpace;
  96107. /**
  96108. * Gets wether the input of the processing is in Gamma or Linear Space.
  96109. */
  96110. /**
  96111. * Sets wether the input of the processing is in Gamma or Linear Space.
  96112. */
  96113. fromLinearSpace: boolean;
  96114. /**
  96115. * Defines cache preventing GC.
  96116. */
  96117. private _defines;
  96118. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  96119. /**
  96120. * "ImageProcessingPostProcess"
  96121. * @returns "ImageProcessingPostProcess"
  96122. */
  96123. getClassName(): string;
  96124. protected _updateParameters(): void;
  96125. dispose(camera?: Camera): void;
  96126. }
  96127. }
  96128. declare module BABYLON {
  96129. /**
  96130. * Class containing static functions to help procedurally build meshes
  96131. */
  96132. export class GroundBuilder {
  96133. /**
  96134. * Creates a ground mesh
  96135. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  96136. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  96137. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  96138. * @param name defines the name of the mesh
  96139. * @param options defines the options used to create the mesh
  96140. * @param scene defines the hosting scene
  96141. * @returns the ground mesh
  96142. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  96143. */
  96144. static CreateGround(name: string, options: {
  96145. width?: number;
  96146. height?: number;
  96147. subdivisions?: number;
  96148. subdivisionsX?: number;
  96149. subdivisionsY?: number;
  96150. updatable?: boolean;
  96151. }, scene: any): Mesh;
  96152. /**
  96153. * Creates a tiled ground mesh
  96154. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  96155. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  96156. * * 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
  96157. * * 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
  96158. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  96159. * @param name defines the name of the mesh
  96160. * @param options defines the options used to create the mesh
  96161. * @param scene defines the hosting scene
  96162. * @returns the tiled ground mesh
  96163. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  96164. */
  96165. static CreateTiledGround(name: string, options: {
  96166. xmin: number;
  96167. zmin: number;
  96168. xmax: number;
  96169. zmax: number;
  96170. subdivisions?: {
  96171. w: number;
  96172. h: number;
  96173. };
  96174. precision?: {
  96175. w: number;
  96176. h: number;
  96177. };
  96178. updatable?: boolean;
  96179. }, scene: Scene): Mesh;
  96180. /**
  96181. * Creates a ground mesh from a height map
  96182. * * The parameter `url` sets the URL of the height map image resource.
  96183. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  96184. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  96185. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  96186. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  96187. * * 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.
  96188. * * 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).
  96189. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  96190. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  96191. * @param name defines the name of the mesh
  96192. * @param url defines the url to the height map
  96193. * @param options defines the options used to create the mesh
  96194. * @param scene defines the hosting scene
  96195. * @returns the ground mesh
  96196. * @see https://doc.babylonjs.com/babylon101/height_map
  96197. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  96198. */
  96199. static CreateGroundFromHeightMap(name: string, url: string, options: {
  96200. width?: number;
  96201. height?: number;
  96202. subdivisions?: number;
  96203. minHeight?: number;
  96204. maxHeight?: number;
  96205. colorFilter?: Color3;
  96206. alphaFilter?: number;
  96207. updatable?: boolean;
  96208. onReady?: (mesh: GroundMesh) => void;
  96209. }, scene: Scene): GroundMesh;
  96210. }
  96211. }
  96212. declare module BABYLON {
  96213. /**
  96214. * Class containing static functions to help procedurally build meshes
  96215. */
  96216. export class TorusBuilder {
  96217. /**
  96218. * Creates a torus mesh
  96219. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  96220. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  96221. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  96222. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  96223. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  96224. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  96225. * @param name defines the name of the mesh
  96226. * @param options defines the options used to create the mesh
  96227. * @param scene defines the hosting scene
  96228. * @returns the torus mesh
  96229. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  96230. */
  96231. static CreateTorus(name: string, options: {
  96232. diameter?: number;
  96233. thickness?: number;
  96234. tessellation?: number;
  96235. updatable?: boolean;
  96236. sideOrientation?: number;
  96237. frontUVs?: Vector4;
  96238. backUVs?: Vector4;
  96239. }, scene: any): Mesh;
  96240. }
  96241. }
  96242. declare module BABYLON {
  96243. /**
  96244. * Class containing static functions to help procedurally build meshes
  96245. */
  96246. export class CylinderBuilder {
  96247. /**
  96248. * Creates a cylinder or a cone mesh
  96249. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  96250. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  96251. * * 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.
  96252. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  96253. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  96254. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  96255. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  96256. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  96257. * * 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).
  96258. * * 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
  96259. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  96260. * * 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
  96261. * * 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.
  96262. * * If `enclose` is false, a ring surface is one element.
  96263. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  96264. * * 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
  96265. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  96266. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  96267. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  96268. * @param name defines the name of the mesh
  96269. * @param options defines the options used to create the mesh
  96270. * @param scene defines the hosting scene
  96271. * @returns the cylinder mesh
  96272. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  96273. */
  96274. static CreateCylinder(name: string, options: {
  96275. height?: number;
  96276. diameterTop?: number;
  96277. diameterBottom?: number;
  96278. diameter?: number;
  96279. tessellation?: number;
  96280. subdivisions?: number;
  96281. arc?: number;
  96282. faceColors?: Color4[];
  96283. faceUV?: Vector4[];
  96284. updatable?: boolean;
  96285. hasRings?: boolean;
  96286. enclose?: boolean;
  96287. sideOrientation?: number;
  96288. frontUVs?: Vector4;
  96289. backUVs?: Vector4;
  96290. }, scene: any): Mesh;
  96291. }
  96292. }
  96293. declare module BABYLON {
  96294. /**
  96295. * Manager for handling gamepads
  96296. */
  96297. export class GamepadManager {
  96298. private _scene?;
  96299. private _babylonGamepads;
  96300. private _oneGamepadConnected;
  96301. /** @hidden */
  96302. _isMonitoring: boolean;
  96303. private _gamepadEventSupported;
  96304. private _gamepadSupport;
  96305. /**
  96306. * observable to be triggered when the gamepad controller has been connected
  96307. */
  96308. onGamepadConnectedObservable: Observable<Gamepad>;
  96309. /**
  96310. * observable to be triggered when the gamepad controller has been disconnected
  96311. */
  96312. onGamepadDisconnectedObservable: Observable<Gamepad>;
  96313. private _onGamepadConnectedEvent;
  96314. private _onGamepadDisconnectedEvent;
  96315. /**
  96316. * Initializes the gamepad manager
  96317. * @param _scene BabylonJS scene
  96318. */
  96319. constructor(_scene?: Scene | undefined);
  96320. /**
  96321. * The gamepads in the game pad manager
  96322. */
  96323. readonly gamepads: Gamepad[];
  96324. /**
  96325. * Get the gamepad controllers based on type
  96326. * @param type The type of gamepad controller
  96327. * @returns Nullable gamepad
  96328. */
  96329. getGamepadByType(type?: number): Nullable<Gamepad>;
  96330. /**
  96331. * Disposes the gamepad manager
  96332. */
  96333. dispose(): void;
  96334. private _addNewGamepad;
  96335. private _startMonitoringGamepads;
  96336. private _stopMonitoringGamepads;
  96337. /** @hidden */
  96338. _checkGamepadsStatus(): void;
  96339. private _updateGamepadObjects;
  96340. }
  96341. }
  96342. declare module BABYLON {
  96343. interface Scene {
  96344. /** @hidden */
  96345. _gamepadManager: Nullable<GamepadManager>;
  96346. /**
  96347. * Gets the gamepad manager associated with the scene
  96348. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  96349. */
  96350. gamepadManager: GamepadManager;
  96351. }
  96352. /**
  96353. * Interface representing a free camera inputs manager
  96354. */
  96355. interface FreeCameraInputsManager {
  96356. /**
  96357. * Adds gamepad input support to the FreeCameraInputsManager.
  96358. * @returns the FreeCameraInputsManager
  96359. */
  96360. addGamepad(): FreeCameraInputsManager;
  96361. }
  96362. /**
  96363. * Interface representing an arc rotate camera inputs manager
  96364. */
  96365. interface ArcRotateCameraInputsManager {
  96366. /**
  96367. * Adds gamepad input support to the ArcRotateCamera InputManager.
  96368. * @returns the camera inputs manager
  96369. */
  96370. addGamepad(): ArcRotateCameraInputsManager;
  96371. }
  96372. /**
  96373. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  96374. */
  96375. export class GamepadSystemSceneComponent implements ISceneComponent {
  96376. /**
  96377. * The component name helpfull to identify the component in the list of scene components.
  96378. */
  96379. readonly name: string;
  96380. /**
  96381. * The scene the component belongs to.
  96382. */
  96383. scene: Scene;
  96384. /**
  96385. * Creates a new instance of the component for the given scene
  96386. * @param scene Defines the scene to register the component in
  96387. */
  96388. constructor(scene: Scene);
  96389. /**
  96390. * Registers the component in a given scene
  96391. */
  96392. register(): void;
  96393. /**
  96394. * Rebuilds the elements related to this component in case of
  96395. * context lost for instance.
  96396. */
  96397. rebuild(): void;
  96398. /**
  96399. * Disposes the component and the associated ressources
  96400. */
  96401. dispose(): void;
  96402. private _beforeCameraUpdate;
  96403. }
  96404. }
  96405. declare module BABYLON {
  96406. /**
  96407. * Options to modify the vr teleportation behavior.
  96408. */
  96409. export interface VRTeleportationOptions {
  96410. /**
  96411. * The name of the mesh which should be used as the teleportation floor. (default: null)
  96412. */
  96413. floorMeshName?: string;
  96414. /**
  96415. * A list of meshes to be used as the teleportation floor. (default: empty)
  96416. */
  96417. floorMeshes?: Mesh[];
  96418. }
  96419. /**
  96420. * Options to modify the vr experience helper's behavior.
  96421. */
  96422. export interface VRExperienceHelperOptions extends WebVROptions {
  96423. /**
  96424. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  96425. */
  96426. createDeviceOrientationCamera?: boolean;
  96427. /**
  96428. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  96429. */
  96430. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  96431. /**
  96432. * Uses the main button on the controller to toggle the laser casted. (default: true)
  96433. */
  96434. laserToggle?: boolean;
  96435. /**
  96436. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  96437. */
  96438. floorMeshes?: Mesh[];
  96439. /**
  96440. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  96441. */
  96442. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  96443. }
  96444. /**
  96445. * Event containing information after VR has been entered
  96446. */
  96447. export class OnAfterEnteringVRObservableEvent {
  96448. /**
  96449. * If entering vr was successful
  96450. */
  96451. success: boolean;
  96452. }
  96453. /**
  96454. * Helps to quickly add VR support to an existing scene.
  96455. * See http://doc.babylonjs.com/how_to/webvr_helper
  96456. */
  96457. export class VRExperienceHelper {
  96458. /** Options to modify the vr experience helper's behavior. */
  96459. webVROptions: VRExperienceHelperOptions;
  96460. private _scene;
  96461. private _position;
  96462. private _btnVR;
  96463. private _btnVRDisplayed;
  96464. private _webVRsupported;
  96465. private _webVRready;
  96466. private _webVRrequesting;
  96467. private _webVRpresenting;
  96468. private _hasEnteredVR;
  96469. private _fullscreenVRpresenting;
  96470. private _canvas;
  96471. private _webVRCamera;
  96472. private _vrDeviceOrientationCamera;
  96473. private _deviceOrientationCamera;
  96474. private _existingCamera;
  96475. private _onKeyDown;
  96476. private _onVrDisplayPresentChange;
  96477. private _onVRDisplayChanged;
  96478. private _onVRRequestPresentStart;
  96479. private _onVRRequestPresentComplete;
  96480. /**
  96481. * Observable raised right before entering VR.
  96482. */
  96483. onEnteringVRObservable: Observable<VRExperienceHelper>;
  96484. /**
  96485. * Observable raised when entering VR has completed.
  96486. */
  96487. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  96488. /**
  96489. * Observable raised when exiting VR.
  96490. */
  96491. onExitingVRObservable: Observable<VRExperienceHelper>;
  96492. /**
  96493. * Observable raised when controller mesh is loaded.
  96494. */
  96495. onControllerMeshLoadedObservable: Observable<WebVRController>;
  96496. /** Return this.onEnteringVRObservable
  96497. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  96498. */
  96499. readonly onEnteringVR: Observable<VRExperienceHelper>;
  96500. /** Return this.onExitingVRObservable
  96501. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  96502. */
  96503. readonly onExitingVR: Observable<VRExperienceHelper>;
  96504. /** Return this.onControllerMeshLoadedObservable
  96505. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  96506. */
  96507. readonly onControllerMeshLoaded: Observable<WebVRController>;
  96508. private _rayLength;
  96509. private _useCustomVRButton;
  96510. private _teleportationRequested;
  96511. private _teleportActive;
  96512. private _floorMeshName;
  96513. private _floorMeshesCollection;
  96514. private _rotationAllowed;
  96515. private _teleportBackwardsVector;
  96516. private _teleportationTarget;
  96517. private _isDefaultTeleportationTarget;
  96518. private _postProcessMove;
  96519. private _teleportationFillColor;
  96520. private _teleportationBorderColor;
  96521. private _rotationAngle;
  96522. private _haloCenter;
  96523. private _cameraGazer;
  96524. private _padSensibilityUp;
  96525. private _padSensibilityDown;
  96526. private _leftController;
  96527. private _rightController;
  96528. /**
  96529. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  96530. */
  96531. onNewMeshSelected: Observable<AbstractMesh>;
  96532. /**
  96533. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  96534. */
  96535. onNewMeshPicked: Observable<PickingInfo>;
  96536. private _circleEase;
  96537. /**
  96538. * Observable raised before camera teleportation
  96539. */
  96540. onBeforeCameraTeleport: Observable<Vector3>;
  96541. /**
  96542. * Observable raised after camera teleportation
  96543. */
  96544. onAfterCameraTeleport: Observable<Vector3>;
  96545. /**
  96546. * Observable raised when current selected mesh gets unselected
  96547. */
  96548. onSelectedMeshUnselected: Observable<AbstractMesh>;
  96549. private _raySelectionPredicate;
  96550. /**
  96551. * To be optionaly changed by user to define custom ray selection
  96552. */
  96553. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  96554. /**
  96555. * To be optionaly changed by user to define custom selection logic (after ray selection)
  96556. */
  96557. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  96558. /**
  96559. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  96560. */
  96561. teleportationEnabled: boolean;
  96562. private _defaultHeight;
  96563. private _teleportationInitialized;
  96564. private _interactionsEnabled;
  96565. private _interactionsRequested;
  96566. private _displayGaze;
  96567. private _displayLaserPointer;
  96568. /**
  96569. * The mesh used to display where the user is going to teleport.
  96570. */
  96571. /**
  96572. * Sets the mesh to be used to display where the user is going to teleport.
  96573. */
  96574. teleportationTarget: Mesh;
  96575. /**
  96576. * 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
  96577. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  96578. * See http://doc.babylonjs.com/resources/baking_transformations
  96579. */
  96580. gazeTrackerMesh: Mesh;
  96581. /**
  96582. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  96583. */
  96584. updateGazeTrackerScale: boolean;
  96585. /**
  96586. * If the gaze trackers color should be updated when selecting meshes
  96587. */
  96588. updateGazeTrackerColor: boolean;
  96589. /**
  96590. * The gaze tracking mesh corresponding to the left controller
  96591. */
  96592. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  96593. /**
  96594. * The gaze tracking mesh corresponding to the right controller
  96595. */
  96596. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  96597. /**
  96598. * If the ray of the gaze should be displayed.
  96599. */
  96600. /**
  96601. * Sets if the ray of the gaze should be displayed.
  96602. */
  96603. displayGaze: boolean;
  96604. /**
  96605. * If the ray of the LaserPointer should be displayed.
  96606. */
  96607. /**
  96608. * Sets if the ray of the LaserPointer should be displayed.
  96609. */
  96610. displayLaserPointer: boolean;
  96611. /**
  96612. * The deviceOrientationCamera used as the camera when not in VR.
  96613. */
  96614. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  96615. /**
  96616. * Based on the current WebVR support, returns the current VR camera used.
  96617. */
  96618. readonly currentVRCamera: Nullable<Camera>;
  96619. /**
  96620. * The webVRCamera which is used when in VR.
  96621. */
  96622. readonly webVRCamera: WebVRFreeCamera;
  96623. /**
  96624. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  96625. */
  96626. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  96627. private readonly _teleportationRequestInitiated;
  96628. /**
  96629. * Defines wether or not Pointer lock should be requested when switching to
  96630. * full screen.
  96631. */
  96632. requestPointerLockOnFullScreen: boolean;
  96633. /**
  96634. * Instantiates a VRExperienceHelper.
  96635. * Helps to quickly add VR support to an existing scene.
  96636. * @param scene The scene the VRExperienceHelper belongs to.
  96637. * @param webVROptions Options to modify the vr experience helper's behavior.
  96638. */
  96639. constructor(scene: Scene,
  96640. /** Options to modify the vr experience helper's behavior. */
  96641. webVROptions?: VRExperienceHelperOptions);
  96642. private _onDefaultMeshLoaded;
  96643. private _onResize;
  96644. private _onFullscreenChange;
  96645. /**
  96646. * Gets a value indicating if we are currently in VR mode.
  96647. */
  96648. readonly isInVRMode: boolean;
  96649. private onVrDisplayPresentChange;
  96650. private onVRDisplayChanged;
  96651. private moveButtonToBottomRight;
  96652. private displayVRButton;
  96653. private updateButtonVisibility;
  96654. private _cachedAngularSensibility;
  96655. /**
  96656. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  96657. * Otherwise, will use the fullscreen API.
  96658. */
  96659. enterVR(): void;
  96660. /**
  96661. * Attempt to exit VR, or fullscreen.
  96662. */
  96663. exitVR(): void;
  96664. /**
  96665. * The position of the vr experience helper.
  96666. */
  96667. /**
  96668. * Sets the position of the vr experience helper.
  96669. */
  96670. position: Vector3;
  96671. /**
  96672. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  96673. */
  96674. enableInteractions(): void;
  96675. private readonly _noControllerIsActive;
  96676. private beforeRender;
  96677. private _isTeleportationFloor;
  96678. /**
  96679. * Adds a floor mesh to be used for teleportation.
  96680. * @param floorMesh the mesh to be used for teleportation.
  96681. */
  96682. addFloorMesh(floorMesh: Mesh): void;
  96683. /**
  96684. * Removes a floor mesh from being used for teleportation.
  96685. * @param floorMesh the mesh to be removed.
  96686. */
  96687. removeFloorMesh(floorMesh: Mesh): void;
  96688. /**
  96689. * Enables interactions and teleportation using the VR controllers and gaze.
  96690. * @param vrTeleportationOptions options to modify teleportation behavior.
  96691. */
  96692. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  96693. private _onNewGamepadConnected;
  96694. private _tryEnableInteractionOnController;
  96695. private _onNewGamepadDisconnected;
  96696. private _enableInteractionOnController;
  96697. private _checkTeleportWithRay;
  96698. private _checkRotate;
  96699. private _checkTeleportBackwards;
  96700. private _enableTeleportationOnController;
  96701. private _createTeleportationCircles;
  96702. private _displayTeleportationTarget;
  96703. private _hideTeleportationTarget;
  96704. private _rotateCamera;
  96705. private _moveTeleportationSelectorTo;
  96706. private _workingVector;
  96707. private _workingQuaternion;
  96708. private _workingMatrix;
  96709. /**
  96710. * Teleports the users feet to the desired location
  96711. * @param location The location where the user's feet should be placed
  96712. */
  96713. teleportCamera(location: Vector3): void;
  96714. private _convertNormalToDirectionOfRay;
  96715. private _castRayAndSelectObject;
  96716. private _notifySelectedMeshUnselected;
  96717. /**
  96718. * Sets the color of the laser ray from the vr controllers.
  96719. * @param color new color for the ray.
  96720. */
  96721. changeLaserColor(color: Color3): void;
  96722. /**
  96723. * Sets the color of the ray from the vr headsets gaze.
  96724. * @param color new color for the ray.
  96725. */
  96726. changeGazeColor(color: Color3): void;
  96727. /**
  96728. * Exits VR and disposes of the vr experience helper
  96729. */
  96730. dispose(): void;
  96731. /**
  96732. * Gets the name of the VRExperienceHelper class
  96733. * @returns "VRExperienceHelper"
  96734. */
  96735. getClassName(): string;
  96736. }
  96737. }
  96738. declare module BABYLON {
  96739. /**
  96740. * Manages an XRSession
  96741. * @see https://doc.babylonjs.com/how_to/webxr
  96742. */
  96743. export class WebXRSessionManager implements IDisposable {
  96744. private scene;
  96745. /**
  96746. * Fires every time a new xrFrame arrives which can be used to update the camera
  96747. */
  96748. onXRFrameObservable: Observable<any>;
  96749. /**
  96750. * Fires when the xr session is ended either by the device or manually done
  96751. */
  96752. onXRSessionEnded: Observable<any>;
  96753. /** @hidden */
  96754. _xrSession: XRSession;
  96755. /** @hidden */
  96756. _frameOfReference: XRFrameOfReference;
  96757. /** @hidden */
  96758. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  96759. /** @hidden */
  96760. _currentXRFrame: Nullable<XRFrame>;
  96761. private _xrNavigator;
  96762. private _xrDevice;
  96763. private _tmpMatrix;
  96764. /**
  96765. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  96766. * @param scene The scene which the session should be created for
  96767. */
  96768. constructor(scene: Scene);
  96769. /**
  96770. * Initializes the manager
  96771. * After initialization enterXR can be called to start an XR session
  96772. * @returns Promise which resolves after it is initialized
  96773. */
  96774. initializeAsync(): Promise<void>;
  96775. /**
  96776. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  96777. * @param sessionCreationOptions xr options to create the session with
  96778. * @param frameOfReferenceType option to configure how the xr pose is expressed
  96779. * @returns Promise which resolves after it enters XR
  96780. */
  96781. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  96782. /**
  96783. * Stops the xrSession and restores the renderloop
  96784. * @returns Promise which resolves after it exits XR
  96785. */
  96786. exitXRAsync(): Promise<void>;
  96787. /**
  96788. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  96789. * @param ray ray to cast into the environment
  96790. * @returns Promise which resolves with a collision point in the environment if it exists
  96791. */
  96792. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  96793. /**
  96794. * Checks if a session would be supported for the creation options specified
  96795. * @param options creation options to check if they are supported
  96796. * @returns true if supported
  96797. */
  96798. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  96799. /**
  96800. * @hidden
  96801. * Converts the render layer of xrSession to a render target
  96802. * @param session session to create render target for
  96803. * @param scene scene the new render target should be created for
  96804. */
  96805. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  96806. /**
  96807. * Disposes of the session manager
  96808. */
  96809. dispose(): void;
  96810. }
  96811. }
  96812. declare module BABYLON {
  96813. /**
  96814. * WebXR Camera which holds the views for the xrSession
  96815. * @see https://doc.babylonjs.com/how_to/webxr
  96816. */
  96817. export class WebXRCamera extends FreeCamera {
  96818. private static _TmpMatrix;
  96819. /**
  96820. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  96821. * @param name the name of the camera
  96822. * @param scene the scene to add the camera to
  96823. */
  96824. constructor(name: string, scene: Scene);
  96825. private _updateNumberOfRigCameras;
  96826. /** @hidden */
  96827. _updateForDualEyeDebugging(pupilDistance?: number): void;
  96828. /**
  96829. * Updates the cameras position from the current pose information of the XR session
  96830. * @param xrSessionManager the session containing pose information
  96831. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  96832. */
  96833. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  96834. }
  96835. }
  96836. declare module BABYLON {
  96837. /**
  96838. * States of the webXR experience
  96839. */
  96840. export enum WebXRState {
  96841. /**
  96842. * Transitioning to being in XR mode
  96843. */
  96844. ENTERING_XR = 0,
  96845. /**
  96846. * Transitioning to non XR mode
  96847. */
  96848. EXITING_XR = 1,
  96849. /**
  96850. * In XR mode and presenting
  96851. */
  96852. IN_XR = 2,
  96853. /**
  96854. * Not entered XR mode
  96855. */
  96856. NOT_IN_XR = 3
  96857. }
  96858. /**
  96859. * Helper class used to enable XR
  96860. * @see https://doc.babylonjs.com/how_to/webxr
  96861. */
  96862. export class WebXRExperienceHelper implements IDisposable {
  96863. private scene;
  96864. /**
  96865. * 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
  96866. */
  96867. container: AbstractMesh;
  96868. /**
  96869. * Camera used to render xr content
  96870. */
  96871. camera: WebXRCamera;
  96872. /**
  96873. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  96874. */
  96875. state: WebXRState;
  96876. private _setState;
  96877. private static _TmpVector;
  96878. /**
  96879. * Fires when the state of the experience helper has changed
  96880. */
  96881. onStateChangedObservable: Observable<WebXRState>;
  96882. /** @hidden */
  96883. _sessionManager: WebXRSessionManager;
  96884. private _nonVRCamera;
  96885. private _originalSceneAutoClear;
  96886. private _supported;
  96887. /**
  96888. * Creates the experience helper
  96889. * @param scene the scene to attach the experience helper to
  96890. * @returns a promise for the experience helper
  96891. */
  96892. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  96893. /**
  96894. * Creates a WebXRExperienceHelper
  96895. * @param scene The scene the helper should be created in
  96896. */
  96897. private constructor();
  96898. /**
  96899. * Exits XR mode and returns the scene to its original state
  96900. * @returns promise that resolves after xr mode has exited
  96901. */
  96902. exitXRAsync(): Promise<void>;
  96903. /**
  96904. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  96905. * @param sessionCreationOptions options for the XR session
  96906. * @param frameOfReference frame of reference of the XR session
  96907. * @returns promise that resolves after xr mode has entered
  96908. */
  96909. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  96910. /**
  96911. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  96912. * @param ray ray to cast into the environment
  96913. * @returns Promise which resolves with a collision point in the environment if it exists
  96914. */
  96915. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  96916. /**
  96917. * Updates the global position of the camera by moving the camera's container
  96918. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  96919. * @param position The desired global position of the camera
  96920. */
  96921. setPositionOfCameraUsingContainer(position: Vector3): void;
  96922. /**
  96923. * Rotates the xr camera by rotating the camera's container around the camera's position
  96924. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  96925. * @param rotation the desired quaternion rotation to apply to the camera
  96926. */
  96927. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  96928. /**
  96929. * Checks if the creation options are supported by the xr session
  96930. * @param options creation options
  96931. * @returns true if supported
  96932. */
  96933. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  96934. /**
  96935. * Disposes of the experience helper
  96936. */
  96937. dispose(): void;
  96938. }
  96939. }
  96940. declare module BABYLON {
  96941. /**
  96942. * Button which can be used to enter a different mode of XR
  96943. */
  96944. export class WebXREnterExitUIButton {
  96945. /** button element */
  96946. element: HTMLElement;
  96947. /** XR initialization options for the button */
  96948. initializationOptions: XRSessionCreationOptions;
  96949. /**
  96950. * Creates a WebXREnterExitUIButton
  96951. * @param element button element
  96952. * @param initializationOptions XR initialization options for the button
  96953. */
  96954. constructor(
  96955. /** button element */
  96956. element: HTMLElement,
  96957. /** XR initialization options for the button */
  96958. initializationOptions: XRSessionCreationOptions);
  96959. /**
  96960. * Overwritable function which can be used to update the button's visuals when the state changes
  96961. * @param activeButton the current active button in the UI
  96962. */
  96963. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  96964. }
  96965. /**
  96966. * Options to create the webXR UI
  96967. */
  96968. export class WebXREnterExitUIOptions {
  96969. /**
  96970. * Context to enter xr with
  96971. */
  96972. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  96973. /**
  96974. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  96975. */
  96976. customButtons?: Array<WebXREnterExitUIButton>;
  96977. }
  96978. /**
  96979. * UI to allow the user to enter/exit XR mode
  96980. */
  96981. export class WebXREnterExitUI implements IDisposable {
  96982. private scene;
  96983. private _overlay;
  96984. private _buttons;
  96985. private _activeButton;
  96986. /**
  96987. * Fired every time the active button is changed.
  96988. *
  96989. * When xr is entered via a button that launches xr that button will be the callback parameter
  96990. *
  96991. * When exiting xr the callback parameter will be null)
  96992. */
  96993. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  96994. /**
  96995. * Creates UI to allow the user to enter/exit XR mode
  96996. * @param scene the scene to add the ui to
  96997. * @param helper the xr experience helper to enter/exit xr with
  96998. * @param options options to configure the UI
  96999. * @returns the created ui
  97000. */
  97001. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  97002. private constructor();
  97003. private _updateButtons;
  97004. /**
  97005. * Disposes of the object
  97006. */
  97007. dispose(): void;
  97008. }
  97009. }
  97010. declare module BABYLON {
  97011. /**
  97012. * Represents an XR input
  97013. */
  97014. export class WebXRController {
  97015. /**
  97016. * 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
  97017. */
  97018. grip?: AbstractMesh;
  97019. /**
  97020. * Pointer which can be used to select objects or attach a visible laser to
  97021. */
  97022. pointer: AbstractMesh;
  97023. /**
  97024. * Creates the controller
  97025. * @see https://doc.babylonjs.com/how_to/webxr
  97026. * @param scene the scene which the controller should be associated to
  97027. */
  97028. constructor(scene: Scene);
  97029. /**
  97030. * Disposes of the object
  97031. */
  97032. dispose(): void;
  97033. }
  97034. /**
  97035. * XR input used to track XR inputs such as controllers/rays
  97036. */
  97037. export class WebXRInput implements IDisposable {
  97038. private helper;
  97039. /**
  97040. * XR controllers being tracked
  97041. */
  97042. controllers: Array<WebXRController>;
  97043. private _tmpMatrix;
  97044. private _frameObserver;
  97045. /**
  97046. * Initializes the WebXRInput
  97047. * @param helper experience helper which the input should be created for
  97048. */
  97049. constructor(helper: WebXRExperienceHelper);
  97050. /**
  97051. * Disposes of the object
  97052. */
  97053. dispose(): void;
  97054. }
  97055. }
  97056. declare module BABYLON {
  97057. /**
  97058. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  97059. */
  97060. export class WebXRManagedOutputCanvas implements IDisposable {
  97061. private _canvas;
  97062. /**
  97063. * xrpresent context of the canvas which can be used to display/mirror xr content
  97064. */
  97065. canvasContext: Nullable<WebGLRenderingContext>;
  97066. /**
  97067. * Initializes the canvas to be added/removed upon entering/exiting xr
  97068. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  97069. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  97070. */
  97071. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  97072. /**
  97073. * Disposes of the object
  97074. */
  97075. dispose(): void;
  97076. private _setManagedOutputCanvas;
  97077. private _addCanvas;
  97078. private _removeCanvas;
  97079. }
  97080. }
  97081. declare module BABYLON {
  97082. /**
  97083. * Contains an array of blocks representing the octree
  97084. */
  97085. export interface IOctreeContainer<T> {
  97086. /**
  97087. * Blocks within the octree
  97088. */
  97089. blocks: Array<OctreeBlock<T>>;
  97090. }
  97091. /**
  97092. * Class used to store a cell in an octree
  97093. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  97094. */
  97095. export class OctreeBlock<T> {
  97096. /**
  97097. * Gets the content of the current block
  97098. */
  97099. entries: T[];
  97100. /**
  97101. * Gets the list of block children
  97102. */
  97103. blocks: Array<OctreeBlock<T>>;
  97104. private _depth;
  97105. private _maxDepth;
  97106. private _capacity;
  97107. private _minPoint;
  97108. private _maxPoint;
  97109. private _boundingVectors;
  97110. private _creationFunc;
  97111. /**
  97112. * Creates a new block
  97113. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  97114. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  97115. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  97116. * @param depth defines the current depth of this block in the octree
  97117. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  97118. * @param creationFunc defines a callback to call when an element is added to the block
  97119. */
  97120. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  97121. /**
  97122. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  97123. */
  97124. readonly capacity: number;
  97125. /**
  97126. * Gets the minimum vector (in world space) of the block's bounding box
  97127. */
  97128. readonly minPoint: Vector3;
  97129. /**
  97130. * Gets the maximum vector (in world space) of the block's bounding box
  97131. */
  97132. readonly maxPoint: Vector3;
  97133. /**
  97134. * Add a new element to this block
  97135. * @param entry defines the element to add
  97136. */
  97137. addEntry(entry: T): void;
  97138. /**
  97139. * Remove an element from this block
  97140. * @param entry defines the element to remove
  97141. */
  97142. removeEntry(entry: T): void;
  97143. /**
  97144. * Add an array of elements to this block
  97145. * @param entries defines the array of elements to add
  97146. */
  97147. addEntries(entries: T[]): void;
  97148. /**
  97149. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  97150. * @param frustumPlanes defines the frustum planes to test
  97151. * @param selection defines the array to store current content if selection is positive
  97152. * @param allowDuplicate defines if the selection array can contains duplicated entries
  97153. */
  97154. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  97155. /**
  97156. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  97157. * @param sphereCenter defines the bounding sphere center
  97158. * @param sphereRadius defines the bounding sphere radius
  97159. * @param selection defines the array to store current content if selection is positive
  97160. * @param allowDuplicate defines if the selection array can contains duplicated entries
  97161. */
  97162. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  97163. /**
  97164. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  97165. * @param ray defines the ray to test with
  97166. * @param selection defines the array to store current content if selection is positive
  97167. */
  97168. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  97169. /**
  97170. * Subdivide the content into child blocks (this block will then be empty)
  97171. */
  97172. createInnerBlocks(): void;
  97173. /**
  97174. * @hidden
  97175. */
  97176. 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;
  97177. }
  97178. }
  97179. declare module BABYLON {
  97180. /**
  97181. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  97182. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  97183. */
  97184. export class Octree<T> {
  97185. /** 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.) */
  97186. maxDepth: number;
  97187. /**
  97188. * Blocks within the octree containing objects
  97189. */
  97190. blocks: Array<OctreeBlock<T>>;
  97191. /**
  97192. * Content stored in the octree
  97193. */
  97194. dynamicContent: T[];
  97195. private _maxBlockCapacity;
  97196. private _selectionContent;
  97197. private _creationFunc;
  97198. /**
  97199. * Creates a octree
  97200. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  97201. * @param creationFunc function to be used to instatiate the octree
  97202. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  97203. * @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.)
  97204. */
  97205. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  97206. /** 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.) */
  97207. maxDepth?: number);
  97208. /**
  97209. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  97210. * @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);
  97211. * @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);
  97212. * @param entries meshes to be added to the octree blocks
  97213. */
  97214. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  97215. /**
  97216. * Adds a mesh to the octree
  97217. * @param entry Mesh to add to the octree
  97218. */
  97219. addMesh(entry: T): void;
  97220. /**
  97221. * Remove an element from the octree
  97222. * @param entry defines the element to remove
  97223. */
  97224. removeMesh(entry: T): void;
  97225. /**
  97226. * Selects an array of meshes within the frustum
  97227. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  97228. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  97229. * @returns array of meshes within the frustum
  97230. */
  97231. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  97232. /**
  97233. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  97234. * @param sphereCenter defines the bounding sphere center
  97235. * @param sphereRadius defines the bounding sphere radius
  97236. * @param allowDuplicate defines if the selection array can contains duplicated entries
  97237. * @returns an array of objects that intersect the sphere
  97238. */
  97239. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  97240. /**
  97241. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  97242. * @param ray defines the ray to test with
  97243. * @returns array of intersected objects
  97244. */
  97245. intersectsRay(ray: Ray): SmartArray<T>;
  97246. /**
  97247. * Adds a mesh into the octree block if it intersects the block
  97248. */
  97249. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  97250. /**
  97251. * Adds a submesh into the octree block if it intersects the block
  97252. */
  97253. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  97254. }
  97255. }
  97256. declare module BABYLON {
  97257. interface Scene {
  97258. /**
  97259. * @hidden
  97260. * Backing Filed
  97261. */
  97262. _selectionOctree: Octree<AbstractMesh>;
  97263. /**
  97264. * Gets the octree used to boost mesh selection (picking)
  97265. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  97266. */
  97267. selectionOctree: Octree<AbstractMesh>;
  97268. /**
  97269. * Creates or updates the octree used to boost selection (picking)
  97270. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  97271. * @param maxCapacity defines the maximum capacity per leaf
  97272. * @param maxDepth defines the maximum depth of the octree
  97273. * @returns an octree of AbstractMesh
  97274. */
  97275. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  97276. }
  97277. interface AbstractMesh {
  97278. /**
  97279. * @hidden
  97280. * Backing Field
  97281. */
  97282. _submeshesOctree: Octree<SubMesh>;
  97283. /**
  97284. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  97285. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  97286. * @param maxCapacity defines the maximum size of each block (64 by default)
  97287. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  97288. * @returns the new octree
  97289. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  97290. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  97291. */
  97292. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  97293. }
  97294. /**
  97295. * Defines the octree scene component responsible to manage any octrees
  97296. * in a given scene.
  97297. */
  97298. export class OctreeSceneComponent {
  97299. /**
  97300. * The component name helpfull to identify the component in the list of scene components.
  97301. */
  97302. readonly name: string;
  97303. /**
  97304. * The scene the component belongs to.
  97305. */
  97306. scene: Scene;
  97307. /**
  97308. * Indicates if the meshes have been checked to make sure they are isEnabled()
  97309. */
  97310. readonly checksIsEnabled: boolean;
  97311. /**
  97312. * Creates a new instance of the component for the given scene
  97313. * @param scene Defines the scene to register the component in
  97314. */
  97315. constructor(scene: Scene);
  97316. /**
  97317. * Registers the component in a given scene
  97318. */
  97319. register(): void;
  97320. /**
  97321. * Return the list of active meshes
  97322. * @returns the list of active meshes
  97323. */
  97324. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  97325. /**
  97326. * Return the list of active sub meshes
  97327. * @param mesh The mesh to get the candidates sub meshes from
  97328. * @returns the list of active sub meshes
  97329. */
  97330. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  97331. private _tempRay;
  97332. /**
  97333. * Return the list of sub meshes intersecting with a given local ray
  97334. * @param mesh defines the mesh to find the submesh for
  97335. * @param localRay defines the ray in local space
  97336. * @returns the list of intersecting sub meshes
  97337. */
  97338. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  97339. /**
  97340. * Return the list of sub meshes colliding with a collider
  97341. * @param mesh defines the mesh to find the submesh for
  97342. * @param collider defines the collider to evaluate the collision against
  97343. * @returns the list of colliding sub meshes
  97344. */
  97345. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  97346. /**
  97347. * Rebuilds the elements related to this component in case of
  97348. * context lost for instance.
  97349. */
  97350. rebuild(): void;
  97351. /**
  97352. * Disposes the component and the associated ressources.
  97353. */
  97354. dispose(): void;
  97355. }
  97356. }
  97357. declare module BABYLON {
  97358. /**
  97359. * Class containing static functions to help procedurally build meshes
  97360. */
  97361. export class LinesBuilder {
  97362. /**
  97363. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  97364. * * 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
  97365. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  97366. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  97367. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  97368. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  97369. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  97370. * * 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
  97371. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  97372. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  97373. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  97374. * @param name defines the name of the new line system
  97375. * @param options defines the options used to create the line system
  97376. * @param scene defines the hosting scene
  97377. * @returns a new line system mesh
  97378. */
  97379. static CreateLineSystem(name: string, options: {
  97380. lines: Vector3[][];
  97381. updatable?: boolean;
  97382. instance?: Nullable<LinesMesh>;
  97383. colors?: Nullable<Color4[][]>;
  97384. useVertexAlpha?: boolean;
  97385. }, scene: Nullable<Scene>): LinesMesh;
  97386. /**
  97387. * Creates a line mesh
  97388. * 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
  97389. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  97390. * * The parameter `points` is an array successive Vector3
  97391. * * 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
  97392. * * The optional parameter `colors` is an array of successive Color4, one per line point
  97393. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  97394. * * When updating an instance, remember that only point positions can change, not the number of points
  97395. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  97396. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  97397. * @param name defines the name of the new line system
  97398. * @param options defines the options used to create the line system
  97399. * @param scene defines the hosting scene
  97400. * @returns a new line mesh
  97401. */
  97402. static CreateLines(name: string, options: {
  97403. points: Vector3[];
  97404. updatable?: boolean;
  97405. instance?: Nullable<LinesMesh>;
  97406. colors?: Color4[];
  97407. useVertexAlpha?: boolean;
  97408. }, scene?: Nullable<Scene>): LinesMesh;
  97409. /**
  97410. * Creates a dashed line mesh
  97411. * * 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
  97412. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  97413. * * The parameter `points` is an array successive Vector3
  97414. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  97415. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  97416. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  97417. * * 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
  97418. * * When updating an instance, remember that only point positions can change, not the number of points
  97419. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  97420. * @param name defines the name of the mesh
  97421. * @param options defines the options used to create the mesh
  97422. * @param scene defines the hosting scene
  97423. * @returns the dashed line mesh
  97424. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  97425. */
  97426. static CreateDashedLines(name: string, options: {
  97427. points: Vector3[];
  97428. dashSize?: number;
  97429. gapSize?: number;
  97430. dashNb?: number;
  97431. updatable?: boolean;
  97432. instance?: LinesMesh;
  97433. }, scene?: Nullable<Scene>): LinesMesh;
  97434. }
  97435. }
  97436. declare module BABYLON {
  97437. /**
  97438. * Renders a layer on top of an existing scene
  97439. */
  97440. export class UtilityLayerRenderer implements IDisposable {
  97441. /** the original scene that will be rendered on top of */
  97442. originalScene: Scene;
  97443. private _pointerCaptures;
  97444. private _lastPointerEvents;
  97445. private static _DefaultUtilityLayer;
  97446. private static _DefaultKeepDepthUtilityLayer;
  97447. /**
  97448. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  97449. */
  97450. pickUtilitySceneFirst: boolean;
  97451. /**
  97452. * 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)
  97453. */
  97454. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  97455. /**
  97456. * 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)
  97457. */
  97458. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  97459. /**
  97460. * The scene that is rendered on top of the original scene
  97461. */
  97462. utilityLayerScene: Scene;
  97463. /**
  97464. * If the utility layer should automatically be rendered on top of existing scene
  97465. */
  97466. shouldRender: boolean;
  97467. /**
  97468. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  97469. */
  97470. onlyCheckPointerDownEvents: boolean;
  97471. /**
  97472. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  97473. */
  97474. processAllEvents: boolean;
  97475. /**
  97476. * Observable raised when the pointer move from the utility layer scene to the main scene
  97477. */
  97478. onPointerOutObservable: Observable<number>;
  97479. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  97480. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  97481. private _afterRenderObserver;
  97482. private _sceneDisposeObserver;
  97483. private _originalPointerObserver;
  97484. /**
  97485. * Instantiates a UtilityLayerRenderer
  97486. * @param originalScene the original scene that will be rendered on top of
  97487. * @param handleEvents boolean indicating if the utility layer should handle events
  97488. */
  97489. constructor(
  97490. /** the original scene that will be rendered on top of */
  97491. originalScene: Scene, handleEvents?: boolean);
  97492. private _notifyObservers;
  97493. /**
  97494. * Renders the utility layers scene on top of the original scene
  97495. */
  97496. render(): void;
  97497. /**
  97498. * Disposes of the renderer
  97499. */
  97500. dispose(): void;
  97501. private _updateCamera;
  97502. }
  97503. }
  97504. declare module BABYLON {
  97505. /**
  97506. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  97507. */
  97508. export class Gizmo implements IDisposable {
  97509. /** The utility layer the gizmo will be added to */
  97510. gizmoLayer: UtilityLayerRenderer;
  97511. /**
  97512. * The root mesh of the gizmo
  97513. */
  97514. _rootMesh: Mesh;
  97515. private _attachedMesh;
  97516. /**
  97517. * Ratio for the scale of the gizmo (Default: 1)
  97518. */
  97519. scaleRatio: number;
  97520. private _tmpMatrix;
  97521. /**
  97522. * If a custom mesh has been set (Default: false)
  97523. */
  97524. protected _customMeshSet: boolean;
  97525. /**
  97526. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  97527. * * When set, interactions will be enabled
  97528. */
  97529. attachedMesh: Nullable<AbstractMesh>;
  97530. /**
  97531. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  97532. * @param mesh The mesh to replace the default mesh of the gizmo
  97533. */
  97534. setCustomMesh(mesh: Mesh): void;
  97535. /**
  97536. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  97537. */
  97538. updateGizmoRotationToMatchAttachedMesh: boolean;
  97539. /**
  97540. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  97541. */
  97542. updateGizmoPositionToMatchAttachedMesh: boolean;
  97543. /**
  97544. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  97545. */
  97546. protected _updateScale: boolean;
  97547. protected _interactionsEnabled: boolean;
  97548. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  97549. private _beforeRenderObserver;
  97550. /**
  97551. * Creates a gizmo
  97552. * @param gizmoLayer The utility layer the gizmo will be added to
  97553. */
  97554. constructor(
  97555. /** The utility layer the gizmo will be added to */
  97556. gizmoLayer?: UtilityLayerRenderer);
  97557. private _tempVector;
  97558. /**
  97559. * @hidden
  97560. * Updates the gizmo to match the attached mesh's position/rotation
  97561. */
  97562. protected _update(): void;
  97563. /**
  97564. * Disposes of the gizmo
  97565. */
  97566. dispose(): void;
  97567. }
  97568. }
  97569. declare module BABYLON {
  97570. /**
  97571. * Single axis drag gizmo
  97572. */
  97573. export class AxisDragGizmo extends Gizmo {
  97574. /**
  97575. * Drag behavior responsible for the gizmos dragging interactions
  97576. */
  97577. dragBehavior: PointerDragBehavior;
  97578. private _pointerObserver;
  97579. /**
  97580. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  97581. */
  97582. snapDistance: number;
  97583. /**
  97584. * Event that fires each time the gizmo snaps to a new location.
  97585. * * snapDistance is the the change in distance
  97586. */
  97587. onSnapObservable: Observable<{
  97588. snapDistance: number;
  97589. }>;
  97590. /** @hidden */
  97591. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  97592. /** @hidden */
  97593. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  97594. /**
  97595. * Creates an AxisDragGizmo
  97596. * @param gizmoLayer The utility layer the gizmo will be added to
  97597. * @param dragAxis The axis which the gizmo will be able to drag on
  97598. * @param color The color of the gizmo
  97599. */
  97600. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  97601. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  97602. /**
  97603. * Disposes of the gizmo
  97604. */
  97605. dispose(): void;
  97606. }
  97607. }
  97608. declare module BABYLON.Debug {
  97609. /**
  97610. * The Axes viewer will show 3 axes in a specific point in space
  97611. */
  97612. export class AxesViewer {
  97613. private _xAxis;
  97614. private _yAxis;
  97615. private _zAxis;
  97616. private _scaleLinesFactor;
  97617. private _instanced;
  97618. /**
  97619. * Gets the hosting scene
  97620. */
  97621. scene: Scene;
  97622. /**
  97623. * Gets or sets a number used to scale line length
  97624. */
  97625. scaleLines: number;
  97626. /** Gets the node hierarchy used to render x-axis */
  97627. readonly xAxis: TransformNode;
  97628. /** Gets the node hierarchy used to render y-axis */
  97629. readonly yAxis: TransformNode;
  97630. /** Gets the node hierarchy used to render z-axis */
  97631. readonly zAxis: TransformNode;
  97632. /**
  97633. * Creates a new AxesViewer
  97634. * @param scene defines the hosting scene
  97635. * @param scaleLines defines a number used to scale line length (1 by default)
  97636. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  97637. * @param xAxis defines the node hierarchy used to render the x-axis
  97638. * @param yAxis defines the node hierarchy used to render the y-axis
  97639. * @param zAxis defines the node hierarchy used to render the z-axis
  97640. */
  97641. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  97642. /**
  97643. * Force the viewer to update
  97644. * @param position defines the position of the viewer
  97645. * @param xaxis defines the x axis of the viewer
  97646. * @param yaxis defines the y axis of the viewer
  97647. * @param zaxis defines the z axis of the viewer
  97648. */
  97649. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  97650. /**
  97651. * Creates an instance of this axes viewer.
  97652. * @returns a new axes viewer with instanced meshes
  97653. */
  97654. createInstance(): AxesViewer;
  97655. /** Releases resources */
  97656. dispose(): void;
  97657. private static _SetRenderingGroupId;
  97658. }
  97659. }
  97660. declare module BABYLON.Debug {
  97661. /**
  97662. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  97663. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  97664. */
  97665. export class BoneAxesViewer extends AxesViewer {
  97666. /**
  97667. * Gets or sets the target mesh where to display the axes viewer
  97668. */
  97669. mesh: Nullable<Mesh>;
  97670. /**
  97671. * Gets or sets the target bone where to display the axes viewer
  97672. */
  97673. bone: Nullable<Bone>;
  97674. /** Gets current position */
  97675. pos: Vector3;
  97676. /** Gets direction of X axis */
  97677. xaxis: Vector3;
  97678. /** Gets direction of Y axis */
  97679. yaxis: Vector3;
  97680. /** Gets direction of Z axis */
  97681. zaxis: Vector3;
  97682. /**
  97683. * Creates a new BoneAxesViewer
  97684. * @param scene defines the hosting scene
  97685. * @param bone defines the target bone
  97686. * @param mesh defines the target mesh
  97687. * @param scaleLines defines a scaling factor for line length (1 by default)
  97688. */
  97689. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  97690. /**
  97691. * Force the viewer to update
  97692. */
  97693. update(): void;
  97694. /** Releases resources */
  97695. dispose(): void;
  97696. }
  97697. }
  97698. declare module BABYLON {
  97699. /**
  97700. * Interface used to define scene explorer extensibility option
  97701. */
  97702. export interface IExplorerExtensibilityOption {
  97703. /**
  97704. * Define the option label
  97705. */
  97706. label: string;
  97707. /**
  97708. * Defines the action to execute on click
  97709. */
  97710. action: (entity: any) => void;
  97711. }
  97712. /**
  97713. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  97714. */
  97715. export interface IExplorerExtensibilityGroup {
  97716. /**
  97717. * Defines a predicate to test if a given type mut be extended
  97718. */
  97719. predicate: (entity: any) => boolean;
  97720. /**
  97721. * Gets the list of options added to a type
  97722. */
  97723. entries: IExplorerExtensibilityOption[];
  97724. }
  97725. /**
  97726. * Interface used to define the options to use to create the Inspector
  97727. */
  97728. export interface IInspectorOptions {
  97729. /**
  97730. * Display in overlay mode (default: false)
  97731. */
  97732. overlay?: boolean;
  97733. /**
  97734. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  97735. */
  97736. globalRoot?: HTMLElement;
  97737. /**
  97738. * Display the Scene explorer
  97739. */
  97740. showExplorer?: boolean;
  97741. /**
  97742. * Display the property inspector
  97743. */
  97744. showInspector?: boolean;
  97745. /**
  97746. * Display in embed mode (both panes on the right)
  97747. */
  97748. embedMode?: boolean;
  97749. /**
  97750. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  97751. */
  97752. handleResize?: boolean;
  97753. /**
  97754. * Allow the panes to popup (default: true)
  97755. */
  97756. enablePopup?: boolean;
  97757. /**
  97758. * Allow the panes to be closed by users (default: true)
  97759. */
  97760. enableClose?: boolean;
  97761. /**
  97762. * Optional list of extensibility entries
  97763. */
  97764. explorerExtensibility?: IExplorerExtensibilityGroup[];
  97765. /**
  97766. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  97767. */
  97768. inspectorURL?: string;
  97769. }
  97770. interface Scene {
  97771. /**
  97772. * @hidden
  97773. * Backing field
  97774. */
  97775. _debugLayer: DebugLayer;
  97776. /**
  97777. * Gets the debug layer (aka Inspector) associated with the scene
  97778. * @see http://doc.babylonjs.com/features/playground_debuglayer
  97779. */
  97780. debugLayer: DebugLayer;
  97781. }
  97782. /**
  97783. * The debug layer (aka Inspector) is the go to tool in order to better understand
  97784. * what is happening in your scene
  97785. * @see http://doc.babylonjs.com/features/playground_debuglayer
  97786. */
  97787. export class DebugLayer {
  97788. /**
  97789. * Define the url to get the inspector script from.
  97790. * By default it uses the babylonjs CDN.
  97791. * @ignoreNaming
  97792. */
  97793. static InspectorURL: string;
  97794. private _scene;
  97795. private BJSINSPECTOR;
  97796. /**
  97797. * Observable triggered when a property is changed through the inspector.
  97798. */
  97799. onPropertyChangedObservable: Observable<{
  97800. object: any;
  97801. property: string;
  97802. value: any;
  97803. initialValue: any;
  97804. }>;
  97805. /**
  97806. * Instantiates a new debug layer.
  97807. * The debug layer (aka Inspector) is the go to tool in order to better understand
  97808. * what is happening in your scene
  97809. * @see http://doc.babylonjs.com/features/playground_debuglayer
  97810. * @param scene Defines the scene to inspect
  97811. */
  97812. constructor(scene: Scene);
  97813. /** Creates the inspector window. */
  97814. private _createInspector;
  97815. /**
  97816. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  97817. * @param entity defines the entity to select
  97818. * @param lineContainerTitle defines the specific block to highlight
  97819. */
  97820. select(entity: any, lineContainerTitle?: string): void;
  97821. /** Get the inspector from bundle or global */
  97822. private _getGlobalInspector;
  97823. /**
  97824. * Get if the inspector is visible or not.
  97825. * @returns true if visible otherwise, false
  97826. */
  97827. isVisible(): boolean;
  97828. /**
  97829. * Hide the inspector and close its window.
  97830. */
  97831. hide(): void;
  97832. /**
  97833. * Launch the debugLayer.
  97834. * @param config Define the configuration of the inspector
  97835. * @return a promise fulfilled when the debug layer is visible
  97836. */
  97837. show(config?: IInspectorOptions): Promise<DebugLayer>;
  97838. }
  97839. }
  97840. declare module BABYLON {
  97841. /**
  97842. * Class containing static functions to help procedurally build meshes
  97843. */
  97844. export class BoxBuilder {
  97845. /**
  97846. * Creates a box mesh
  97847. * * The parameter `size` sets the size (float) of each box side (default 1)
  97848. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  97849. * * 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)
  97850. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  97851. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  97852. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  97853. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  97854. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  97855. * @param name defines the name of the mesh
  97856. * @param options defines the options used to create the mesh
  97857. * @param scene defines the hosting scene
  97858. * @returns the box mesh
  97859. */
  97860. static CreateBox(name: string, options: {
  97861. size?: number;
  97862. width?: number;
  97863. height?: number;
  97864. depth?: number;
  97865. faceUV?: Vector4[];
  97866. faceColors?: Color4[];
  97867. sideOrientation?: number;
  97868. frontUVs?: Vector4;
  97869. backUVs?: Vector4;
  97870. updatable?: boolean;
  97871. }, scene?: Nullable<Scene>): Mesh;
  97872. }
  97873. }
  97874. declare module BABYLON {
  97875. /**
  97876. * Class containing static functions to help procedurally build meshes
  97877. */
  97878. export class SphereBuilder {
  97879. /**
  97880. * Creates a sphere mesh
  97881. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  97882. * * 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`)
  97883. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  97884. * * 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
  97885. * * 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)
  97886. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  97887. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  97888. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  97889. * @param name defines the name of the mesh
  97890. * @param options defines the options used to create the mesh
  97891. * @param scene defines the hosting scene
  97892. * @returns the sphere mesh
  97893. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  97894. */
  97895. static CreateSphere(name: string, options: {
  97896. segments?: number;
  97897. diameter?: number;
  97898. diameterX?: number;
  97899. diameterY?: number;
  97900. diameterZ?: number;
  97901. arc?: number;
  97902. slice?: number;
  97903. sideOrientation?: number;
  97904. frontUVs?: Vector4;
  97905. backUVs?: Vector4;
  97906. updatable?: boolean;
  97907. }, scene: any): Mesh;
  97908. }
  97909. }
  97910. declare module BABYLON.Debug {
  97911. /**
  97912. * Used to show the physics impostor around the specific mesh
  97913. */
  97914. export class PhysicsViewer {
  97915. /** @hidden */
  97916. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  97917. /** @hidden */
  97918. protected _meshes: Array<Nullable<AbstractMesh>>;
  97919. /** @hidden */
  97920. protected _scene: Nullable<Scene>;
  97921. /** @hidden */
  97922. protected _numMeshes: number;
  97923. /** @hidden */
  97924. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  97925. private _renderFunction;
  97926. private _utilityLayer;
  97927. private _debugBoxMesh;
  97928. private _debugSphereMesh;
  97929. private _debugMaterial;
  97930. /**
  97931. * Creates a new PhysicsViewer
  97932. * @param scene defines the hosting scene
  97933. */
  97934. constructor(scene: Scene);
  97935. /** @hidden */
  97936. protected _updateDebugMeshes(): void;
  97937. /**
  97938. * Renders a specified physic impostor
  97939. * @param impostor defines the impostor to render
  97940. * @returns the new debug mesh used to render the impostor
  97941. */
  97942. showImpostor(impostor: PhysicsImpostor): Nullable<AbstractMesh>;
  97943. /**
  97944. * Hides a specified physic impostor
  97945. * @param impostor defines the impostor to hide
  97946. */
  97947. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  97948. private _getDebugMaterial;
  97949. private _getDebugBoxMesh;
  97950. private _getDebugSphereMesh;
  97951. private _getDebugMesh;
  97952. /** Releases all resources */
  97953. dispose(): void;
  97954. }
  97955. }
  97956. declare module BABYLON {
  97957. /**
  97958. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  97959. * in order to better appreciate the issue one might have.
  97960. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  97961. */
  97962. export class RayHelper {
  97963. /**
  97964. * Defines the ray we are currently tryin to visualize.
  97965. */
  97966. ray: Nullable<Ray>;
  97967. private _renderPoints;
  97968. private _renderLine;
  97969. private _renderFunction;
  97970. private _scene;
  97971. private _updateToMeshFunction;
  97972. private _attachedToMesh;
  97973. private _meshSpaceDirection;
  97974. private _meshSpaceOrigin;
  97975. /**
  97976. * Helper function to create a colored helper in a scene in one line.
  97977. * @param ray Defines the ray we are currently tryin to visualize
  97978. * @param scene Defines the scene the ray is used in
  97979. * @param color Defines the color we want to see the ray in
  97980. * @returns The newly created ray helper.
  97981. */
  97982. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  97983. /**
  97984. * Instantiate a new ray helper.
  97985. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  97986. * in order to better appreciate the issue one might have.
  97987. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  97988. * @param ray Defines the ray we are currently tryin to visualize
  97989. */
  97990. constructor(ray: Ray);
  97991. /**
  97992. * Shows the ray we are willing to debug.
  97993. * @param scene Defines the scene the ray needs to be rendered in
  97994. * @param color Defines the color the ray needs to be rendered in
  97995. */
  97996. show(scene: Scene, color?: Color3): void;
  97997. /**
  97998. * Hides the ray we are debugging.
  97999. */
  98000. hide(): void;
  98001. private _render;
  98002. /**
  98003. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  98004. * @param mesh Defines the mesh we want the helper attached to
  98005. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  98006. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  98007. * @param length Defines the length of the ray
  98008. */
  98009. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  98010. /**
  98011. * Detach the ray helper from the mesh it has previously been attached to.
  98012. */
  98013. detachFromMesh(): void;
  98014. private _updateToMesh;
  98015. /**
  98016. * Dispose the helper and release its associated resources.
  98017. */
  98018. dispose(): void;
  98019. }
  98020. }
  98021. declare module BABYLON.Debug {
  98022. /**
  98023. * Class used to render a debug view of a given skeleton
  98024. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  98025. */
  98026. export class SkeletonViewer {
  98027. /** defines the skeleton to render */
  98028. skeleton: Skeleton;
  98029. /** defines the mesh attached to the skeleton */
  98030. mesh: AbstractMesh;
  98031. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  98032. autoUpdateBonesMatrices: boolean;
  98033. /** defines the rendering group id to use with the viewer */
  98034. renderingGroupId: number;
  98035. /** Gets or sets the color used to render the skeleton */
  98036. color: Color3;
  98037. private _scene;
  98038. private _debugLines;
  98039. private _debugMesh;
  98040. private _isEnabled;
  98041. private _renderFunction;
  98042. private _utilityLayer;
  98043. /**
  98044. * Returns the mesh used to render the bones
  98045. */
  98046. readonly debugMesh: Nullable<LinesMesh>;
  98047. /**
  98048. * Creates a new SkeletonViewer
  98049. * @param skeleton defines the skeleton to render
  98050. * @param mesh defines the mesh attached to the skeleton
  98051. * @param scene defines the hosting scene
  98052. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  98053. * @param renderingGroupId defines the rendering group id to use with the viewer
  98054. */
  98055. constructor(
  98056. /** defines the skeleton to render */
  98057. skeleton: Skeleton,
  98058. /** defines the mesh attached to the skeleton */
  98059. mesh: AbstractMesh, scene: Scene,
  98060. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  98061. autoUpdateBonesMatrices?: boolean,
  98062. /** defines the rendering group id to use with the viewer */
  98063. renderingGroupId?: number);
  98064. /** Gets or sets a boolean indicating if the viewer is enabled */
  98065. isEnabled: boolean;
  98066. private _getBonePosition;
  98067. private _getLinesForBonesWithLength;
  98068. private _getLinesForBonesNoLength;
  98069. /** Update the viewer to sync with current skeleton state */
  98070. update(): void;
  98071. /** Release associated resources */
  98072. dispose(): void;
  98073. }
  98074. }
  98075. declare module BABYLON {
  98076. /**
  98077. * Options to create the null engine
  98078. */
  98079. export class NullEngineOptions {
  98080. /**
  98081. * Render width (Default: 512)
  98082. */
  98083. renderWidth: number;
  98084. /**
  98085. * Render height (Default: 256)
  98086. */
  98087. renderHeight: number;
  98088. /**
  98089. * Texture size (Default: 512)
  98090. */
  98091. textureSize: number;
  98092. /**
  98093. * If delta time between frames should be constant
  98094. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  98095. */
  98096. deterministicLockstep: boolean;
  98097. /**
  98098. * Maximum about of steps between frames (Default: 4)
  98099. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  98100. */
  98101. lockstepMaxSteps: number;
  98102. }
  98103. /**
  98104. * The null engine class provides support for headless version of babylon.js.
  98105. * This can be used in server side scenario or for testing purposes
  98106. */
  98107. export class NullEngine extends Engine {
  98108. private _options;
  98109. /**
  98110. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  98111. */
  98112. isDeterministicLockStep(): boolean;
  98113. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  98114. getLockstepMaxSteps(): number;
  98115. /**
  98116. * Sets hardware scaling, used to save performance if needed
  98117. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  98118. */
  98119. getHardwareScalingLevel(): number;
  98120. constructor(options?: NullEngineOptions);
  98121. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  98122. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  98123. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  98124. getRenderWidth(useScreen?: boolean): number;
  98125. getRenderHeight(useScreen?: boolean): number;
  98126. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  98127. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  98128. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  98129. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  98130. bindSamplers(effect: Effect): void;
  98131. enableEffect(effect: Effect): void;
  98132. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  98133. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  98134. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  98135. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  98136. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  98137. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  98138. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  98139. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  98140. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  98141. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  98142. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  98143. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  98144. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  98145. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  98146. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  98147. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  98148. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  98149. setFloat(uniform: WebGLUniformLocation, value: number): void;
  98150. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  98151. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  98152. setBool(uniform: WebGLUniformLocation, bool: number): void;
  98153. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  98154. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  98155. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  98156. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  98157. bindBuffers(vertexBuffers: {
  98158. [key: string]: VertexBuffer;
  98159. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  98160. wipeCaches(bruteForce?: boolean): void;
  98161. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  98162. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  98163. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  98164. /** @hidden */
  98165. _createTexture(): WebGLTexture;
  98166. /** @hidden */
  98167. _releaseTexture(texture: InternalTexture): void;
  98168. 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;
  98169. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  98170. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  98171. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  98172. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  98173. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  98174. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  98175. areAllEffectsReady(): boolean;
  98176. /**
  98177. * @hidden
  98178. * Get the current error code of the webGL context
  98179. * @returns the error code
  98180. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  98181. */
  98182. getError(): number;
  98183. /** @hidden */
  98184. _getUnpackAlignement(): number;
  98185. /** @hidden */
  98186. _unpackFlipY(value: boolean): void;
  98187. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  98188. /**
  98189. * Updates a dynamic vertex buffer.
  98190. * @param vertexBuffer the vertex buffer to update
  98191. * @param data the data used to update the vertex buffer
  98192. * @param byteOffset the byte offset of the data (optional)
  98193. * @param byteLength the byte length of the data (optional)
  98194. */
  98195. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  98196. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  98197. /** @hidden */
  98198. _bindTexture(channel: number, texture: InternalTexture): void;
  98199. /** @hidden */
  98200. _releaseBuffer(buffer: WebGLBuffer): boolean;
  98201. releaseEffects(): void;
  98202. displayLoadingUI(): void;
  98203. hideLoadingUI(): void;
  98204. /** @hidden */
  98205. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  98206. /** @hidden */
  98207. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  98208. /** @hidden */
  98209. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  98210. /** @hidden */
  98211. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  98212. }
  98213. }
  98214. declare module BABYLON {
  98215. /** @hidden */
  98216. export class _OcclusionDataStorage {
  98217. /** @hidden */
  98218. occlusionInternalRetryCounter: number;
  98219. /** @hidden */
  98220. isOcclusionQueryInProgress: boolean;
  98221. /** @hidden */
  98222. isOccluded: boolean;
  98223. /** @hidden */
  98224. occlusionRetryCount: number;
  98225. /** @hidden */
  98226. occlusionType: number;
  98227. /** @hidden */
  98228. occlusionQueryAlgorithmType: number;
  98229. }
  98230. interface Engine {
  98231. /**
  98232. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  98233. * @return the new query
  98234. */
  98235. createQuery(): WebGLQuery;
  98236. /**
  98237. * Delete and release a webGL query
  98238. * @param query defines the query to delete
  98239. * @return the current engine
  98240. */
  98241. deleteQuery(query: WebGLQuery): Engine;
  98242. /**
  98243. * Check if a given query has resolved and got its value
  98244. * @param query defines the query to check
  98245. * @returns true if the query got its value
  98246. */
  98247. isQueryResultAvailable(query: WebGLQuery): boolean;
  98248. /**
  98249. * Gets the value of a given query
  98250. * @param query defines the query to check
  98251. * @returns the value of the query
  98252. */
  98253. getQueryResult(query: WebGLQuery): number;
  98254. /**
  98255. * Initiates an occlusion query
  98256. * @param algorithmType defines the algorithm to use
  98257. * @param query defines the query to use
  98258. * @returns the current engine
  98259. * @see http://doc.babylonjs.com/features/occlusionquery
  98260. */
  98261. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  98262. /**
  98263. * Ends an occlusion query
  98264. * @see http://doc.babylonjs.com/features/occlusionquery
  98265. * @param algorithmType defines the algorithm to use
  98266. * @returns the current engine
  98267. */
  98268. endOcclusionQuery(algorithmType: number): Engine;
  98269. /**
  98270. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  98271. * Please note that only one query can be issued at a time
  98272. * @returns a time token used to track the time span
  98273. */
  98274. startTimeQuery(): Nullable<_TimeToken>;
  98275. /**
  98276. * Ends a time query
  98277. * @param token defines the token used to measure the time span
  98278. * @returns the time spent (in ns)
  98279. */
  98280. endTimeQuery(token: _TimeToken): int;
  98281. /** @hidden */
  98282. _currentNonTimestampToken: Nullable<_TimeToken>;
  98283. /** @hidden */
  98284. _createTimeQuery(): WebGLQuery;
  98285. /** @hidden */
  98286. _deleteTimeQuery(query: WebGLQuery): void;
  98287. /** @hidden */
  98288. _getGlAlgorithmType(algorithmType: number): number;
  98289. /** @hidden */
  98290. _getTimeQueryResult(query: WebGLQuery): any;
  98291. /** @hidden */
  98292. _getTimeQueryAvailability(query: WebGLQuery): any;
  98293. }
  98294. interface AbstractMesh {
  98295. /**
  98296. * Backing filed
  98297. * @hidden
  98298. */
  98299. __occlusionDataStorage: _OcclusionDataStorage;
  98300. /**
  98301. * Access property
  98302. * @hidden
  98303. */
  98304. _occlusionDataStorage: _OcclusionDataStorage;
  98305. /**
  98306. * 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.
  98307. * The default value is -1 which means don't break the query and wait till the result
  98308. * @see http://doc.babylonjs.com/features/occlusionquery
  98309. */
  98310. occlusionRetryCount: number;
  98311. /**
  98312. * 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:
  98313. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  98314. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  98315. * * 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.
  98316. * @see http://doc.babylonjs.com/features/occlusionquery
  98317. */
  98318. occlusionType: number;
  98319. /**
  98320. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  98321. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  98322. * * 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.
  98323. * @see http://doc.babylonjs.com/features/occlusionquery
  98324. */
  98325. occlusionQueryAlgorithmType: number;
  98326. /**
  98327. * 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
  98328. * @see http://doc.babylonjs.com/features/occlusionquery
  98329. */
  98330. isOccluded: boolean;
  98331. /**
  98332. * Flag to check the progress status of the query
  98333. * @see http://doc.babylonjs.com/features/occlusionquery
  98334. */
  98335. isOcclusionQueryInProgress: boolean;
  98336. }
  98337. }
  98338. declare module BABYLON {
  98339. /** @hidden */
  98340. export var _forceTransformFeedbackToBundle: boolean;
  98341. interface Engine {
  98342. /**
  98343. * Creates a webGL transform feedback object
  98344. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  98345. * @returns the webGL transform feedback object
  98346. */
  98347. createTransformFeedback(): WebGLTransformFeedback;
  98348. /**
  98349. * Delete a webGL transform feedback object
  98350. * @param value defines the webGL transform feedback object to delete
  98351. */
  98352. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  98353. /**
  98354. * Bind a webGL transform feedback object to the webgl context
  98355. * @param value defines the webGL transform feedback object to bind
  98356. */
  98357. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  98358. /**
  98359. * Begins a transform feedback operation
  98360. * @param usePoints defines if points or triangles must be used
  98361. */
  98362. beginTransformFeedback(usePoints: boolean): void;
  98363. /**
  98364. * Ends a transform feedback operation
  98365. */
  98366. endTransformFeedback(): void;
  98367. /**
  98368. * Specify the varyings to use with transform feedback
  98369. * @param program defines the associated webGL program
  98370. * @param value defines the list of strings representing the varying names
  98371. */
  98372. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  98373. /**
  98374. * Bind a webGL buffer for a transform feedback operation
  98375. * @param value defines the webGL buffer to bind
  98376. */
  98377. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  98378. }
  98379. }
  98380. declare module BABYLON {
  98381. /**
  98382. * Gather the list of clipboard event types as constants.
  98383. */
  98384. export class ClipboardEventTypes {
  98385. /**
  98386. * The clipboard event is fired when a copy command is active (pressed).
  98387. */
  98388. static readonly COPY: number;
  98389. /**
  98390. * The clipboard event is fired when a cut command is active (pressed).
  98391. */
  98392. static readonly CUT: number;
  98393. /**
  98394. * The clipboard event is fired when a paste command is active (pressed).
  98395. */
  98396. static readonly PASTE: number;
  98397. }
  98398. /**
  98399. * This class is used to store clipboard related info for the onClipboardObservable event.
  98400. */
  98401. export class ClipboardInfo {
  98402. /**
  98403. * Defines the type of event (BABYLON.ClipboardEventTypes)
  98404. */
  98405. type: number;
  98406. /**
  98407. * Defines the related dom event
  98408. */
  98409. event: ClipboardEvent;
  98410. /**
  98411. *Creates an instance of ClipboardInfo.
  98412. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  98413. * @param event Defines the related dom event
  98414. */
  98415. constructor(
  98416. /**
  98417. * Defines the type of event (BABYLON.ClipboardEventTypes)
  98418. */
  98419. type: number,
  98420. /**
  98421. * Defines the related dom event
  98422. */
  98423. event: ClipboardEvent);
  98424. /**
  98425. * Get the clipboard event's type from the keycode.
  98426. * @param keyCode Defines the keyCode for the current keyboard event.
  98427. * @return {number}
  98428. */
  98429. static GetTypeFromCharacter(keyCode: number): number;
  98430. }
  98431. }
  98432. declare module BABYLON {
  98433. /**
  98434. * Class used to represent data loading progression
  98435. */
  98436. export class SceneLoaderProgressEvent {
  98437. /** defines if data length to load can be evaluated */
  98438. readonly lengthComputable: boolean;
  98439. /** defines the loaded data length */
  98440. readonly loaded: number;
  98441. /** defines the data length to load */
  98442. readonly total: number;
  98443. /**
  98444. * Create a new progress event
  98445. * @param lengthComputable defines if data length to load can be evaluated
  98446. * @param loaded defines the loaded data length
  98447. * @param total defines the data length to load
  98448. */
  98449. constructor(
  98450. /** defines if data length to load can be evaluated */
  98451. lengthComputable: boolean,
  98452. /** defines the loaded data length */
  98453. loaded: number,
  98454. /** defines the data length to load */
  98455. total: number);
  98456. /**
  98457. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  98458. * @param event defines the source event
  98459. * @returns a new SceneLoaderProgressEvent
  98460. */
  98461. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  98462. }
  98463. /**
  98464. * Interface used by SceneLoader plugins to define supported file extensions
  98465. */
  98466. export interface ISceneLoaderPluginExtensions {
  98467. /**
  98468. * Defines the list of supported extensions
  98469. */
  98470. [extension: string]: {
  98471. isBinary: boolean;
  98472. };
  98473. }
  98474. /**
  98475. * Interface used by SceneLoader plugin factory
  98476. */
  98477. export interface ISceneLoaderPluginFactory {
  98478. /**
  98479. * Defines the name of the factory
  98480. */
  98481. name: string;
  98482. /**
  98483. * Function called to create a new plugin
  98484. * @return the new plugin
  98485. */
  98486. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  98487. /**
  98488. * Boolean indicating if the plugin can direct load specific data
  98489. */
  98490. canDirectLoad?: (data: string) => boolean;
  98491. }
  98492. /**
  98493. * Interface used to define a SceneLoader plugin
  98494. */
  98495. export interface ISceneLoaderPlugin {
  98496. /**
  98497. * The friendly name of this plugin.
  98498. */
  98499. name: string;
  98500. /**
  98501. * The file extensions supported by this plugin.
  98502. */
  98503. extensions: string | ISceneLoaderPluginExtensions;
  98504. /**
  98505. * Import meshes into a scene.
  98506. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  98507. * @param scene The scene to import into
  98508. * @param data The data to import
  98509. * @param rootUrl The root url for scene and resources
  98510. * @param meshes The meshes array to import into
  98511. * @param particleSystems The particle systems array to import into
  98512. * @param skeletons The skeletons array to import into
  98513. * @param onError The callback when import fails
  98514. * @returns True if successful or false otherwise
  98515. */
  98516. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  98517. /**
  98518. * Load into a scene.
  98519. * @param scene The scene to load into
  98520. * @param data The data to import
  98521. * @param rootUrl The root url for scene and resources
  98522. * @param onError The callback when import fails
  98523. * @returns true if successful or false otherwise
  98524. */
  98525. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  98526. /**
  98527. * The callback that returns true if the data can be directly loaded.
  98528. */
  98529. canDirectLoad?: (data: string) => boolean;
  98530. /**
  98531. * The callback that allows custom handling of the root url based on the response url.
  98532. */
  98533. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  98534. /**
  98535. * Load into an asset container.
  98536. * @param scene The scene to load into
  98537. * @param data The data to import
  98538. * @param rootUrl The root url for scene and resources
  98539. * @param onError The callback when import fails
  98540. * @returns The loaded asset container
  98541. */
  98542. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  98543. }
  98544. /**
  98545. * Interface used to define an async SceneLoader plugin
  98546. */
  98547. export interface ISceneLoaderPluginAsync {
  98548. /**
  98549. * The friendly name of this plugin.
  98550. */
  98551. name: string;
  98552. /**
  98553. * The file extensions supported by this plugin.
  98554. */
  98555. extensions: string | ISceneLoaderPluginExtensions;
  98556. /**
  98557. * Import meshes into a scene.
  98558. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  98559. * @param scene The scene to import into
  98560. * @param data The data to import
  98561. * @param rootUrl The root url for scene and resources
  98562. * @param onProgress The callback when the load progresses
  98563. * @param fileName Defines the name of the file to load
  98564. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  98565. */
  98566. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  98567. meshes: AbstractMesh[];
  98568. particleSystems: IParticleSystem[];
  98569. skeletons: Skeleton[];
  98570. animationGroups: AnimationGroup[];
  98571. }>;
  98572. /**
  98573. * Load into a scene.
  98574. * @param scene The scene to load into
  98575. * @param data The data to import
  98576. * @param rootUrl The root url for scene and resources
  98577. * @param onProgress The callback when the load progresses
  98578. * @param fileName Defines the name of the file to load
  98579. * @returns Nothing
  98580. */
  98581. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  98582. /**
  98583. * The callback that returns true if the data can be directly loaded.
  98584. */
  98585. canDirectLoad?: (data: string) => boolean;
  98586. /**
  98587. * The callback that allows custom handling of the root url based on the response url.
  98588. */
  98589. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  98590. /**
  98591. * Load into an asset container.
  98592. * @param scene The scene to load into
  98593. * @param data The data to import
  98594. * @param rootUrl The root url for scene and resources
  98595. * @param onProgress The callback when the load progresses
  98596. * @param fileName Defines the name of the file to load
  98597. * @returns The loaded asset container
  98598. */
  98599. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  98600. }
  98601. /**
  98602. * Class used to load scene from various file formats using registered plugins
  98603. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  98604. */
  98605. export class SceneLoader {
  98606. /**
  98607. * No logging while loading
  98608. */
  98609. static readonly NO_LOGGING: number;
  98610. /**
  98611. * Minimal logging while loading
  98612. */
  98613. static readonly MINIMAL_LOGGING: number;
  98614. /**
  98615. * Summary logging while loading
  98616. */
  98617. static readonly SUMMARY_LOGGING: number;
  98618. /**
  98619. * Detailled logging while loading
  98620. */
  98621. static readonly DETAILED_LOGGING: number;
  98622. /**
  98623. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  98624. */
  98625. static ForceFullSceneLoadingForIncremental: boolean;
  98626. /**
  98627. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  98628. */
  98629. static ShowLoadingScreen: boolean;
  98630. /**
  98631. * Defines the current logging level (while loading the scene)
  98632. * @ignorenaming
  98633. */
  98634. static loggingLevel: number;
  98635. /**
  98636. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  98637. */
  98638. static CleanBoneMatrixWeights: boolean;
  98639. /**
  98640. * Event raised when a plugin is used to load a scene
  98641. */
  98642. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  98643. private static _registeredPlugins;
  98644. private static _getDefaultPlugin;
  98645. private static _getPluginForExtension;
  98646. private static _getPluginForDirectLoad;
  98647. private static _getPluginForFilename;
  98648. private static _getDirectLoad;
  98649. private static _loadData;
  98650. private static _getFileInfo;
  98651. /**
  98652. * Gets a plugin that can load the given extension
  98653. * @param extension defines the extension to load
  98654. * @returns a plugin or null if none works
  98655. */
  98656. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  98657. /**
  98658. * Gets a boolean indicating that the given extension can be loaded
  98659. * @param extension defines the extension to load
  98660. * @returns true if the extension is supported
  98661. */
  98662. static IsPluginForExtensionAvailable(extension: string): boolean;
  98663. /**
  98664. * Adds a new plugin to the list of registered plugins
  98665. * @param plugin defines the plugin to add
  98666. */
  98667. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  98668. /**
  98669. * Import meshes into a scene
  98670. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  98671. * @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)
  98672. * @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)
  98673. * @param scene the instance of BABYLON.Scene to append to
  98674. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  98675. * @param onProgress a callback with a progress event for each file being loaded
  98676. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  98677. * @param pluginExtension the extension used to determine the plugin
  98678. * @returns The loaded plugin
  98679. */
  98680. 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>;
  98681. /**
  98682. * Import meshes into a scene
  98683. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  98684. * @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)
  98685. * @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)
  98686. * @param scene the instance of BABYLON.Scene to append to
  98687. * @param onProgress a callback with a progress event for each file being loaded
  98688. * @param pluginExtension the extension used to determine the plugin
  98689. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  98690. */
  98691. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  98692. meshes: AbstractMesh[];
  98693. particleSystems: IParticleSystem[];
  98694. skeletons: Skeleton[];
  98695. animationGroups: AnimationGroup[];
  98696. }>;
  98697. /**
  98698. * Load a scene
  98699. * @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)
  98700. * @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)
  98701. * @param engine is the instance of BABYLON.Engine to use to create the scene
  98702. * @param onSuccess a callback with the scene when import succeeds
  98703. * @param onProgress a callback with a progress event for each file being loaded
  98704. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  98705. * @param pluginExtension the extension used to determine the plugin
  98706. * @returns The loaded plugin
  98707. */
  98708. 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>;
  98709. /**
  98710. * Load a scene
  98711. * @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)
  98712. * @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)
  98713. * @param engine is the instance of BABYLON.Engine to use to create the scene
  98714. * @param onProgress a callback with a progress event for each file being loaded
  98715. * @param pluginExtension the extension used to determine the plugin
  98716. * @returns The loaded scene
  98717. */
  98718. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  98719. /**
  98720. * Append a scene
  98721. * @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)
  98722. * @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)
  98723. * @param scene is the instance of BABYLON.Scene to append to
  98724. * @param onSuccess a callback with the scene when import succeeds
  98725. * @param onProgress a callback with a progress event for each file being loaded
  98726. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  98727. * @param pluginExtension the extension used to determine the plugin
  98728. * @returns The loaded plugin
  98729. */
  98730. 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>;
  98731. /**
  98732. * Append a scene
  98733. * @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)
  98734. * @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)
  98735. * @param scene is the instance of BABYLON.Scene to append to
  98736. * @param onProgress a callback with a progress event for each file being loaded
  98737. * @param pluginExtension the extension used to determine the plugin
  98738. * @returns The given scene
  98739. */
  98740. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  98741. /**
  98742. * Load a scene into an asset container
  98743. * @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)
  98744. * @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)
  98745. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  98746. * @param onSuccess a callback with the scene when import succeeds
  98747. * @param onProgress a callback with a progress event for each file being loaded
  98748. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  98749. * @param pluginExtension the extension used to determine the plugin
  98750. * @returns The loaded plugin
  98751. */
  98752. 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>;
  98753. /**
  98754. * Load a scene into an asset container
  98755. * @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)
  98756. * @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)
  98757. * @param scene is the instance of Scene to append to
  98758. * @param onProgress a callback with a progress event for each file being loaded
  98759. * @param pluginExtension the extension used to determine the plugin
  98760. * @returns The loaded asset container
  98761. */
  98762. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  98763. }
  98764. }
  98765. declare module BABYLON {
  98766. /**
  98767. * Google Daydream controller
  98768. */
  98769. export class DaydreamController extends WebVRController {
  98770. /**
  98771. * Base Url for the controller model.
  98772. */
  98773. static MODEL_BASE_URL: string;
  98774. /**
  98775. * File name for the controller model.
  98776. */
  98777. static MODEL_FILENAME: string;
  98778. /**
  98779. * Gamepad Id prefix used to identify Daydream Controller.
  98780. */
  98781. static readonly GAMEPAD_ID_PREFIX: string;
  98782. /**
  98783. * Creates a new DaydreamController from a gamepad
  98784. * @param vrGamepad the gamepad that the controller should be created from
  98785. */
  98786. constructor(vrGamepad: any);
  98787. /**
  98788. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  98789. * @param scene scene in which to add meshes
  98790. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  98791. */
  98792. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  98793. /**
  98794. * Called once for each button that changed state since the last frame
  98795. * @param buttonIdx Which button index changed
  98796. * @param state New state of the button
  98797. * @param changes Which properties on the state changed since last frame
  98798. */
  98799. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  98800. }
  98801. }
  98802. declare module BABYLON {
  98803. /**
  98804. * Gear VR Controller
  98805. */
  98806. export class GearVRController extends WebVRController {
  98807. /**
  98808. * Base Url for the controller model.
  98809. */
  98810. static MODEL_BASE_URL: string;
  98811. /**
  98812. * File name for the controller model.
  98813. */
  98814. static MODEL_FILENAME: string;
  98815. /**
  98816. * Gamepad Id prefix used to identify this controller.
  98817. */
  98818. static readonly GAMEPAD_ID_PREFIX: string;
  98819. private readonly _buttonIndexToObservableNameMap;
  98820. /**
  98821. * Creates a new GearVRController from a gamepad
  98822. * @param vrGamepad the gamepad that the controller should be created from
  98823. */
  98824. constructor(vrGamepad: any);
  98825. /**
  98826. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  98827. * @param scene scene in which to add meshes
  98828. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  98829. */
  98830. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  98831. /**
  98832. * Called once for each button that changed state since the last frame
  98833. * @param buttonIdx Which button index changed
  98834. * @param state New state of the button
  98835. * @param changes Which properties on the state changed since last frame
  98836. */
  98837. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  98838. }
  98839. }
  98840. declare module BABYLON {
  98841. /**
  98842. * Generic Controller
  98843. */
  98844. export class GenericController extends WebVRController {
  98845. /**
  98846. * Base Url for the controller model.
  98847. */
  98848. static readonly MODEL_BASE_URL: string;
  98849. /**
  98850. * File name for the controller model.
  98851. */
  98852. static readonly MODEL_FILENAME: string;
  98853. /**
  98854. * Creates a new GenericController from a gamepad
  98855. * @param vrGamepad the gamepad that the controller should be created from
  98856. */
  98857. constructor(vrGamepad: any);
  98858. /**
  98859. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  98860. * @param scene scene in which to add meshes
  98861. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  98862. */
  98863. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  98864. /**
  98865. * Called once for each button that changed state since the last frame
  98866. * @param buttonIdx Which button index changed
  98867. * @param state New state of the button
  98868. * @param changes Which properties on the state changed since last frame
  98869. */
  98870. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  98871. }
  98872. }
  98873. declare module BABYLON {
  98874. /**
  98875. * Oculus Touch Controller
  98876. */
  98877. export class OculusTouchController extends WebVRController {
  98878. /**
  98879. * Base Url for the controller model.
  98880. */
  98881. static MODEL_BASE_URL: string;
  98882. /**
  98883. * File name for the left controller model.
  98884. */
  98885. static MODEL_LEFT_FILENAME: string;
  98886. /**
  98887. * File name for the right controller model.
  98888. */
  98889. static MODEL_RIGHT_FILENAME: string;
  98890. /**
  98891. * Fired when the secondary trigger on this controller is modified
  98892. */
  98893. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  98894. /**
  98895. * Fired when the thumb rest on this controller is modified
  98896. */
  98897. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  98898. /**
  98899. * Creates a new OculusTouchController from a gamepad
  98900. * @param vrGamepad the gamepad that the controller should be created from
  98901. */
  98902. constructor(vrGamepad: any);
  98903. /**
  98904. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  98905. * @param scene scene in which to add meshes
  98906. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  98907. */
  98908. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  98909. /**
  98910. * Fired when the A button on this controller is modified
  98911. */
  98912. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  98913. /**
  98914. * Fired when the B button on this controller is modified
  98915. */
  98916. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  98917. /**
  98918. * Fired when the X button on this controller is modified
  98919. */
  98920. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  98921. /**
  98922. * Fired when the Y button on this controller is modified
  98923. */
  98924. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  98925. /**
  98926. * Called once for each button that changed state since the last frame
  98927. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  98928. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  98929. * 2) secondary trigger (same)
  98930. * 3) A (right) X (left), touch, pressed = value
  98931. * 4) B / Y
  98932. * 5) thumb rest
  98933. * @param buttonIdx Which button index changed
  98934. * @param state New state of the button
  98935. * @param changes Which properties on the state changed since last frame
  98936. */
  98937. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  98938. }
  98939. }
  98940. declare module BABYLON {
  98941. /**
  98942. * Vive Controller
  98943. */
  98944. export class ViveController extends WebVRController {
  98945. /**
  98946. * Base Url for the controller model.
  98947. */
  98948. static MODEL_BASE_URL: string;
  98949. /**
  98950. * File name for the controller model.
  98951. */
  98952. static MODEL_FILENAME: string;
  98953. /**
  98954. * Creates a new ViveController from a gamepad
  98955. * @param vrGamepad the gamepad that the controller should be created from
  98956. */
  98957. constructor(vrGamepad: any);
  98958. /**
  98959. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  98960. * @param scene scene in which to add meshes
  98961. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  98962. */
  98963. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  98964. /**
  98965. * Fired when the left button on this controller is modified
  98966. */
  98967. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  98968. /**
  98969. * Fired when the right button on this controller is modified
  98970. */
  98971. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  98972. /**
  98973. * Fired when the menu button on this controller is modified
  98974. */
  98975. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  98976. /**
  98977. * Called once for each button that changed state since the last frame
  98978. * Vive mapping:
  98979. * 0: touchpad
  98980. * 1: trigger
  98981. * 2: left AND right buttons
  98982. * 3: menu button
  98983. * @param buttonIdx Which button index changed
  98984. * @param state New state of the button
  98985. * @param changes Which properties on the state changed since last frame
  98986. */
  98987. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  98988. }
  98989. }
  98990. declare module BABYLON {
  98991. /**
  98992. * Defines the WindowsMotionController object that the state of the windows motion controller
  98993. */
  98994. export class WindowsMotionController extends WebVRController {
  98995. /**
  98996. * The base url used to load the left and right controller models
  98997. */
  98998. static MODEL_BASE_URL: string;
  98999. /**
  99000. * The name of the left controller model file
  99001. */
  99002. static MODEL_LEFT_FILENAME: string;
  99003. /**
  99004. * The name of the right controller model file
  99005. */
  99006. static MODEL_RIGHT_FILENAME: string;
  99007. /**
  99008. * The controller name prefix for this controller type
  99009. */
  99010. static readonly GAMEPAD_ID_PREFIX: string;
  99011. /**
  99012. * The controller id pattern for this controller type
  99013. */
  99014. private static readonly GAMEPAD_ID_PATTERN;
  99015. private _loadedMeshInfo;
  99016. private readonly _mapping;
  99017. /**
  99018. * Fired when the trackpad on this controller is clicked
  99019. */
  99020. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  99021. /**
  99022. * Fired when the trackpad on this controller is modified
  99023. */
  99024. onTrackpadValuesChangedObservable: Observable<StickValues>;
  99025. /**
  99026. * The current x and y values of this controller's trackpad
  99027. */
  99028. trackpad: StickValues;
  99029. /**
  99030. * Creates a new WindowsMotionController from a gamepad
  99031. * @param vrGamepad the gamepad that the controller should be created from
  99032. */
  99033. constructor(vrGamepad: any);
  99034. /**
  99035. * Fired when the trigger on this controller is modified
  99036. */
  99037. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  99038. /**
  99039. * Fired when the menu button on this controller is modified
  99040. */
  99041. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  99042. /**
  99043. * Fired when the grip button on this controller is modified
  99044. */
  99045. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  99046. /**
  99047. * Fired when the thumbstick button on this controller is modified
  99048. */
  99049. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  99050. /**
  99051. * Fired when the touchpad button on this controller is modified
  99052. */
  99053. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  99054. /**
  99055. * Fired when the touchpad values on this controller are modified
  99056. */
  99057. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  99058. private _updateTrackpad;
  99059. /**
  99060. * Called once per frame by the engine.
  99061. */
  99062. update(): void;
  99063. /**
  99064. * Called once for each button that changed state since the last frame
  99065. * @param buttonIdx Which button index changed
  99066. * @param state New state of the button
  99067. * @param changes Which properties on the state changed since last frame
  99068. */
  99069. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  99070. /**
  99071. * Moves the buttons on the controller mesh based on their current state
  99072. * @param buttonName the name of the button to move
  99073. * @param buttonValue the value of the button which determines the buttons new position
  99074. */
  99075. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  99076. /**
  99077. * Moves the axis on the controller mesh based on its current state
  99078. * @param axis the index of the axis
  99079. * @param axisValue the value of the axis which determines the meshes new position
  99080. * @hidden
  99081. */
  99082. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  99083. /**
  99084. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  99085. * @param scene scene in which to add meshes
  99086. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  99087. */
  99088. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  99089. /**
  99090. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  99091. * can be transformed by button presses and axes values, based on this._mapping.
  99092. *
  99093. * @param scene scene in which the meshes exist
  99094. * @param meshes list of meshes that make up the controller model to process
  99095. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  99096. */
  99097. private processModel;
  99098. private createMeshInfo;
  99099. /**
  99100. * Gets the ray of the controller in the direction the controller is pointing
  99101. * @param length the length the resulting ray should be
  99102. * @returns a ray in the direction the controller is pointing
  99103. */
  99104. getForwardRay(length?: number): Ray;
  99105. /**
  99106. * Disposes of the controller
  99107. */
  99108. dispose(): void;
  99109. }
  99110. }
  99111. declare module BABYLON {
  99112. /**
  99113. * Single axis scale gizmo
  99114. */
  99115. export class AxisScaleGizmo extends Gizmo {
  99116. private _coloredMaterial;
  99117. /**
  99118. * Drag behavior responsible for the gizmos dragging interactions
  99119. */
  99120. dragBehavior: PointerDragBehavior;
  99121. private _pointerObserver;
  99122. /**
  99123. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  99124. */
  99125. snapDistance: number;
  99126. /**
  99127. * Event that fires each time the gizmo snaps to a new location.
  99128. * * snapDistance is the the change in distance
  99129. */
  99130. onSnapObservable: Observable<{
  99131. snapDistance: number;
  99132. }>;
  99133. /**
  99134. * If the scaling operation should be done on all axis (default: false)
  99135. */
  99136. uniformScaling: boolean;
  99137. /**
  99138. * Creates an AxisScaleGizmo
  99139. * @param gizmoLayer The utility layer the gizmo will be added to
  99140. * @param dragAxis The axis which the gizmo will be able to scale on
  99141. * @param color The color of the gizmo
  99142. */
  99143. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  99144. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  99145. /**
  99146. * Disposes of the gizmo
  99147. */
  99148. dispose(): void;
  99149. /**
  99150. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  99151. * @param mesh The mesh to replace the default mesh of the gizmo
  99152. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  99153. */
  99154. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  99155. }
  99156. }
  99157. declare module BABYLON {
  99158. /**
  99159. * Bounding box gizmo
  99160. */
  99161. export class BoundingBoxGizmo extends Gizmo {
  99162. private _lineBoundingBox;
  99163. private _rotateSpheresParent;
  99164. private _scaleBoxesParent;
  99165. private _boundingDimensions;
  99166. private _renderObserver;
  99167. private _pointerObserver;
  99168. private _scaleDragSpeed;
  99169. private _tmpQuaternion;
  99170. private _tmpVector;
  99171. private _tmpRotationMatrix;
  99172. /**
  99173. * 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)
  99174. */
  99175. ignoreChildren: boolean;
  99176. /**
  99177. * 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)
  99178. */
  99179. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  99180. /**
  99181. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  99182. */
  99183. rotationSphereSize: number;
  99184. /**
  99185. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  99186. */
  99187. scaleBoxSize: number;
  99188. /**
  99189. * 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)
  99190. */
  99191. fixedDragMeshScreenSize: boolean;
  99192. /**
  99193. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  99194. */
  99195. fixedDragMeshScreenSizeDistanceFactor: number;
  99196. /**
  99197. * Fired when a rotation sphere or scale box is dragged
  99198. */
  99199. onDragStartObservable: Observable<{}>;
  99200. /**
  99201. * Fired when a scale box is dragged
  99202. */
  99203. onScaleBoxDragObservable: Observable<{}>;
  99204. /**
  99205. * Fired when a scale box drag is ended
  99206. */
  99207. onScaleBoxDragEndObservable: Observable<{}>;
  99208. /**
  99209. * Fired when a rotation sphere is dragged
  99210. */
  99211. onRotationSphereDragObservable: Observable<{}>;
  99212. /**
  99213. * Fired when a rotation sphere drag is ended
  99214. */
  99215. onRotationSphereDragEndObservable: Observable<{}>;
  99216. /**
  99217. * 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)
  99218. */
  99219. scalePivot: Nullable<Vector3>;
  99220. private _anchorMesh;
  99221. private _existingMeshScale;
  99222. private _dragMesh;
  99223. private pointerDragBehavior;
  99224. private coloredMaterial;
  99225. private hoverColoredMaterial;
  99226. /**
  99227. * Sets the color of the bounding box gizmo
  99228. * @param color the color to set
  99229. */
  99230. setColor(color: Color3): void;
  99231. /**
  99232. * Creates an BoundingBoxGizmo
  99233. * @param gizmoLayer The utility layer the gizmo will be added to
  99234. * @param color The color of the gizmo
  99235. */
  99236. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  99237. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  99238. private _selectNode;
  99239. /**
  99240. * Updates the bounding box information for the Gizmo
  99241. */
  99242. updateBoundingBox(): void;
  99243. private _updateRotationSpheres;
  99244. private _updateScaleBoxes;
  99245. /**
  99246. * Enables rotation on the specified axis and disables rotation on the others
  99247. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  99248. */
  99249. setEnabledRotationAxis(axis: string): void;
  99250. /**
  99251. * Enables/disables scaling
  99252. * @param enable if scaling should be enabled
  99253. */
  99254. setEnabledScaling(enable: boolean): void;
  99255. private _updateDummy;
  99256. /**
  99257. * Enables a pointer drag behavior on the bounding box of the gizmo
  99258. */
  99259. enableDragBehavior(): void;
  99260. /**
  99261. * Disposes of the gizmo
  99262. */
  99263. dispose(): void;
  99264. /**
  99265. * 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)
  99266. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  99267. * @returns the bounding box mesh with the passed in mesh as a child
  99268. */
  99269. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  99270. /**
  99271. * CustomMeshes are not supported by this gizmo
  99272. * @param mesh The mesh to replace the default mesh of the gizmo
  99273. */
  99274. setCustomMesh(mesh: Mesh): void;
  99275. }
  99276. }
  99277. declare module BABYLON {
  99278. /**
  99279. * Single plane rotation gizmo
  99280. */
  99281. export class PlaneRotationGizmo extends Gizmo {
  99282. /**
  99283. * Drag behavior responsible for the gizmos dragging interactions
  99284. */
  99285. dragBehavior: PointerDragBehavior;
  99286. private _pointerObserver;
  99287. /**
  99288. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  99289. */
  99290. snapDistance: number;
  99291. /**
  99292. * Event that fires each time the gizmo snaps to a new location.
  99293. * * snapDistance is the the change in distance
  99294. */
  99295. onSnapObservable: Observable<{
  99296. snapDistance: number;
  99297. }>;
  99298. /**
  99299. * Creates a PlaneRotationGizmo
  99300. * @param gizmoLayer The utility layer the gizmo will be added to
  99301. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  99302. * @param color The color of the gizmo
  99303. * @param tessellation Amount of tessellation to be used when creating rotation circles
  99304. */
  99305. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  99306. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  99307. /**
  99308. * Disposes of the gizmo
  99309. */
  99310. dispose(): void;
  99311. }
  99312. }
  99313. declare module BABYLON {
  99314. /**
  99315. * Gizmo that enables rotating a mesh along 3 axis
  99316. */
  99317. export class RotationGizmo extends Gizmo {
  99318. /**
  99319. * Internal gizmo used for interactions on the x axis
  99320. */
  99321. xGizmo: PlaneRotationGizmo;
  99322. /**
  99323. * Internal gizmo used for interactions on the y axis
  99324. */
  99325. yGizmo: PlaneRotationGizmo;
  99326. /**
  99327. * Internal gizmo used for interactions on the z axis
  99328. */
  99329. zGizmo: PlaneRotationGizmo;
  99330. /** Fires an event when any of it's sub gizmos are dragged */
  99331. onDragStartObservable: Observable<{}>;
  99332. /** Fires an event when any of it's sub gizmos are released from dragging */
  99333. onDragEndObservable: Observable<{}>;
  99334. attachedMesh: Nullable<AbstractMesh>;
  99335. /**
  99336. * Creates a RotationGizmo
  99337. * @param gizmoLayer The utility layer the gizmo will be added to
  99338. * @param tessellation Amount of tessellation to be used when creating rotation circles
  99339. */
  99340. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  99341. updateGizmoRotationToMatchAttachedMesh: boolean;
  99342. /**
  99343. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  99344. */
  99345. snapDistance: number;
  99346. /**
  99347. * Ratio for the scale of the gizmo (Default: 1)
  99348. */
  99349. scaleRatio: number;
  99350. /**
  99351. * Disposes of the gizmo
  99352. */
  99353. dispose(): void;
  99354. /**
  99355. * CustomMeshes are not supported by this gizmo
  99356. * @param mesh The mesh to replace the default mesh of the gizmo
  99357. */
  99358. setCustomMesh(mesh: Mesh): void;
  99359. }
  99360. }
  99361. declare module BABYLON {
  99362. /**
  99363. * Gizmo that enables dragging a mesh along 3 axis
  99364. */
  99365. export class PositionGizmo extends Gizmo {
  99366. /**
  99367. * Internal gizmo used for interactions on the x axis
  99368. */
  99369. xGizmo: AxisDragGizmo;
  99370. /**
  99371. * Internal gizmo used for interactions on the y axis
  99372. */
  99373. yGizmo: AxisDragGizmo;
  99374. /**
  99375. * Internal gizmo used for interactions on the z axis
  99376. */
  99377. zGizmo: AxisDragGizmo;
  99378. /** Fires an event when any of it's sub gizmos are dragged */
  99379. onDragStartObservable: Observable<{}>;
  99380. /** Fires an event when any of it's sub gizmos are released from dragging */
  99381. onDragEndObservable: Observable<{}>;
  99382. attachedMesh: Nullable<AbstractMesh>;
  99383. /**
  99384. * Creates a PositionGizmo
  99385. * @param gizmoLayer The utility layer the gizmo will be added to
  99386. */
  99387. constructor(gizmoLayer?: UtilityLayerRenderer);
  99388. updateGizmoRotationToMatchAttachedMesh: boolean;
  99389. /**
  99390. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  99391. */
  99392. snapDistance: number;
  99393. /**
  99394. * Ratio for the scale of the gizmo (Default: 1)
  99395. */
  99396. scaleRatio: number;
  99397. /**
  99398. * Disposes of the gizmo
  99399. */
  99400. dispose(): void;
  99401. /**
  99402. * CustomMeshes are not supported by this gizmo
  99403. * @param mesh The mesh to replace the default mesh of the gizmo
  99404. */
  99405. setCustomMesh(mesh: Mesh): void;
  99406. }
  99407. }
  99408. declare module BABYLON {
  99409. /**
  99410. * Class containing static functions to help procedurally build meshes
  99411. */
  99412. export class PolyhedronBuilder {
  99413. /**
  99414. * Creates a polyhedron mesh
  99415. * * 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
  99416. * * The parameter `size` (positive float, default 1) sets the polygon size
  99417. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  99418. * * 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`
  99419. * * 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
  99420. * * 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)`)
  99421. * * 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
  99422. * * 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
  99423. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  99424. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  99425. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  99426. * @param name defines the name of the mesh
  99427. * @param options defines the options used to create the mesh
  99428. * @param scene defines the hosting scene
  99429. * @returns the polyhedron mesh
  99430. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  99431. */
  99432. static CreatePolyhedron(name: string, options: {
  99433. type?: number;
  99434. size?: number;
  99435. sizeX?: number;
  99436. sizeY?: number;
  99437. sizeZ?: number;
  99438. custom?: any;
  99439. faceUV?: Vector4[];
  99440. faceColors?: Color4[];
  99441. flat?: boolean;
  99442. updatable?: boolean;
  99443. sideOrientation?: number;
  99444. frontUVs?: Vector4;
  99445. backUVs?: Vector4;
  99446. }, scene: Scene): Mesh;
  99447. }
  99448. }
  99449. declare module BABYLON {
  99450. /**
  99451. * Gizmo that enables scaling a mesh along 3 axis
  99452. */
  99453. export class ScaleGizmo extends Gizmo {
  99454. /**
  99455. * Internal gizmo used for interactions on the x axis
  99456. */
  99457. xGizmo: AxisScaleGizmo;
  99458. /**
  99459. * Internal gizmo used for interactions on the y axis
  99460. */
  99461. yGizmo: AxisScaleGizmo;
  99462. /**
  99463. * Internal gizmo used for interactions on the z axis
  99464. */
  99465. zGizmo: AxisScaleGizmo;
  99466. /**
  99467. * Internal gizmo used to scale all axis equally
  99468. */
  99469. uniformScaleGizmo: AxisScaleGizmo;
  99470. /** Fires an event when any of it's sub gizmos are dragged */
  99471. onDragStartObservable: Observable<{}>;
  99472. /** Fires an event when any of it's sub gizmos are released from dragging */
  99473. onDragEndObservable: Observable<{}>;
  99474. attachedMesh: Nullable<AbstractMesh>;
  99475. /**
  99476. * Creates a ScaleGizmo
  99477. * @param gizmoLayer The utility layer the gizmo will be added to
  99478. */
  99479. constructor(gizmoLayer?: UtilityLayerRenderer);
  99480. updateGizmoRotationToMatchAttachedMesh: boolean;
  99481. /**
  99482. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  99483. */
  99484. snapDistance: number;
  99485. /**
  99486. * Ratio for the scale of the gizmo (Default: 1)
  99487. */
  99488. scaleRatio: number;
  99489. /**
  99490. * Disposes of the gizmo
  99491. */
  99492. dispose(): void;
  99493. }
  99494. }
  99495. declare module BABYLON {
  99496. /**
  99497. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  99498. */
  99499. export class GizmoManager implements IDisposable {
  99500. private scene;
  99501. /**
  99502. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  99503. */
  99504. gizmos: {
  99505. positionGizmo: Nullable<PositionGizmo>;
  99506. rotationGizmo: Nullable<RotationGizmo>;
  99507. scaleGizmo: Nullable<ScaleGizmo>;
  99508. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  99509. };
  99510. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  99511. clearGizmoOnEmptyPointerEvent: boolean;
  99512. /** Fires an event when the manager is attached to a mesh */
  99513. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  99514. private _gizmosEnabled;
  99515. private _pointerObserver;
  99516. private _attachedMesh;
  99517. private _boundingBoxColor;
  99518. private _defaultUtilityLayer;
  99519. private _defaultKeepDepthUtilityLayer;
  99520. /**
  99521. * When bounding box gizmo is enabled, this can be used to track drag/end events
  99522. */
  99523. boundingBoxDragBehavior: SixDofDragBehavior;
  99524. /**
  99525. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  99526. */
  99527. attachableMeshes: Nullable<Array<AbstractMesh>>;
  99528. /**
  99529. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  99530. */
  99531. usePointerToAttachGizmos: boolean;
  99532. /**
  99533. * Instatiates a gizmo manager
  99534. * @param scene the scene to overlay the gizmos on top of
  99535. */
  99536. constructor(scene: Scene);
  99537. /**
  99538. * Attaches a set of gizmos to the specified mesh
  99539. * @param mesh The mesh the gizmo's should be attached to
  99540. */
  99541. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  99542. /**
  99543. * If the position gizmo is enabled
  99544. */
  99545. positionGizmoEnabled: boolean;
  99546. /**
  99547. * If the rotation gizmo is enabled
  99548. */
  99549. rotationGizmoEnabled: boolean;
  99550. /**
  99551. * If the scale gizmo is enabled
  99552. */
  99553. scaleGizmoEnabled: boolean;
  99554. /**
  99555. * If the boundingBox gizmo is enabled
  99556. */
  99557. boundingBoxGizmoEnabled: boolean;
  99558. /**
  99559. * Disposes of the gizmo manager
  99560. */
  99561. dispose(): void;
  99562. }
  99563. }
  99564. declare module BABYLON {
  99565. /**
  99566. * Gizmo that enables viewing a light
  99567. */
  99568. export class LightGizmo extends Gizmo {
  99569. private _box;
  99570. /**
  99571. * Creates a LightGizmo
  99572. * @param gizmoLayer The utility layer the gizmo will be added to
  99573. */
  99574. constructor(gizmoLayer?: UtilityLayerRenderer);
  99575. private _light;
  99576. /**
  99577. * The light that the gizmo is attached to
  99578. */
  99579. light: Nullable<Light>;
  99580. /**
  99581. * @hidden
  99582. * Updates the gizmo to match the attached mesh's position/rotation
  99583. */
  99584. protected _update(): void;
  99585. }
  99586. }
  99587. declare module BABYLON {
  99588. /** @hidden */
  99589. export var backgroundFragmentDeclaration: {
  99590. name: string;
  99591. shader: string;
  99592. };
  99593. }
  99594. declare module BABYLON {
  99595. /** @hidden */
  99596. export var backgroundUboDeclaration: {
  99597. name: string;
  99598. shader: string;
  99599. };
  99600. }
  99601. declare module BABYLON {
  99602. /** @hidden */
  99603. export var backgroundPixelShader: {
  99604. name: string;
  99605. shader: string;
  99606. };
  99607. }
  99608. declare module BABYLON {
  99609. /** @hidden */
  99610. export var backgroundVertexDeclaration: {
  99611. name: string;
  99612. shader: string;
  99613. };
  99614. }
  99615. declare module BABYLON {
  99616. /** @hidden */
  99617. export var backgroundVertexShader: {
  99618. name: string;
  99619. shader: string;
  99620. };
  99621. }
  99622. declare module BABYLON {
  99623. /**
  99624. * Background material used to create an efficient environement around your scene.
  99625. */
  99626. export class BackgroundMaterial extends PushMaterial {
  99627. /**
  99628. * Standard reflectance value at parallel view angle.
  99629. */
  99630. static StandardReflectance0: number;
  99631. /**
  99632. * Standard reflectance value at grazing angle.
  99633. */
  99634. static StandardReflectance90: number;
  99635. protected _primaryColor: Color3;
  99636. /**
  99637. * Key light Color (multiply against the environement texture)
  99638. */
  99639. primaryColor: Color3;
  99640. protected __perceptualColor: Nullable<Color3>;
  99641. /**
  99642. * Experimental Internal Use Only.
  99643. *
  99644. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  99645. * This acts as a helper to set the primary color to a more "human friendly" value.
  99646. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  99647. * output color as close as possible from the chosen value.
  99648. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  99649. * part of lighting setup.)
  99650. */
  99651. _perceptualColor: Nullable<Color3>;
  99652. protected _primaryColorShadowLevel: float;
  99653. /**
  99654. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  99655. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  99656. */
  99657. primaryColorShadowLevel: float;
  99658. protected _primaryColorHighlightLevel: float;
  99659. /**
  99660. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  99661. * The primary color is used at the level chosen to define what the white area would look.
  99662. */
  99663. primaryColorHighlightLevel: float;
  99664. protected _reflectionTexture: Nullable<BaseTexture>;
  99665. /**
  99666. * Reflection Texture used in the material.
  99667. * Should be author in a specific way for the best result (refer to the documentation).
  99668. */
  99669. reflectionTexture: Nullable<BaseTexture>;
  99670. protected _reflectionBlur: float;
  99671. /**
  99672. * Reflection Texture level of blur.
  99673. *
  99674. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  99675. * texture twice.
  99676. */
  99677. reflectionBlur: float;
  99678. protected _diffuseTexture: Nullable<BaseTexture>;
  99679. /**
  99680. * Diffuse Texture used in the material.
  99681. * Should be author in a specific way for the best result (refer to the documentation).
  99682. */
  99683. diffuseTexture: Nullable<BaseTexture>;
  99684. protected _shadowLights: Nullable<IShadowLight[]>;
  99685. /**
  99686. * Specify the list of lights casting shadow on the material.
  99687. * All scene shadow lights will be included if null.
  99688. */
  99689. shadowLights: Nullable<IShadowLight[]>;
  99690. protected _shadowLevel: float;
  99691. /**
  99692. * Helps adjusting the shadow to a softer level if required.
  99693. * 0 means black shadows and 1 means no shadows.
  99694. */
  99695. shadowLevel: float;
  99696. protected _sceneCenter: Vector3;
  99697. /**
  99698. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  99699. * It is usually zero but might be interesting to modify according to your setup.
  99700. */
  99701. sceneCenter: Vector3;
  99702. protected _opacityFresnel: boolean;
  99703. /**
  99704. * This helps specifying that the material is falling off to the sky box at grazing angle.
  99705. * This helps ensuring a nice transition when the camera goes under the ground.
  99706. */
  99707. opacityFresnel: boolean;
  99708. protected _reflectionFresnel: boolean;
  99709. /**
  99710. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  99711. * This helps adding a mirror texture on the ground.
  99712. */
  99713. reflectionFresnel: boolean;
  99714. protected _reflectionFalloffDistance: number;
  99715. /**
  99716. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  99717. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  99718. */
  99719. reflectionFalloffDistance: number;
  99720. protected _reflectionAmount: number;
  99721. /**
  99722. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  99723. */
  99724. reflectionAmount: number;
  99725. protected _reflectionReflectance0: number;
  99726. /**
  99727. * This specifies the weight of the reflection at grazing angle.
  99728. */
  99729. reflectionReflectance0: number;
  99730. protected _reflectionReflectance90: number;
  99731. /**
  99732. * This specifies the weight of the reflection at a perpendicular point of view.
  99733. */
  99734. reflectionReflectance90: number;
  99735. /**
  99736. * Sets the reflection reflectance fresnel values according to the default standard
  99737. * empirically know to work well :-)
  99738. */
  99739. reflectionStandardFresnelWeight: number;
  99740. protected _useRGBColor: boolean;
  99741. /**
  99742. * Helps to directly use the maps channels instead of their level.
  99743. */
  99744. useRGBColor: boolean;
  99745. protected _enableNoise: boolean;
  99746. /**
  99747. * This helps reducing the banding effect that could occur on the background.
  99748. */
  99749. enableNoise: boolean;
  99750. /**
  99751. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  99752. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  99753. * Recommended to be keep at 1.0 except for special cases.
  99754. */
  99755. fovMultiplier: number;
  99756. private _fovMultiplier;
  99757. /**
  99758. * Enable the FOV adjustment feature controlled by fovMultiplier.
  99759. */
  99760. useEquirectangularFOV: boolean;
  99761. private _maxSimultaneousLights;
  99762. /**
  99763. * Number of Simultaneous lights allowed on the material.
  99764. */
  99765. maxSimultaneousLights: int;
  99766. /**
  99767. * Default configuration related to image processing available in the Background Material.
  99768. */
  99769. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  99770. /**
  99771. * Keep track of the image processing observer to allow dispose and replace.
  99772. */
  99773. private _imageProcessingObserver;
  99774. /**
  99775. * Attaches a new image processing configuration to the PBR Material.
  99776. * @param configuration (if null the scene configuration will be use)
  99777. */
  99778. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  99779. /**
  99780. * Gets the image processing configuration used either in this material.
  99781. */
  99782. /**
  99783. * Sets the Default image processing configuration used either in the this material.
  99784. *
  99785. * If sets to null, the scene one is in use.
  99786. */
  99787. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  99788. /**
  99789. * Gets wether the color curves effect is enabled.
  99790. */
  99791. /**
  99792. * Sets wether the color curves effect is enabled.
  99793. */
  99794. cameraColorCurvesEnabled: boolean;
  99795. /**
  99796. * Gets wether the color grading effect is enabled.
  99797. */
  99798. /**
  99799. * Gets wether the color grading effect is enabled.
  99800. */
  99801. cameraColorGradingEnabled: boolean;
  99802. /**
  99803. * Gets wether tonemapping is enabled or not.
  99804. */
  99805. /**
  99806. * Sets wether tonemapping is enabled or not
  99807. */
  99808. cameraToneMappingEnabled: boolean;
  99809. /**
  99810. * The camera exposure used on this material.
  99811. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  99812. * This corresponds to a photographic exposure.
  99813. */
  99814. /**
  99815. * The camera exposure used on this material.
  99816. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  99817. * This corresponds to a photographic exposure.
  99818. */
  99819. cameraExposure: float;
  99820. /**
  99821. * Gets The camera contrast used on this material.
  99822. */
  99823. /**
  99824. * Sets The camera contrast used on this material.
  99825. */
  99826. cameraContrast: float;
  99827. /**
  99828. * Gets the Color Grading 2D Lookup Texture.
  99829. */
  99830. /**
  99831. * Sets the Color Grading 2D Lookup Texture.
  99832. */
  99833. cameraColorGradingTexture: Nullable<BaseTexture>;
  99834. /**
  99835. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  99836. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  99837. * 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;
  99838. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  99839. */
  99840. /**
  99841. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  99842. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  99843. * 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;
  99844. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  99845. */
  99846. cameraColorCurves: Nullable<ColorCurves>;
  99847. /**
  99848. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  99849. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  99850. */
  99851. switchToBGR: boolean;
  99852. private _renderTargets;
  99853. private _reflectionControls;
  99854. private _white;
  99855. private _primaryShadowColor;
  99856. private _primaryHighlightColor;
  99857. /**
  99858. * Instantiates a Background Material in the given scene
  99859. * @param name The friendly name of the material
  99860. * @param scene The scene to add the material to
  99861. */
  99862. constructor(name: string, scene: Scene);
  99863. /**
  99864. * Gets a boolean indicating that current material needs to register RTT
  99865. */
  99866. readonly hasRenderTargetTextures: boolean;
  99867. /**
  99868. * The entire material has been created in order to prevent overdraw.
  99869. * @returns false
  99870. */
  99871. needAlphaTesting(): boolean;
  99872. /**
  99873. * The entire material has been created in order to prevent overdraw.
  99874. * @returns true if blending is enable
  99875. */
  99876. needAlphaBlending(): boolean;
  99877. /**
  99878. * Checks wether the material is ready to be rendered for a given mesh.
  99879. * @param mesh The mesh to render
  99880. * @param subMesh The submesh to check against
  99881. * @param useInstances Specify wether or not the material is used with instances
  99882. * @returns true if all the dependencies are ready (Textures, Effects...)
  99883. */
  99884. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  99885. /**
  99886. * Compute the primary color according to the chosen perceptual color.
  99887. */
  99888. private _computePrimaryColorFromPerceptualColor;
  99889. /**
  99890. * Compute the highlights and shadow colors according to their chosen levels.
  99891. */
  99892. private _computePrimaryColors;
  99893. /**
  99894. * Build the uniform buffer used in the material.
  99895. */
  99896. buildUniformLayout(): void;
  99897. /**
  99898. * Unbind the material.
  99899. */
  99900. unbind(): void;
  99901. /**
  99902. * Bind only the world matrix to the material.
  99903. * @param world The world matrix to bind.
  99904. */
  99905. bindOnlyWorldMatrix(world: Matrix): void;
  99906. /**
  99907. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  99908. * @param world The world matrix to bind.
  99909. * @param subMesh The submesh to bind for.
  99910. */
  99911. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  99912. /**
  99913. * Dispose the material.
  99914. * @param forceDisposeEffect Force disposal of the associated effect.
  99915. * @param forceDisposeTextures Force disposal of the associated textures.
  99916. */
  99917. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  99918. /**
  99919. * Clones the material.
  99920. * @param name The cloned name.
  99921. * @returns The cloned material.
  99922. */
  99923. clone(name: string): BackgroundMaterial;
  99924. /**
  99925. * Serializes the current material to its JSON representation.
  99926. * @returns The JSON representation.
  99927. */
  99928. serialize(): any;
  99929. /**
  99930. * Gets the class name of the material
  99931. * @returns "BackgroundMaterial"
  99932. */
  99933. getClassName(): string;
  99934. /**
  99935. * Parse a JSON input to create back a background material.
  99936. * @param source The JSON data to parse
  99937. * @param scene The scene to create the parsed material in
  99938. * @param rootUrl The root url of the assets the material depends upon
  99939. * @returns the instantiated BackgroundMaterial.
  99940. */
  99941. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  99942. }
  99943. }
  99944. declare module BABYLON {
  99945. /**
  99946. * Represents the different options available during the creation of
  99947. * a Environment helper.
  99948. *
  99949. * This can control the default ground, skybox and image processing setup of your scene.
  99950. */
  99951. export interface IEnvironmentHelperOptions {
  99952. /**
  99953. * Specifies wether or not to create a ground.
  99954. * True by default.
  99955. */
  99956. createGround: boolean;
  99957. /**
  99958. * Specifies the ground size.
  99959. * 15 by default.
  99960. */
  99961. groundSize: number;
  99962. /**
  99963. * The texture used on the ground for the main color.
  99964. * Comes from the BabylonJS CDN by default.
  99965. *
  99966. * Remarks: Can be either a texture or a url.
  99967. */
  99968. groundTexture: string | BaseTexture;
  99969. /**
  99970. * The color mixed in the ground texture by default.
  99971. * BabylonJS clearColor by default.
  99972. */
  99973. groundColor: Color3;
  99974. /**
  99975. * Specifies the ground opacity.
  99976. * 1 by default.
  99977. */
  99978. groundOpacity: number;
  99979. /**
  99980. * Enables the ground to receive shadows.
  99981. * True by default.
  99982. */
  99983. enableGroundShadow: boolean;
  99984. /**
  99985. * Helps preventing the shadow to be fully black on the ground.
  99986. * 0.5 by default.
  99987. */
  99988. groundShadowLevel: number;
  99989. /**
  99990. * Creates a mirror texture attach to the ground.
  99991. * false by default.
  99992. */
  99993. enableGroundMirror: boolean;
  99994. /**
  99995. * Specifies the ground mirror size ratio.
  99996. * 0.3 by default as the default kernel is 64.
  99997. */
  99998. groundMirrorSizeRatio: number;
  99999. /**
  100000. * Specifies the ground mirror blur kernel size.
  100001. * 64 by default.
  100002. */
  100003. groundMirrorBlurKernel: number;
  100004. /**
  100005. * Specifies the ground mirror visibility amount.
  100006. * 1 by default
  100007. */
  100008. groundMirrorAmount: number;
  100009. /**
  100010. * Specifies the ground mirror reflectance weight.
  100011. * This uses the standard weight of the background material to setup the fresnel effect
  100012. * of the mirror.
  100013. * 1 by default.
  100014. */
  100015. groundMirrorFresnelWeight: number;
  100016. /**
  100017. * Specifies the ground mirror Falloff distance.
  100018. * This can helps reducing the size of the reflection.
  100019. * 0 by Default.
  100020. */
  100021. groundMirrorFallOffDistance: number;
  100022. /**
  100023. * Specifies the ground mirror texture type.
  100024. * Unsigned Int by Default.
  100025. */
  100026. groundMirrorTextureType: number;
  100027. /**
  100028. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  100029. * the shown objects.
  100030. */
  100031. groundYBias: number;
  100032. /**
  100033. * Specifies wether or not to create a skybox.
  100034. * True by default.
  100035. */
  100036. createSkybox: boolean;
  100037. /**
  100038. * Specifies the skybox size.
  100039. * 20 by default.
  100040. */
  100041. skyboxSize: number;
  100042. /**
  100043. * The texture used on the skybox for the main color.
  100044. * Comes from the BabylonJS CDN by default.
  100045. *
  100046. * Remarks: Can be either a texture or a url.
  100047. */
  100048. skyboxTexture: string | BaseTexture;
  100049. /**
  100050. * The color mixed in the skybox texture by default.
  100051. * BabylonJS clearColor by default.
  100052. */
  100053. skyboxColor: Color3;
  100054. /**
  100055. * The background rotation around the Y axis of the scene.
  100056. * This helps aligning the key lights of your scene with the background.
  100057. * 0 by default.
  100058. */
  100059. backgroundYRotation: number;
  100060. /**
  100061. * Compute automatically the size of the elements to best fit with the scene.
  100062. */
  100063. sizeAuto: boolean;
  100064. /**
  100065. * Default position of the rootMesh if autoSize is not true.
  100066. */
  100067. rootPosition: Vector3;
  100068. /**
  100069. * Sets up the image processing in the scene.
  100070. * true by default.
  100071. */
  100072. setupImageProcessing: boolean;
  100073. /**
  100074. * The texture used as your environment texture in the scene.
  100075. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  100076. *
  100077. * Remarks: Can be either a texture or a url.
  100078. */
  100079. environmentTexture: string | BaseTexture;
  100080. /**
  100081. * The value of the exposure to apply to the scene.
  100082. * 0.6 by default if setupImageProcessing is true.
  100083. */
  100084. cameraExposure: number;
  100085. /**
  100086. * The value of the contrast to apply to the scene.
  100087. * 1.6 by default if setupImageProcessing is true.
  100088. */
  100089. cameraContrast: number;
  100090. /**
  100091. * Specifies wether or not tonemapping should be enabled in the scene.
  100092. * true by default if setupImageProcessing is true.
  100093. */
  100094. toneMappingEnabled: boolean;
  100095. }
  100096. /**
  100097. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  100098. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  100099. * It also helps with the default setup of your imageProcessing configuration.
  100100. */
  100101. export class EnvironmentHelper {
  100102. /**
  100103. * Default ground texture URL.
  100104. */
  100105. private static _groundTextureCDNUrl;
  100106. /**
  100107. * Default skybox texture URL.
  100108. */
  100109. private static _skyboxTextureCDNUrl;
  100110. /**
  100111. * Default environment texture URL.
  100112. */
  100113. private static _environmentTextureCDNUrl;
  100114. /**
  100115. * Creates the default options for the helper.
  100116. */
  100117. private static _getDefaultOptions;
  100118. private _rootMesh;
  100119. /**
  100120. * Gets the root mesh created by the helper.
  100121. */
  100122. readonly rootMesh: Mesh;
  100123. private _skybox;
  100124. /**
  100125. * Gets the skybox created by the helper.
  100126. */
  100127. readonly skybox: Nullable<Mesh>;
  100128. private _skyboxTexture;
  100129. /**
  100130. * Gets the skybox texture created by the helper.
  100131. */
  100132. readonly skyboxTexture: Nullable<BaseTexture>;
  100133. private _skyboxMaterial;
  100134. /**
  100135. * Gets the skybox material created by the helper.
  100136. */
  100137. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  100138. private _ground;
  100139. /**
  100140. * Gets the ground mesh created by the helper.
  100141. */
  100142. readonly ground: Nullable<Mesh>;
  100143. private _groundTexture;
  100144. /**
  100145. * Gets the ground texture created by the helper.
  100146. */
  100147. readonly groundTexture: Nullable<BaseTexture>;
  100148. private _groundMirror;
  100149. /**
  100150. * Gets the ground mirror created by the helper.
  100151. */
  100152. readonly groundMirror: Nullable<MirrorTexture>;
  100153. /**
  100154. * Gets the ground mirror render list to helps pushing the meshes
  100155. * you wish in the ground reflection.
  100156. */
  100157. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  100158. private _groundMaterial;
  100159. /**
  100160. * Gets the ground material created by the helper.
  100161. */
  100162. readonly groundMaterial: Nullable<BackgroundMaterial>;
  100163. /**
  100164. * Stores the creation options.
  100165. */
  100166. private readonly _scene;
  100167. private _options;
  100168. /**
  100169. * This observable will be notified with any error during the creation of the environment,
  100170. * mainly texture creation errors.
  100171. */
  100172. onErrorObservable: Observable<{
  100173. message?: string;
  100174. exception?: any;
  100175. }>;
  100176. /**
  100177. * constructor
  100178. * @param options Defines the options we want to customize the helper
  100179. * @param scene The scene to add the material to
  100180. */
  100181. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  100182. /**
  100183. * Updates the background according to the new options
  100184. * @param options
  100185. */
  100186. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  100187. /**
  100188. * Sets the primary color of all the available elements.
  100189. * @param color the main color to affect to the ground and the background
  100190. */
  100191. setMainColor(color: Color3): void;
  100192. /**
  100193. * Setup the image processing according to the specified options.
  100194. */
  100195. private _setupImageProcessing;
  100196. /**
  100197. * Setup the environment texture according to the specified options.
  100198. */
  100199. private _setupEnvironmentTexture;
  100200. /**
  100201. * Setup the background according to the specified options.
  100202. */
  100203. private _setupBackground;
  100204. /**
  100205. * Get the scene sizes according to the setup.
  100206. */
  100207. private _getSceneSize;
  100208. /**
  100209. * Setup the ground according to the specified options.
  100210. */
  100211. private _setupGround;
  100212. /**
  100213. * Setup the ground material according to the specified options.
  100214. */
  100215. private _setupGroundMaterial;
  100216. /**
  100217. * Setup the ground diffuse texture according to the specified options.
  100218. */
  100219. private _setupGroundDiffuseTexture;
  100220. /**
  100221. * Setup the ground mirror texture according to the specified options.
  100222. */
  100223. private _setupGroundMirrorTexture;
  100224. /**
  100225. * Setup the ground to receive the mirror texture.
  100226. */
  100227. private _setupMirrorInGroundMaterial;
  100228. /**
  100229. * Setup the skybox according to the specified options.
  100230. */
  100231. private _setupSkybox;
  100232. /**
  100233. * Setup the skybox material according to the specified options.
  100234. */
  100235. private _setupSkyboxMaterial;
  100236. /**
  100237. * Setup the skybox reflection texture according to the specified options.
  100238. */
  100239. private _setupSkyboxReflectionTexture;
  100240. private _errorHandler;
  100241. /**
  100242. * Dispose all the elements created by the Helper.
  100243. */
  100244. dispose(): void;
  100245. }
  100246. }
  100247. declare module BABYLON {
  100248. /**
  100249. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  100250. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  100251. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  100252. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  100253. */
  100254. export class PhotoDome extends TransformNode {
  100255. private _useDirectMapping;
  100256. /**
  100257. * The texture being displayed on the sphere
  100258. */
  100259. protected _photoTexture: Texture;
  100260. /**
  100261. * Gets or sets the texture being displayed on the sphere
  100262. */
  100263. photoTexture: Texture;
  100264. /**
  100265. * Observable raised when an error occured while loading the 360 image
  100266. */
  100267. onLoadErrorObservable: Observable<string>;
  100268. /**
  100269. * The skybox material
  100270. */
  100271. protected _material: BackgroundMaterial;
  100272. /**
  100273. * The surface used for the skybox
  100274. */
  100275. protected _mesh: Mesh;
  100276. /**
  100277. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  100278. * Also see the options.resolution property.
  100279. */
  100280. fovMultiplier: number;
  100281. /**
  100282. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  100283. * @param name Element's name, child elements will append suffixes for their own names.
  100284. * @param urlsOfPhoto defines the url of the photo to display
  100285. * @param options defines an object containing optional or exposed sub element properties
  100286. * @param onError defines a callback called when an error occured while loading the texture
  100287. */
  100288. constructor(name: string, urlOfPhoto: string, options: {
  100289. resolution?: number;
  100290. size?: number;
  100291. useDirectMapping?: boolean;
  100292. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  100293. /**
  100294. * Releases resources associated with this node.
  100295. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  100296. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  100297. */
  100298. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  100299. }
  100300. }
  100301. declare module BABYLON {
  100302. /**
  100303. * Class used to host texture specific utilities
  100304. */
  100305. export class TextureTools {
  100306. /**
  100307. * Uses the GPU to create a copy texture rescaled at a given size
  100308. * @param texture Texture to copy from
  100309. * @param width defines the desired width
  100310. * @param height defines the desired height
  100311. * @param useBilinearMode defines if bilinear mode has to be used
  100312. * @return the generated texture
  100313. */
  100314. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  100315. /**
  100316. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  100317. * @param scene defines the hosting scene
  100318. * @returns the environment BRDF texture
  100319. */
  100320. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  100321. private static _environmentBRDFBase64Texture;
  100322. }
  100323. }
  100324. declare module BABYLON {
  100325. /**
  100326. * @hidden
  100327. */
  100328. export interface IMaterialClearCoatDefines {
  100329. CLEARCOAT: boolean;
  100330. CLEARCOAT_DEFAULTIOR: boolean;
  100331. CLEARCOAT_TEXTURE: boolean;
  100332. CLEARCOAT_TEXTUREDIRECTUV: number;
  100333. CLEARCOAT_BUMP: boolean;
  100334. CLEARCOAT_BUMPDIRECTUV: number;
  100335. CLEARCOAT_TINT: boolean;
  100336. CLEARCOAT_TINT_TEXTURE: boolean;
  100337. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  100338. /** @hidden */
  100339. _areTexturesDirty: boolean;
  100340. }
  100341. /**
  100342. * Define the code related to the clear coat parameters of the pbr material.
  100343. */
  100344. export class PBRClearCoatConfiguration {
  100345. /**
  100346. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  100347. * The default fits with a polyurethane material.
  100348. */
  100349. private static readonly _DefaultIndiceOfRefraction;
  100350. private _isEnabled;
  100351. /**
  100352. * Defines if the clear coat is enabled in the material.
  100353. */
  100354. isEnabled: boolean;
  100355. /**
  100356. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  100357. */
  100358. intensity: number;
  100359. /**
  100360. * Defines the clear coat layer roughness.
  100361. */
  100362. roughness: number;
  100363. private _indiceOfRefraction;
  100364. /**
  100365. * Defines the indice of refraction of the clear coat.
  100366. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  100367. * The default fits with a polyurethane material.
  100368. * Changing the default value is more performance intensive.
  100369. */
  100370. indiceOfRefraction: number;
  100371. private _texture;
  100372. /**
  100373. * Stores the clear coat values in a texture.
  100374. */
  100375. texture: Nullable<BaseTexture>;
  100376. private _bumpTexture;
  100377. /**
  100378. * Define the clear coat specific bump texture.
  100379. */
  100380. bumpTexture: Nullable<BaseTexture>;
  100381. private _isTintEnabled;
  100382. /**
  100383. * Defines if the clear coat tint is enabled in the material.
  100384. */
  100385. isTintEnabled: boolean;
  100386. /**
  100387. * Defines if the clear coat tint is enabled in the material.
  100388. * This is only use if tint is enabled
  100389. */
  100390. tintColor: Color3;
  100391. /**
  100392. * Defines if the distance at which the tint color should be found in the
  100393. * clear coat media.
  100394. * This is only use if tint is enabled
  100395. */
  100396. tintColorAtDistance: number;
  100397. /**
  100398. * Defines the clear coat layer thickness.
  100399. * This is only use if tint is enabled
  100400. */
  100401. tintThickness: number;
  100402. private _tintTexture;
  100403. /**
  100404. * Stores the clear tint values in a texture.
  100405. * rgb is tint
  100406. * a is a thickness factor
  100407. */
  100408. tintTexture: Nullable<BaseTexture>;
  100409. /** @hidden */
  100410. private _internalMarkAllSubMeshesAsTexturesDirty;
  100411. /** @hidden */
  100412. _markAllSubMeshesAsTexturesDirty(): void;
  100413. /**
  100414. * Instantiate a new istance of clear coat configuration.
  100415. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  100416. */
  100417. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  100418. /**
  100419. * Specifies that the submesh is ready to be used.
  100420. * @param defines the list of "defines" to update.
  100421. * @param scene defines the scene the material belongs to.
  100422. * @param engine defines the engine the material belongs to.
  100423. * @param disableBumpMap defines wether the material disables bump or not.
  100424. * @returns - boolean indicating that the submesh is ready or not.
  100425. */
  100426. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  100427. /**
  100428. * Checks to see if a texture is used in the material.
  100429. * @param defines the list of "defines" to update.
  100430. * @param scene defines the scene to the material belongs to.
  100431. */
  100432. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  100433. /**
  100434. * Binds the material data.
  100435. * @param uniformBuffer defines the Uniform buffer to fill in.
  100436. * @param scene defines the scene the material belongs to.
  100437. * @param engine defines the engine the material belongs to.
  100438. * @param disableBumpMap defines wether the material disables bump or not.
  100439. * @param isFrozen defines wether the material is frozen or not.
  100440. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  100441. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  100442. */
  100443. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  100444. /**
  100445. * Checks to see if a texture is used in the material.
  100446. * @param texture - Base texture to use.
  100447. * @returns - Boolean specifying if a texture is used in the material.
  100448. */
  100449. hasTexture(texture: BaseTexture): boolean;
  100450. /**
  100451. * Returns an array of the actively used textures.
  100452. * @param activeTextures Array of BaseTextures
  100453. */
  100454. getActiveTextures(activeTextures: BaseTexture[]): void;
  100455. /**
  100456. * Returns the animatable textures.
  100457. * @param animatables Array of animatable textures.
  100458. */
  100459. getAnimatables(animatables: IAnimatable[]): void;
  100460. /**
  100461. * Disposes the resources of the material.
  100462. * @param forceDisposeTextures - Forces the disposal of all textures.
  100463. */
  100464. dispose(forceDisposeTextures?: boolean): void;
  100465. /**
  100466. * Get the current class name of the texture useful for serialization or dynamic coding.
  100467. * @returns "PBRClearCoatConfiguration"
  100468. */
  100469. getClassName(): string;
  100470. /**
  100471. * Add fallbacks to the effect fallbacks list.
  100472. * @param defines defines the Base texture to use.
  100473. * @param fallbacks defines the current fallback list.
  100474. * @param currentRank defines the current fallback rank.
  100475. * @returns the new fallback rank.
  100476. */
  100477. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  100478. /**
  100479. * Add the required uniforms to the current list.
  100480. * @param uniforms defines the current uniform list.
  100481. */
  100482. static AddUniforms(uniforms: string[]): void;
  100483. /**
  100484. * Add the required samplers to the current list.
  100485. * @param samplers defines the current sampler list.
  100486. */
  100487. static AddSamplers(samplers: string[]): void;
  100488. /**
  100489. * Add the required uniforms to the current buffer.
  100490. * @param uniformBuffer defines the current uniform buffer.
  100491. */
  100492. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  100493. /**
  100494. * Makes a duplicate of the current configuration into another one.
  100495. * @param clearCoatConfiguration define the config where to copy the info
  100496. */
  100497. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  100498. /**
  100499. * Serializes this clear coat configuration.
  100500. * @returns - An object with the serialized config.
  100501. */
  100502. serialize(): any;
  100503. /**
  100504. * Parses a Clear Coat Configuration from a serialized object.
  100505. * @param source - Serialized object.
  100506. */
  100507. parse(source: any): void;
  100508. }
  100509. }
  100510. declare module BABYLON {
  100511. /**
  100512. * @hidden
  100513. */
  100514. export interface IMaterialAnisotropicDefines {
  100515. ANISOTROPIC: boolean;
  100516. ANISOTROPIC_TEXTURE: boolean;
  100517. ANISOTROPIC_TEXTUREDIRECTUV: number;
  100518. MAINUV1: boolean;
  100519. _areTexturesDirty: boolean;
  100520. _needUVs: boolean;
  100521. }
  100522. /**
  100523. * Define the code related to the anisotropic parameters of the pbr material.
  100524. */
  100525. export class PBRAnisotropicConfiguration {
  100526. private _isEnabled;
  100527. /**
  100528. * Defines if the anisotropy is enabled in the material.
  100529. */
  100530. isEnabled: boolean;
  100531. /**
  100532. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  100533. */
  100534. intensity: number;
  100535. /**
  100536. * Defines if the effect is along the tangents, bitangents or in between.
  100537. * By default, the effect is "strectching" the highlights along the tangents.
  100538. */
  100539. direction: Vector2;
  100540. private _texture;
  100541. /**
  100542. * Stores the anisotropy values in a texture.
  100543. * rg is direction (like normal from -1 to 1)
  100544. * b is a intensity
  100545. */
  100546. texture: Nullable<BaseTexture>;
  100547. /** @hidden */
  100548. private _internalMarkAllSubMeshesAsTexturesDirty;
  100549. /** @hidden */
  100550. _markAllSubMeshesAsTexturesDirty(): void;
  100551. /**
  100552. * Instantiate a new istance of anisotropy configuration.
  100553. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  100554. */
  100555. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  100556. /**
  100557. * Specifies that the submesh is ready to be used.
  100558. * @param defines the list of "defines" to update.
  100559. * @param scene defines the scene the material belongs to.
  100560. * @returns - boolean indicating that the submesh is ready or not.
  100561. */
  100562. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  100563. /**
  100564. * Checks to see if a texture is used in the material.
  100565. * @param defines the list of "defines" to update.
  100566. * @param mesh the mesh we are preparing the defines for.
  100567. * @param scene defines the scene the material belongs to.
  100568. */
  100569. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  100570. /**
  100571. * Binds the material data.
  100572. * @param uniformBuffer defines the Uniform buffer to fill in.
  100573. * @param scene defines the scene the material belongs to.
  100574. * @param isFrozen defines wether the material is frozen or not.
  100575. */
  100576. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  100577. /**
  100578. * Checks to see if a texture is used in the material.
  100579. * @param texture - Base texture to use.
  100580. * @returns - Boolean specifying if a texture is used in the material.
  100581. */
  100582. hasTexture(texture: BaseTexture): boolean;
  100583. /**
  100584. * Returns an array of the actively used textures.
  100585. * @param activeTextures Array of BaseTextures
  100586. */
  100587. getActiveTextures(activeTextures: BaseTexture[]): void;
  100588. /**
  100589. * Returns the animatable textures.
  100590. * @param animatables Array of animatable textures.
  100591. */
  100592. getAnimatables(animatables: IAnimatable[]): void;
  100593. /**
  100594. * Disposes the resources of the material.
  100595. * @param forceDisposeTextures - Forces the disposal of all textures.
  100596. */
  100597. dispose(forceDisposeTextures?: boolean): void;
  100598. /**
  100599. * Get the current class name of the texture useful for serialization or dynamic coding.
  100600. * @returns "PBRAnisotropicConfiguration"
  100601. */
  100602. getClassName(): string;
  100603. /**
  100604. * Add fallbacks to the effect fallbacks list.
  100605. * @param defines defines the Base texture to use.
  100606. * @param fallbacks defines the current fallback list.
  100607. * @param currentRank defines the current fallback rank.
  100608. * @returns the new fallback rank.
  100609. */
  100610. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  100611. /**
  100612. * Add the required uniforms to the current list.
  100613. * @param uniforms defines the current uniform list.
  100614. */
  100615. static AddUniforms(uniforms: string[]): void;
  100616. /**
  100617. * Add the required uniforms to the current buffer.
  100618. * @param uniformBuffer defines the current uniform buffer.
  100619. */
  100620. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  100621. /**
  100622. * Add the required samplers to the current list.
  100623. * @param samplers defines the current sampler list.
  100624. */
  100625. static AddSamplers(samplers: string[]): void;
  100626. /**
  100627. * Makes a duplicate of the current configuration into another one.
  100628. * @param anisotropicConfiguration define the config where to copy the info
  100629. */
  100630. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  100631. /**
  100632. * Serializes this anisotropy configuration.
  100633. * @returns - An object with the serialized config.
  100634. */
  100635. serialize(): any;
  100636. /**
  100637. * Parses a anisotropy Configuration from a serialized object.
  100638. * @param source - Serialized object.
  100639. */
  100640. parse(source: any): void;
  100641. }
  100642. }
  100643. declare module BABYLON {
  100644. /**
  100645. * @hidden
  100646. */
  100647. export interface IMaterialBRDFDefines {
  100648. BRDF_V_HEIGHT_CORRELATED: boolean;
  100649. MS_BRDF_ENERGY_CONSERVATION: boolean;
  100650. /** @hidden */
  100651. _areMiscDirty: boolean;
  100652. }
  100653. /**
  100654. * Define the code related to the BRDF parameters of the pbr material.
  100655. */
  100656. export class PBRBRDFConfiguration {
  100657. private _useEnergyConservation;
  100658. /**
  100659. * Defines if the material uses energy conservation.
  100660. */
  100661. useEnergyConservation: boolean;
  100662. private _useSmithVisibilityHeightCorrelated;
  100663. /**
  100664. * LEGACY Mode set to false
  100665. * Defines if the material uses height smith correlated visibility term.
  100666. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  100667. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  100668. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  100669. * Not relying on height correlated will also disable energy conservation.
  100670. */
  100671. useSmithVisibilityHeightCorrelated: boolean;
  100672. /** @hidden */
  100673. private _internalMarkAllSubMeshesAsMiscDirty;
  100674. /** @hidden */
  100675. _markAllSubMeshesAsMiscDirty(): void;
  100676. /**
  100677. * Instantiate a new istance of clear coat configuration.
  100678. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  100679. */
  100680. constructor(markAllSubMeshesAsMiscDirty: () => void);
  100681. /**
  100682. * Checks to see if a texture is used in the material.
  100683. * @param defines the list of "defines" to update.
  100684. */
  100685. prepareDefines(defines: IMaterialBRDFDefines): void;
  100686. /**
  100687. * Get the current class name of the texture useful for serialization or dynamic coding.
  100688. * @returns "PBRClearCoatConfiguration"
  100689. */
  100690. getClassName(): string;
  100691. /**
  100692. * Makes a duplicate of the current configuration into another one.
  100693. * @param brdfConfiguration define the config where to copy the info
  100694. */
  100695. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  100696. /**
  100697. * Serializes this BRDF configuration.
  100698. * @returns - An object with the serialized config.
  100699. */
  100700. serialize(): any;
  100701. /**
  100702. * Parses a BRDF Configuration from a serialized object.
  100703. * @param source - Serialized object.
  100704. */
  100705. parse(source: any): void;
  100706. }
  100707. }
  100708. declare module BABYLON {
  100709. /**
  100710. * @hidden
  100711. */
  100712. export interface IMaterialSheenDefines {
  100713. SHEEN: boolean;
  100714. SHEEN_TEXTURE: boolean;
  100715. SHEEN_TEXTUREDIRECTUV: number;
  100716. SHEEN_LINKWITHALBEDO: boolean;
  100717. /** @hidden */
  100718. _areTexturesDirty: boolean;
  100719. }
  100720. /**
  100721. * Define the code related to the Sheen parameters of the pbr material.
  100722. */
  100723. export class PBRSheenConfiguration {
  100724. private _isEnabled;
  100725. /**
  100726. * Defines if the material uses sheen.
  100727. */
  100728. isEnabled: boolean;
  100729. private _linkSheenWithAlbedo;
  100730. /**
  100731. * Defines if the sheen is linked to the sheen color.
  100732. */
  100733. linkSheenWithAlbedo: boolean;
  100734. /**
  100735. * Defines the sheen intensity.
  100736. */
  100737. intensity: number;
  100738. /**
  100739. * Defines the sheen color.
  100740. */
  100741. color: Color3;
  100742. private _texture;
  100743. /**
  100744. * Stores the sheen tint values in a texture.
  100745. * rgb is tint
  100746. * a is a intensity
  100747. */
  100748. texture: Nullable<BaseTexture>;
  100749. /** @hidden */
  100750. private _internalMarkAllSubMeshesAsTexturesDirty;
  100751. /** @hidden */
  100752. _markAllSubMeshesAsTexturesDirty(): void;
  100753. /**
  100754. * Instantiate a new istance of clear coat configuration.
  100755. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  100756. */
  100757. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  100758. /**
  100759. * Specifies that the submesh is ready to be used.
  100760. * @param defines the list of "defines" to update.
  100761. * @param scene defines the scene the material belongs to.
  100762. * @returns - boolean indicating that the submesh is ready or not.
  100763. */
  100764. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  100765. /**
  100766. * Checks to see if a texture is used in the material.
  100767. * @param defines the list of "defines" to update.
  100768. * @param scene defines the scene the material belongs to.
  100769. */
  100770. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  100771. /**
  100772. * Binds the material data.
  100773. * @param uniformBuffer defines the Uniform buffer to fill in.
  100774. * @param scene defines the scene the material belongs to.
  100775. * @param isFrozen defines wether the material is frozen or not.
  100776. */
  100777. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  100778. /**
  100779. * Checks to see if a texture is used in the material.
  100780. * @param texture - Base texture to use.
  100781. * @returns - Boolean specifying if a texture is used in the material.
  100782. */
  100783. hasTexture(texture: BaseTexture): boolean;
  100784. /**
  100785. * Returns an array of the actively used textures.
  100786. * @param activeTextures Array of BaseTextures
  100787. */
  100788. getActiveTextures(activeTextures: BaseTexture[]): void;
  100789. /**
  100790. * Returns the animatable textures.
  100791. * @param animatables Array of animatable textures.
  100792. */
  100793. getAnimatables(animatables: IAnimatable[]): void;
  100794. /**
  100795. * Disposes the resources of the material.
  100796. * @param forceDisposeTextures - Forces the disposal of all textures.
  100797. */
  100798. dispose(forceDisposeTextures?: boolean): void;
  100799. /**
  100800. * Get the current class name of the texture useful for serialization or dynamic coding.
  100801. * @returns "PBRSheenConfiguration"
  100802. */
  100803. getClassName(): string;
  100804. /**
  100805. * Add fallbacks to the effect fallbacks list.
  100806. * @param defines defines the Base texture to use.
  100807. * @param fallbacks defines the current fallback list.
  100808. * @param currentRank defines the current fallback rank.
  100809. * @returns the new fallback rank.
  100810. */
  100811. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  100812. /**
  100813. * Add the required uniforms to the current list.
  100814. * @param uniforms defines the current uniform list.
  100815. */
  100816. static AddUniforms(uniforms: string[]): void;
  100817. /**
  100818. * Add the required uniforms to the current buffer.
  100819. * @param uniformBuffer defines the current uniform buffer.
  100820. */
  100821. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  100822. /**
  100823. * Add the required samplers to the current list.
  100824. * @param samplers defines the current sampler list.
  100825. */
  100826. static AddSamplers(samplers: string[]): void;
  100827. /**
  100828. * Makes a duplicate of the current configuration into another one.
  100829. * @param sheenConfiguration define the config where to copy the info
  100830. */
  100831. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  100832. /**
  100833. * Serializes this BRDF configuration.
  100834. * @returns - An object with the serialized config.
  100835. */
  100836. serialize(): any;
  100837. /**
  100838. * Parses a Sheen Configuration from a serialized object.
  100839. * @param source - Serialized object.
  100840. */
  100841. parse(source: any): void;
  100842. }
  100843. }
  100844. declare module BABYLON {
  100845. /** @hidden */
  100846. export var pbrFragmentDeclaration: {
  100847. name: string;
  100848. shader: string;
  100849. };
  100850. }
  100851. declare module BABYLON {
  100852. /** @hidden */
  100853. export var pbrUboDeclaration: {
  100854. name: string;
  100855. shader: string;
  100856. };
  100857. }
  100858. declare module BABYLON {
  100859. /** @hidden */
  100860. export var pbrFunctions: {
  100861. name: string;
  100862. shader: string;
  100863. };
  100864. }
  100865. declare module BABYLON {
  100866. /** @hidden */
  100867. export var harmonicsFunctions: {
  100868. name: string;
  100869. shader: string;
  100870. };
  100871. }
  100872. declare module BABYLON {
  100873. /** @hidden */
  100874. export var pbrPreLightingFunctions: {
  100875. name: string;
  100876. shader: string;
  100877. };
  100878. }
  100879. declare module BABYLON {
  100880. /** @hidden */
  100881. export var pbrFalloffLightingFunctions: {
  100882. name: string;
  100883. shader: string;
  100884. };
  100885. }
  100886. declare module BABYLON {
  100887. /** @hidden */
  100888. export var pbrLightingFunctions: {
  100889. name: string;
  100890. shader: string;
  100891. };
  100892. }
  100893. declare module BABYLON {
  100894. /** @hidden */
  100895. export var pbrDebug: {
  100896. name: string;
  100897. shader: string;
  100898. };
  100899. }
  100900. declare module BABYLON {
  100901. /** @hidden */
  100902. export var pbrPixelShader: {
  100903. name: string;
  100904. shader: string;
  100905. };
  100906. }
  100907. declare module BABYLON {
  100908. /** @hidden */
  100909. export var pbrVertexDeclaration: {
  100910. name: string;
  100911. shader: string;
  100912. };
  100913. }
  100914. declare module BABYLON {
  100915. /** @hidden */
  100916. export var pbrVertexShader: {
  100917. name: string;
  100918. shader: string;
  100919. };
  100920. }
  100921. declare module BABYLON {
  100922. /**
  100923. * The Physically based material base class of BJS.
  100924. *
  100925. * This offers the main features of a standard PBR material.
  100926. * For more information, please refer to the documentation :
  100927. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  100928. */
  100929. export abstract class PBRBaseMaterial extends PushMaterial {
  100930. /**
  100931. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  100932. */
  100933. static readonly PBRMATERIAL_OPAQUE: number;
  100934. /**
  100935. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  100936. */
  100937. static readonly PBRMATERIAL_ALPHATEST: number;
  100938. /**
  100939. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  100940. */
  100941. static readonly PBRMATERIAL_ALPHABLEND: number;
  100942. /**
  100943. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  100944. * They are also discarded below the alpha cutoff threshold to improve performances.
  100945. */
  100946. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  100947. /**
  100948. * Defines the default value of how much AO map is occluding the analytical lights
  100949. * (point spot...).
  100950. */
  100951. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  100952. /**
  100953. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  100954. */
  100955. static readonly LIGHTFALLOFF_PHYSICAL: number;
  100956. /**
  100957. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  100958. * to enhance interoperability with other engines.
  100959. */
  100960. static readonly LIGHTFALLOFF_GLTF: number;
  100961. /**
  100962. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  100963. * to enhance interoperability with other materials.
  100964. */
  100965. static readonly LIGHTFALLOFF_STANDARD: number;
  100966. /**
  100967. * Intensity of the direct lights e.g. the four lights available in your scene.
  100968. * This impacts both the direct diffuse and specular highlights.
  100969. */
  100970. protected _directIntensity: number;
  100971. /**
  100972. * Intensity of the emissive part of the material.
  100973. * This helps controlling the emissive effect without modifying the emissive color.
  100974. */
  100975. protected _emissiveIntensity: number;
  100976. /**
  100977. * Intensity of the environment e.g. how much the environment will light the object
  100978. * either through harmonics for rough material or through the refelction for shiny ones.
  100979. */
  100980. protected _environmentIntensity: number;
  100981. /**
  100982. * This is a special control allowing the reduction of the specular highlights coming from the
  100983. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  100984. */
  100985. protected _specularIntensity: number;
  100986. /**
  100987. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  100988. */
  100989. private _lightingInfos;
  100990. /**
  100991. * Debug Control allowing disabling the bump map on this material.
  100992. */
  100993. protected _disableBumpMap: boolean;
  100994. /**
  100995. * AKA Diffuse Texture in standard nomenclature.
  100996. */
  100997. protected _albedoTexture: BaseTexture;
  100998. /**
  100999. * AKA Occlusion Texture in other nomenclature.
  101000. */
  101001. protected _ambientTexture: BaseTexture;
  101002. /**
  101003. * AKA Occlusion Texture Intensity in other nomenclature.
  101004. */
  101005. protected _ambientTextureStrength: number;
  101006. /**
  101007. * Defines how much the AO map is occluding the analytical lights (point spot...).
  101008. * 1 means it completely occludes it
  101009. * 0 mean it has no impact
  101010. */
  101011. protected _ambientTextureImpactOnAnalyticalLights: number;
  101012. /**
  101013. * Stores the alpha values in a texture.
  101014. */
  101015. protected _opacityTexture: BaseTexture;
  101016. /**
  101017. * Stores the reflection values in a texture.
  101018. */
  101019. protected _reflectionTexture: BaseTexture;
  101020. /**
  101021. * Stores the refraction values in a texture.
  101022. */
  101023. protected _refractionTexture: BaseTexture;
  101024. /**
  101025. * Stores the emissive values in a texture.
  101026. */
  101027. protected _emissiveTexture: BaseTexture;
  101028. /**
  101029. * AKA Specular texture in other nomenclature.
  101030. */
  101031. protected _reflectivityTexture: BaseTexture;
  101032. /**
  101033. * Used to switch from specular/glossiness to metallic/roughness workflow.
  101034. */
  101035. protected _metallicTexture: BaseTexture;
  101036. /**
  101037. * Specifies the metallic scalar of the metallic/roughness workflow.
  101038. * Can also be used to scale the metalness values of the metallic texture.
  101039. */
  101040. protected _metallic: Nullable<number>;
  101041. /**
  101042. * Specifies the roughness scalar of the metallic/roughness workflow.
  101043. * Can also be used to scale the roughness values of the metallic texture.
  101044. */
  101045. protected _roughness: Nullable<number>;
  101046. /**
  101047. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  101048. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  101049. */
  101050. protected _microSurfaceTexture: BaseTexture;
  101051. /**
  101052. * Stores surface normal data used to displace a mesh in a texture.
  101053. */
  101054. protected _bumpTexture: BaseTexture;
  101055. /**
  101056. * Stores the pre-calculated light information of a mesh in a texture.
  101057. */
  101058. protected _lightmapTexture: BaseTexture;
  101059. /**
  101060. * The color of a material in ambient lighting.
  101061. */
  101062. protected _ambientColor: Color3;
  101063. /**
  101064. * AKA Diffuse Color in other nomenclature.
  101065. */
  101066. protected _albedoColor: Color3;
  101067. /**
  101068. * AKA Specular Color in other nomenclature.
  101069. */
  101070. protected _reflectivityColor: Color3;
  101071. /**
  101072. * The color applied when light is reflected from a material.
  101073. */
  101074. protected _reflectionColor: Color3;
  101075. /**
  101076. * The color applied when light is emitted from a material.
  101077. */
  101078. protected _emissiveColor: Color3;
  101079. /**
  101080. * AKA Glossiness in other nomenclature.
  101081. */
  101082. protected _microSurface: number;
  101083. /**
  101084. * source material index of refraction (IOR)' / 'destination material IOR.
  101085. */
  101086. protected _indexOfRefraction: number;
  101087. /**
  101088. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  101089. */
  101090. protected _invertRefractionY: boolean;
  101091. /**
  101092. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  101093. * Materials half opaque for instance using refraction could benefit from this control.
  101094. */
  101095. protected _linkRefractionWithTransparency: boolean;
  101096. /**
  101097. * Specifies that the material will use the light map as a show map.
  101098. */
  101099. protected _useLightmapAsShadowmap: boolean;
  101100. /**
  101101. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  101102. * makes the reflect vector face the model (under horizon).
  101103. */
  101104. protected _useHorizonOcclusion: boolean;
  101105. /**
  101106. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  101107. * too much the area relying on ambient texture to define their ambient occlusion.
  101108. */
  101109. protected _useRadianceOcclusion: boolean;
  101110. /**
  101111. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  101112. */
  101113. protected _useAlphaFromAlbedoTexture: boolean;
  101114. /**
  101115. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  101116. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  101117. */
  101118. protected _useSpecularOverAlpha: boolean;
  101119. /**
  101120. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  101121. */
  101122. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  101123. /**
  101124. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  101125. */
  101126. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  101127. /**
  101128. * Specifies if the metallic texture contains the roughness information in its green channel.
  101129. */
  101130. protected _useRoughnessFromMetallicTextureGreen: boolean;
  101131. /**
  101132. * Specifies if the metallic texture contains the metallness information in its blue channel.
  101133. */
  101134. protected _useMetallnessFromMetallicTextureBlue: boolean;
  101135. /**
  101136. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  101137. */
  101138. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  101139. /**
  101140. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  101141. */
  101142. protected _useAmbientInGrayScale: boolean;
  101143. /**
  101144. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  101145. * The material will try to infer what glossiness each pixel should be.
  101146. */
  101147. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  101148. /**
  101149. * Defines the falloff type used in this material.
  101150. * It by default is Physical.
  101151. */
  101152. protected _lightFalloff: number;
  101153. /**
  101154. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  101155. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  101156. */
  101157. protected _useRadianceOverAlpha: boolean;
  101158. /**
  101159. * Allows using an object space normal map (instead of tangent space).
  101160. */
  101161. protected _useObjectSpaceNormalMap: boolean;
  101162. /**
  101163. * Allows using the bump map in parallax mode.
  101164. */
  101165. protected _useParallax: boolean;
  101166. /**
  101167. * Allows using the bump map in parallax occlusion mode.
  101168. */
  101169. protected _useParallaxOcclusion: boolean;
  101170. /**
  101171. * Controls the scale bias of the parallax mode.
  101172. */
  101173. protected _parallaxScaleBias: number;
  101174. /**
  101175. * If sets to true, disables all the lights affecting the material.
  101176. */
  101177. protected _disableLighting: boolean;
  101178. /**
  101179. * Number of Simultaneous lights allowed on the material.
  101180. */
  101181. protected _maxSimultaneousLights: number;
  101182. /**
  101183. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  101184. */
  101185. protected _invertNormalMapX: boolean;
  101186. /**
  101187. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  101188. */
  101189. protected _invertNormalMapY: boolean;
  101190. /**
  101191. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  101192. */
  101193. protected _twoSidedLighting: boolean;
  101194. /**
  101195. * Defines the alpha limits in alpha test mode.
  101196. */
  101197. protected _alphaCutOff: number;
  101198. /**
  101199. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  101200. */
  101201. protected _forceAlphaTest: boolean;
  101202. /**
  101203. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  101204. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  101205. */
  101206. protected _useAlphaFresnel: boolean;
  101207. /**
  101208. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  101209. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  101210. */
  101211. protected _useLinearAlphaFresnel: boolean;
  101212. /**
  101213. * The transparency mode of the material.
  101214. */
  101215. protected _transparencyMode: Nullable<number>;
  101216. /**
  101217. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  101218. * from cos thetav and roughness:
  101219. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  101220. */
  101221. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  101222. /**
  101223. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  101224. */
  101225. protected _forceIrradianceInFragment: boolean;
  101226. /**
  101227. * Force normal to face away from face.
  101228. */
  101229. protected _forceNormalForward: boolean;
  101230. /**
  101231. * Enables specular anti aliasing in the PBR shader.
  101232. * It will both interacts on the Geometry for analytical and IBL lighting.
  101233. * It also prefilter the roughness map based on the bump values.
  101234. */
  101235. protected _enableSpecularAntiAliasing: boolean;
  101236. /**
  101237. * Default configuration related to image processing available in the PBR Material.
  101238. */
  101239. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  101240. /**
  101241. * Keep track of the image processing observer to allow dispose and replace.
  101242. */
  101243. private _imageProcessingObserver;
  101244. /**
  101245. * Attaches a new image processing configuration to the PBR Material.
  101246. * @param configuration
  101247. */
  101248. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  101249. /**
  101250. * Stores the available render targets.
  101251. */
  101252. private _renderTargets;
  101253. /**
  101254. * Sets the global ambient color for the material used in lighting calculations.
  101255. */
  101256. private _globalAmbientColor;
  101257. /**
  101258. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  101259. */
  101260. private _useLogarithmicDepth;
  101261. /**
  101262. * If set to true, no lighting calculations will be applied.
  101263. */
  101264. private _unlit;
  101265. private _debugMode;
  101266. /**
  101267. * @hidden
  101268. * This is reserved for the inspector.
  101269. * Defines the material debug mode.
  101270. * It helps seeing only some components of the material while troubleshooting.
  101271. */
  101272. debugMode: number;
  101273. /**
  101274. * @hidden
  101275. * This is reserved for the inspector.
  101276. * Specify from where on screen the debug mode should start.
  101277. * The value goes from -1 (full screen) to 1 (not visible)
  101278. * It helps with side by side comparison against the final render
  101279. * This defaults to -1
  101280. */
  101281. private debugLimit;
  101282. /**
  101283. * @hidden
  101284. * This is reserved for the inspector.
  101285. * As the default viewing range might not be enough (if the ambient is really small for instance)
  101286. * You can use the factor to better multiply the final value.
  101287. */
  101288. private debugFactor;
  101289. /**
  101290. * Defines the clear coat layer parameters for the material.
  101291. */
  101292. readonly clearCoat: PBRClearCoatConfiguration;
  101293. /**
  101294. * Defines the anisotropic parameters for the material.
  101295. */
  101296. readonly anisotropy: PBRAnisotropicConfiguration;
  101297. /**
  101298. * Defines the BRDF parameters for the material.
  101299. */
  101300. readonly brdf: PBRBRDFConfiguration;
  101301. /**
  101302. * Defines the Sheen parameters for the material.
  101303. */
  101304. readonly sheen: PBRSheenConfiguration;
  101305. /**
  101306. * Instantiates a new PBRMaterial instance.
  101307. *
  101308. * @param name The material name
  101309. * @param scene The scene the material will be use in.
  101310. */
  101311. constructor(name: string, scene: Scene);
  101312. /**
  101313. * Gets a boolean indicating that current material needs to register RTT
  101314. */
  101315. readonly hasRenderTargetTextures: boolean;
  101316. /**
  101317. * Gets the name of the material class.
  101318. */
  101319. getClassName(): string;
  101320. /**
  101321. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  101322. */
  101323. /**
  101324. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  101325. */
  101326. useLogarithmicDepth: boolean;
  101327. /**
  101328. * Gets the current transparency mode.
  101329. */
  101330. /**
  101331. * Sets the transparency mode of the material.
  101332. *
  101333. * | Value | Type | Description |
  101334. * | ----- | ----------------------------------- | ----------- |
  101335. * | 0 | OPAQUE | |
  101336. * | 1 | ALPHATEST | |
  101337. * | 2 | ALPHABLEND | |
  101338. * | 3 | ALPHATESTANDBLEND | |
  101339. *
  101340. */
  101341. transparencyMode: Nullable<number>;
  101342. /**
  101343. * Returns true if alpha blending should be disabled.
  101344. */
  101345. private readonly _disableAlphaBlending;
  101346. /**
  101347. * Specifies whether or not this material should be rendered in alpha blend mode.
  101348. */
  101349. needAlphaBlending(): boolean;
  101350. /**
  101351. * Specifies if the mesh will require alpha blending.
  101352. * @param mesh - BJS mesh.
  101353. */
  101354. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  101355. /**
  101356. * Specifies whether or not this material should be rendered in alpha test mode.
  101357. */
  101358. needAlphaTesting(): boolean;
  101359. /**
  101360. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  101361. */
  101362. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  101363. /**
  101364. * Gets the texture used for the alpha test.
  101365. */
  101366. getAlphaTestTexture(): BaseTexture;
  101367. /**
  101368. * Specifies that the submesh is ready to be used.
  101369. * @param mesh - BJS mesh.
  101370. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  101371. * @param useInstances - Specifies that instances should be used.
  101372. * @returns - boolean indicating that the submesh is ready or not.
  101373. */
  101374. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  101375. /**
  101376. * Specifies if the material uses metallic roughness workflow.
  101377. * @returns boolean specifiying if the material uses metallic roughness workflow.
  101378. */
  101379. isMetallicWorkflow(): boolean;
  101380. private _prepareEffect;
  101381. private _prepareDefines;
  101382. /**
  101383. * Force shader compilation
  101384. */
  101385. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  101386. clipPlane: boolean;
  101387. }>): void;
  101388. /**
  101389. * Initializes the uniform buffer layout for the shader.
  101390. */
  101391. buildUniformLayout(): void;
  101392. /**
  101393. * Unbinds the textures.
  101394. */
  101395. unbind(): void;
  101396. /**
  101397. * Binds the submesh data.
  101398. * @param world - The world matrix.
  101399. * @param mesh - The BJS mesh.
  101400. * @param subMesh - A submesh of the BJS mesh.
  101401. */
  101402. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  101403. /**
  101404. * Returns the animatable textures.
  101405. * @returns - Array of animatable textures.
  101406. */
  101407. getAnimatables(): IAnimatable[];
  101408. /**
  101409. * Returns the texture used for reflections.
  101410. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  101411. */
  101412. private _getReflectionTexture;
  101413. /**
  101414. * Returns the texture used for refraction or null if none is used.
  101415. * @returns - Refection texture if present. If no refraction texture and refraction
  101416. * is linked with transparency, returns environment texture. Otherwise, returns null.
  101417. */
  101418. private _getRefractionTexture;
  101419. /**
  101420. * Returns an array of the actively used textures.
  101421. * @returns - Array of BaseTextures
  101422. */
  101423. getActiveTextures(): BaseTexture[];
  101424. /**
  101425. * Checks to see if a texture is used in the material.
  101426. * @param texture - Base texture to use.
  101427. * @returns - Boolean specifying if a texture is used in the material.
  101428. */
  101429. hasTexture(texture: BaseTexture): boolean;
  101430. /**
  101431. * Disposes the resources of the material.
  101432. * @param forceDisposeEffect - Forces the disposal of effects.
  101433. * @param forceDisposeTextures - Forces the disposal of all textures.
  101434. */
  101435. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  101436. }
  101437. }
  101438. declare module BABYLON {
  101439. /**
  101440. * The Physically based material of BJS.
  101441. *
  101442. * This offers the main features of a standard PBR material.
  101443. * For more information, please refer to the documentation :
  101444. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  101445. */
  101446. export class PBRMaterial extends PBRBaseMaterial {
  101447. /**
  101448. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  101449. */
  101450. static readonly PBRMATERIAL_OPAQUE: number;
  101451. /**
  101452. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  101453. */
  101454. static readonly PBRMATERIAL_ALPHATEST: number;
  101455. /**
  101456. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  101457. */
  101458. static readonly PBRMATERIAL_ALPHABLEND: number;
  101459. /**
  101460. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  101461. * They are also discarded below the alpha cutoff threshold to improve performances.
  101462. */
  101463. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  101464. /**
  101465. * Defines the default value of how much AO map is occluding the analytical lights
  101466. * (point spot...).
  101467. */
  101468. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  101469. /**
  101470. * Intensity of the direct lights e.g. the four lights available in your scene.
  101471. * This impacts both the direct diffuse and specular highlights.
  101472. */
  101473. directIntensity: number;
  101474. /**
  101475. * Intensity of the emissive part of the material.
  101476. * This helps controlling the emissive effect without modifying the emissive color.
  101477. */
  101478. emissiveIntensity: number;
  101479. /**
  101480. * Intensity of the environment e.g. how much the environment will light the object
  101481. * either through harmonics for rough material or through the refelction for shiny ones.
  101482. */
  101483. environmentIntensity: number;
  101484. /**
  101485. * This is a special control allowing the reduction of the specular highlights coming from the
  101486. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  101487. */
  101488. specularIntensity: number;
  101489. /**
  101490. * Debug Control allowing disabling the bump map on this material.
  101491. */
  101492. disableBumpMap: boolean;
  101493. /**
  101494. * AKA Diffuse Texture in standard nomenclature.
  101495. */
  101496. albedoTexture: BaseTexture;
  101497. /**
  101498. * AKA Occlusion Texture in other nomenclature.
  101499. */
  101500. ambientTexture: BaseTexture;
  101501. /**
  101502. * AKA Occlusion Texture Intensity in other nomenclature.
  101503. */
  101504. ambientTextureStrength: number;
  101505. /**
  101506. * Defines how much the AO map is occluding the analytical lights (point spot...).
  101507. * 1 means it completely occludes it
  101508. * 0 mean it has no impact
  101509. */
  101510. ambientTextureImpactOnAnalyticalLights: number;
  101511. /**
  101512. * Stores the alpha values in a texture.
  101513. */
  101514. opacityTexture: BaseTexture;
  101515. /**
  101516. * Stores the reflection values in a texture.
  101517. */
  101518. reflectionTexture: Nullable<BaseTexture>;
  101519. /**
  101520. * Stores the emissive values in a texture.
  101521. */
  101522. emissiveTexture: BaseTexture;
  101523. /**
  101524. * AKA Specular texture in other nomenclature.
  101525. */
  101526. reflectivityTexture: BaseTexture;
  101527. /**
  101528. * Used to switch from specular/glossiness to metallic/roughness workflow.
  101529. */
  101530. metallicTexture: BaseTexture;
  101531. /**
  101532. * Specifies the metallic scalar of the metallic/roughness workflow.
  101533. * Can also be used to scale the metalness values of the metallic texture.
  101534. */
  101535. metallic: Nullable<number>;
  101536. /**
  101537. * Specifies the roughness scalar of the metallic/roughness workflow.
  101538. * Can also be used to scale the roughness values of the metallic texture.
  101539. */
  101540. roughness: Nullable<number>;
  101541. /**
  101542. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  101543. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  101544. */
  101545. microSurfaceTexture: BaseTexture;
  101546. /**
  101547. * Stores surface normal data used to displace a mesh in a texture.
  101548. */
  101549. bumpTexture: BaseTexture;
  101550. /**
  101551. * Stores the pre-calculated light information of a mesh in a texture.
  101552. */
  101553. lightmapTexture: BaseTexture;
  101554. /**
  101555. * Stores the refracted light information in a texture.
  101556. */
  101557. refractionTexture: BaseTexture;
  101558. /**
  101559. * The color of a material in ambient lighting.
  101560. */
  101561. ambientColor: Color3;
  101562. /**
  101563. * AKA Diffuse Color in other nomenclature.
  101564. */
  101565. albedoColor: Color3;
  101566. /**
  101567. * AKA Specular Color in other nomenclature.
  101568. */
  101569. reflectivityColor: Color3;
  101570. /**
  101571. * The color reflected from the material.
  101572. */
  101573. reflectionColor: Color3;
  101574. /**
  101575. * The color emitted from the material.
  101576. */
  101577. emissiveColor: Color3;
  101578. /**
  101579. * AKA Glossiness in other nomenclature.
  101580. */
  101581. microSurface: number;
  101582. /**
  101583. * source material index of refraction (IOR)' / 'destination material IOR.
  101584. */
  101585. indexOfRefraction: number;
  101586. /**
  101587. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  101588. */
  101589. invertRefractionY: boolean;
  101590. /**
  101591. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  101592. * Materials half opaque for instance using refraction could benefit from this control.
  101593. */
  101594. linkRefractionWithTransparency: boolean;
  101595. /**
  101596. * If true, the light map contains occlusion information instead of lighting info.
  101597. */
  101598. useLightmapAsShadowmap: boolean;
  101599. /**
  101600. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  101601. */
  101602. useAlphaFromAlbedoTexture: boolean;
  101603. /**
  101604. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  101605. */
  101606. forceAlphaTest: boolean;
  101607. /**
  101608. * Defines the alpha limits in alpha test mode.
  101609. */
  101610. alphaCutOff: number;
  101611. /**
  101612. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  101613. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  101614. */
  101615. useSpecularOverAlpha: boolean;
  101616. /**
  101617. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  101618. */
  101619. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  101620. /**
  101621. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  101622. */
  101623. useRoughnessFromMetallicTextureAlpha: boolean;
  101624. /**
  101625. * Specifies if the metallic texture contains the roughness information in its green channel.
  101626. */
  101627. useRoughnessFromMetallicTextureGreen: boolean;
  101628. /**
  101629. * Specifies if the metallic texture contains the metallness information in its blue channel.
  101630. */
  101631. useMetallnessFromMetallicTextureBlue: boolean;
  101632. /**
  101633. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  101634. */
  101635. useAmbientOcclusionFromMetallicTextureRed: boolean;
  101636. /**
  101637. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  101638. */
  101639. useAmbientInGrayScale: boolean;
  101640. /**
  101641. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  101642. * The material will try to infer what glossiness each pixel should be.
  101643. */
  101644. useAutoMicroSurfaceFromReflectivityMap: boolean;
  101645. /**
  101646. * BJS is using an harcoded light falloff based on a manually sets up range.
  101647. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  101648. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  101649. */
  101650. /**
  101651. * BJS is using an harcoded light falloff based on a manually sets up range.
  101652. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  101653. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  101654. */
  101655. usePhysicalLightFalloff: boolean;
  101656. /**
  101657. * In order to support the falloff compatibility with gltf, a special mode has been added
  101658. * to reproduce the gltf light falloff.
  101659. */
  101660. /**
  101661. * In order to support the falloff compatibility with gltf, a special mode has been added
  101662. * to reproduce the gltf light falloff.
  101663. */
  101664. useGLTFLightFalloff: boolean;
  101665. /**
  101666. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  101667. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  101668. */
  101669. useRadianceOverAlpha: boolean;
  101670. /**
  101671. * Allows using an object space normal map (instead of tangent space).
  101672. */
  101673. useObjectSpaceNormalMap: boolean;
  101674. /**
  101675. * Allows using the bump map in parallax mode.
  101676. */
  101677. useParallax: boolean;
  101678. /**
  101679. * Allows using the bump map in parallax occlusion mode.
  101680. */
  101681. useParallaxOcclusion: boolean;
  101682. /**
  101683. * Controls the scale bias of the parallax mode.
  101684. */
  101685. parallaxScaleBias: number;
  101686. /**
  101687. * If sets to true, disables all the lights affecting the material.
  101688. */
  101689. disableLighting: boolean;
  101690. /**
  101691. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  101692. */
  101693. forceIrradianceInFragment: boolean;
  101694. /**
  101695. * Number of Simultaneous lights allowed on the material.
  101696. */
  101697. maxSimultaneousLights: number;
  101698. /**
  101699. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  101700. */
  101701. invertNormalMapX: boolean;
  101702. /**
  101703. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  101704. */
  101705. invertNormalMapY: boolean;
  101706. /**
  101707. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  101708. */
  101709. twoSidedLighting: boolean;
  101710. /**
  101711. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  101712. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  101713. */
  101714. useAlphaFresnel: boolean;
  101715. /**
  101716. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  101717. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  101718. */
  101719. useLinearAlphaFresnel: boolean;
  101720. /**
  101721. * Let user defines the brdf lookup texture used for IBL.
  101722. * A default 8bit version is embedded but you could point at :
  101723. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.png
  101724. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  101725. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  101726. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  101727. */
  101728. environmentBRDFTexture: Nullable<BaseTexture>;
  101729. /**
  101730. * Force normal to face away from face.
  101731. */
  101732. forceNormalForward: boolean;
  101733. /**
  101734. * Enables specular anti aliasing in the PBR shader.
  101735. * It will both interacts on the Geometry for analytical and IBL lighting.
  101736. * It also prefilter the roughness map based on the bump values.
  101737. */
  101738. enableSpecularAntiAliasing: boolean;
  101739. /**
  101740. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  101741. * makes the reflect vector face the model (under horizon).
  101742. */
  101743. useHorizonOcclusion: boolean;
  101744. /**
  101745. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  101746. * too much the area relying on ambient texture to define their ambient occlusion.
  101747. */
  101748. useRadianceOcclusion: boolean;
  101749. /**
  101750. * If set to true, no lighting calculations will be applied.
  101751. */
  101752. unlit: boolean;
  101753. /**
  101754. * Gets the image processing configuration used either in this material.
  101755. */
  101756. /**
  101757. * Sets the Default image processing configuration used either in the this material.
  101758. *
  101759. * If sets to null, the scene one is in use.
  101760. */
  101761. imageProcessingConfiguration: ImageProcessingConfiguration;
  101762. /**
  101763. * Gets wether the color curves effect is enabled.
  101764. */
  101765. /**
  101766. * Sets wether the color curves effect is enabled.
  101767. */
  101768. cameraColorCurvesEnabled: boolean;
  101769. /**
  101770. * Gets wether the color grading effect is enabled.
  101771. */
  101772. /**
  101773. * Gets wether the color grading effect is enabled.
  101774. */
  101775. cameraColorGradingEnabled: boolean;
  101776. /**
  101777. * Gets wether tonemapping is enabled or not.
  101778. */
  101779. /**
  101780. * Sets wether tonemapping is enabled or not
  101781. */
  101782. cameraToneMappingEnabled: boolean;
  101783. /**
  101784. * The camera exposure used on this material.
  101785. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  101786. * This corresponds to a photographic exposure.
  101787. */
  101788. /**
  101789. * The camera exposure used on this material.
  101790. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  101791. * This corresponds to a photographic exposure.
  101792. */
  101793. cameraExposure: number;
  101794. /**
  101795. * Gets The camera contrast used on this material.
  101796. */
  101797. /**
  101798. * Sets The camera contrast used on this material.
  101799. */
  101800. cameraContrast: number;
  101801. /**
  101802. * Gets the Color Grading 2D Lookup Texture.
  101803. */
  101804. /**
  101805. * Sets the Color Grading 2D Lookup Texture.
  101806. */
  101807. cameraColorGradingTexture: Nullable<BaseTexture>;
  101808. /**
  101809. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  101810. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  101811. * 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;
  101812. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  101813. */
  101814. /**
  101815. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  101816. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  101817. * 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;
  101818. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  101819. */
  101820. cameraColorCurves: Nullable<ColorCurves>;
  101821. /**
  101822. * Instantiates a new PBRMaterial instance.
  101823. *
  101824. * @param name The material name
  101825. * @param scene The scene the material will be use in.
  101826. */
  101827. constructor(name: string, scene: Scene);
  101828. /**
  101829. * Returns the name of this material class.
  101830. */
  101831. getClassName(): string;
  101832. /**
  101833. * Makes a duplicate of the current material.
  101834. * @param name - name to use for the new material.
  101835. */
  101836. clone(name: string): PBRMaterial;
  101837. /**
  101838. * Serializes this PBR Material.
  101839. * @returns - An object with the serialized material.
  101840. */
  101841. serialize(): any;
  101842. /**
  101843. * Parses a PBR Material from a serialized object.
  101844. * @param source - Serialized object.
  101845. * @param scene - BJS scene instance.
  101846. * @param rootUrl - url for the scene object
  101847. * @returns - PBRMaterial
  101848. */
  101849. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  101850. }
  101851. }
  101852. declare module BABYLON {
  101853. /**
  101854. * Direct draw surface info
  101855. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  101856. */
  101857. export interface DDSInfo {
  101858. /**
  101859. * Width of the texture
  101860. */
  101861. width: number;
  101862. /**
  101863. * Width of the texture
  101864. */
  101865. height: number;
  101866. /**
  101867. * Number of Mipmaps for the texture
  101868. * @see https://en.wikipedia.org/wiki/Mipmap
  101869. */
  101870. mipmapCount: number;
  101871. /**
  101872. * If the textures format is a known fourCC format
  101873. * @see https://www.fourcc.org/
  101874. */
  101875. isFourCC: boolean;
  101876. /**
  101877. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  101878. */
  101879. isRGB: boolean;
  101880. /**
  101881. * If the texture is a lumincance format
  101882. */
  101883. isLuminance: boolean;
  101884. /**
  101885. * If this is a cube texture
  101886. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  101887. */
  101888. isCube: boolean;
  101889. /**
  101890. * If the texture is a compressed format eg. FOURCC_DXT1
  101891. */
  101892. isCompressed: boolean;
  101893. /**
  101894. * The dxgiFormat of the texture
  101895. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  101896. */
  101897. dxgiFormat: number;
  101898. /**
  101899. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  101900. */
  101901. textureType: number;
  101902. /**
  101903. * Sphericle polynomial created for the dds texture
  101904. */
  101905. sphericalPolynomial?: SphericalPolynomial;
  101906. }
  101907. /**
  101908. * Class used to provide DDS decompression tools
  101909. */
  101910. export class DDSTools {
  101911. /**
  101912. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  101913. */
  101914. static StoreLODInAlphaChannel: boolean;
  101915. /**
  101916. * Gets DDS information from an array buffer
  101917. * @param arrayBuffer defines the array buffer to read data from
  101918. * @returns the DDS information
  101919. */
  101920. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  101921. private static _FloatView;
  101922. private static _Int32View;
  101923. private static _ToHalfFloat;
  101924. private static _FromHalfFloat;
  101925. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  101926. private static _GetHalfFloatRGBAArrayBuffer;
  101927. private static _GetFloatRGBAArrayBuffer;
  101928. private static _GetFloatAsUIntRGBAArrayBuffer;
  101929. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  101930. private static _GetRGBAArrayBuffer;
  101931. private static _ExtractLongWordOrder;
  101932. private static _GetRGBArrayBuffer;
  101933. private static _GetLuminanceArrayBuffer;
  101934. /**
  101935. * Uploads DDS Levels to a Babylon Texture
  101936. * @hidden
  101937. */
  101938. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  101939. }
  101940. interface Engine {
  101941. /**
  101942. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  101943. * @param rootUrl defines the url where the file to load is located
  101944. * @param scene defines the current scene
  101945. * @param lodScale defines scale to apply to the mip map selection
  101946. * @param lodOffset defines offset to apply to the mip map selection
  101947. * @param onLoad defines an optional callback raised when the texture is loaded
  101948. * @param onError defines an optional callback raised if there is an issue to load the texture
  101949. * @param format defines the format of the data
  101950. * @param forcedExtension defines the extension to use to pick the right loader
  101951. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  101952. * @returns the cube texture as an InternalTexture
  101953. */
  101954. 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;
  101955. }
  101956. }
  101957. declare module BABYLON {
  101958. /**
  101959. * Implementation of the DDS Texture Loader.
  101960. * @hidden
  101961. */
  101962. export class _DDSTextureLoader implements IInternalTextureLoader {
  101963. /**
  101964. * Defines wether the loader supports cascade loading the different faces.
  101965. */
  101966. readonly supportCascades: boolean;
  101967. /**
  101968. * This returns if the loader support the current file information.
  101969. * @param extension defines the file extension of the file being loaded
  101970. * @param textureFormatInUse defines the current compressed format in use iun the engine
  101971. * @param fallback defines the fallback internal texture if any
  101972. * @param isBase64 defines whether the texture is encoded as a base64
  101973. * @param isBuffer defines whether the texture data are stored as a buffer
  101974. * @returns true if the loader can load the specified file
  101975. */
  101976. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  101977. /**
  101978. * Transform the url before loading if required.
  101979. * @param rootUrl the url of the texture
  101980. * @param textureFormatInUse defines the current compressed format in use iun the engine
  101981. * @returns the transformed texture
  101982. */
  101983. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  101984. /**
  101985. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  101986. * @param rootUrl the url of the texture
  101987. * @param textureFormatInUse defines the current compressed format in use iun the engine
  101988. * @returns the fallback texture
  101989. */
  101990. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  101991. /**
  101992. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  101993. * @param data contains the texture data
  101994. * @param texture defines the BabylonJS internal texture
  101995. * @param createPolynomials will be true if polynomials have been requested
  101996. * @param onLoad defines the callback to trigger once the texture is ready
  101997. * @param onError defines the callback to trigger in case of error
  101998. */
  101999. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  102000. /**
  102001. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  102002. * @param data contains the texture data
  102003. * @param texture defines the BabylonJS internal texture
  102004. * @param callback defines the method to call once ready to upload
  102005. */
  102006. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  102007. }
  102008. }
  102009. declare module BABYLON {
  102010. /** @hidden */
  102011. export var rgbdEncodePixelShader: {
  102012. name: string;
  102013. shader: string;
  102014. };
  102015. }
  102016. declare module BABYLON {
  102017. /** @hidden */
  102018. export var rgbdDecodePixelShader: {
  102019. name: string;
  102020. shader: string;
  102021. };
  102022. }
  102023. declare module BABYLON {
  102024. /**
  102025. * Raw texture data and descriptor sufficient for WebGL texture upload
  102026. */
  102027. export interface EnvironmentTextureInfo {
  102028. /**
  102029. * Version of the environment map
  102030. */
  102031. version: number;
  102032. /**
  102033. * Width of image
  102034. */
  102035. width: number;
  102036. /**
  102037. * Irradiance information stored in the file.
  102038. */
  102039. irradiance: any;
  102040. /**
  102041. * Specular information stored in the file.
  102042. */
  102043. specular: any;
  102044. }
  102045. /**
  102046. * Sets of helpers addressing the serialization and deserialization of environment texture
  102047. * stored in a BabylonJS env file.
  102048. * Those files are usually stored as .env files.
  102049. */
  102050. export class EnvironmentTextureTools {
  102051. /**
  102052. * Magic number identifying the env file.
  102053. */
  102054. private static _MagicBytes;
  102055. /**
  102056. * Gets the environment info from an env file.
  102057. * @param data The array buffer containing the .env bytes.
  102058. * @returns the environment file info (the json header) if successfully parsed.
  102059. */
  102060. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  102061. /**
  102062. * Creates an environment texture from a loaded cube texture.
  102063. * @param texture defines the cube texture to convert in env file
  102064. * @return a promise containing the environment data if succesfull.
  102065. */
  102066. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  102067. /**
  102068. * Creates a JSON representation of the spherical data.
  102069. * @param texture defines the texture containing the polynomials
  102070. * @return the JSON representation of the spherical info
  102071. */
  102072. private static _CreateEnvTextureIrradiance;
  102073. /**
  102074. * Uploads the texture info contained in the env file to the GPU.
  102075. * @param texture defines the internal texture to upload to
  102076. * @param arrayBuffer defines the buffer cotaining the data to load
  102077. * @param info defines the texture info retrieved through the GetEnvInfo method
  102078. * @returns a promise
  102079. */
  102080. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  102081. /**
  102082. * Uploads the levels of image data to the GPU.
  102083. * @param texture defines the internal texture to upload to
  102084. * @param imageData defines the array buffer views of image data [mipmap][face]
  102085. * @returns a promise
  102086. */
  102087. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  102088. /**
  102089. * Uploads spherical polynomials information to the texture.
  102090. * @param texture defines the texture we are trying to upload the information to
  102091. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  102092. */
  102093. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  102094. /** @hidden */
  102095. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  102096. }
  102097. }
  102098. declare module BABYLON {
  102099. /**
  102100. * Implementation of the ENV Texture Loader.
  102101. * @hidden
  102102. */
  102103. export class _ENVTextureLoader implements IInternalTextureLoader {
  102104. /**
  102105. * Defines wether the loader supports cascade loading the different faces.
  102106. */
  102107. readonly supportCascades: boolean;
  102108. /**
  102109. * This returns if the loader support the current file information.
  102110. * @param extension defines the file extension of the file being loaded
  102111. * @param textureFormatInUse defines the current compressed format in use iun the engine
  102112. * @param fallback defines the fallback internal texture if any
  102113. * @param isBase64 defines whether the texture is encoded as a base64
  102114. * @param isBuffer defines whether the texture data are stored as a buffer
  102115. * @returns true if the loader can load the specified file
  102116. */
  102117. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  102118. /**
  102119. * Transform the url before loading if required.
  102120. * @param rootUrl the url of the texture
  102121. * @param textureFormatInUse defines the current compressed format in use iun the engine
  102122. * @returns the transformed texture
  102123. */
  102124. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  102125. /**
  102126. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  102127. * @param rootUrl the url of the texture
  102128. * @param textureFormatInUse defines the current compressed format in use iun the engine
  102129. * @returns the fallback texture
  102130. */
  102131. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  102132. /**
  102133. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  102134. * @param data contains the texture data
  102135. * @param texture defines the BabylonJS internal texture
  102136. * @param createPolynomials will be true if polynomials have been requested
  102137. * @param onLoad defines the callback to trigger once the texture is ready
  102138. * @param onError defines the callback to trigger in case of error
  102139. */
  102140. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  102141. /**
  102142. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  102143. * @param data contains the texture data
  102144. * @param texture defines the BabylonJS internal texture
  102145. * @param callback defines the method to call once ready to upload
  102146. */
  102147. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  102148. }
  102149. }
  102150. declare module BABYLON {
  102151. /**
  102152. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  102153. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  102154. */
  102155. export class KhronosTextureContainer {
  102156. /** contents of the KTX container file */
  102157. arrayBuffer: any;
  102158. private static HEADER_LEN;
  102159. private static COMPRESSED_2D;
  102160. private static COMPRESSED_3D;
  102161. private static TEX_2D;
  102162. private static TEX_3D;
  102163. /**
  102164. * Gets the openGL type
  102165. */
  102166. glType: number;
  102167. /**
  102168. * Gets the openGL type size
  102169. */
  102170. glTypeSize: number;
  102171. /**
  102172. * Gets the openGL format
  102173. */
  102174. glFormat: number;
  102175. /**
  102176. * Gets the openGL internal format
  102177. */
  102178. glInternalFormat: number;
  102179. /**
  102180. * Gets the base internal format
  102181. */
  102182. glBaseInternalFormat: number;
  102183. /**
  102184. * Gets image width in pixel
  102185. */
  102186. pixelWidth: number;
  102187. /**
  102188. * Gets image height in pixel
  102189. */
  102190. pixelHeight: number;
  102191. /**
  102192. * Gets image depth in pixels
  102193. */
  102194. pixelDepth: number;
  102195. /**
  102196. * Gets the number of array elements
  102197. */
  102198. numberOfArrayElements: number;
  102199. /**
  102200. * Gets the number of faces
  102201. */
  102202. numberOfFaces: number;
  102203. /**
  102204. * Gets the number of mipmap levels
  102205. */
  102206. numberOfMipmapLevels: number;
  102207. /**
  102208. * Gets the bytes of key value data
  102209. */
  102210. bytesOfKeyValueData: number;
  102211. /**
  102212. * Gets the load type
  102213. */
  102214. loadType: number;
  102215. /**
  102216. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  102217. */
  102218. isInvalid: boolean;
  102219. /**
  102220. * Creates a new KhronosTextureContainer
  102221. * @param arrayBuffer contents of the KTX container file
  102222. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  102223. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  102224. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  102225. */
  102226. constructor(
  102227. /** contents of the KTX container file */
  102228. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  102229. /**
  102230. * Uploads KTX content to a Babylon Texture.
  102231. * It is assumed that the texture has already been created & is currently bound
  102232. * @hidden
  102233. */
  102234. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  102235. private _upload2DCompressedLevels;
  102236. }
  102237. }
  102238. declare module BABYLON {
  102239. /**
  102240. * Implementation of the KTX Texture Loader.
  102241. * @hidden
  102242. */
  102243. export class _KTXTextureLoader implements IInternalTextureLoader {
  102244. /**
  102245. * Defines wether the loader supports cascade loading the different faces.
  102246. */
  102247. readonly supportCascades: boolean;
  102248. /**
  102249. * This returns if the loader support the current file information.
  102250. * @param extension defines the file extension of the file being loaded
  102251. * @param textureFormatInUse defines the current compressed format in use iun the engine
  102252. * @param fallback defines the fallback internal texture if any
  102253. * @param isBase64 defines whether the texture is encoded as a base64
  102254. * @param isBuffer defines whether the texture data are stored as a buffer
  102255. * @returns true if the loader can load the specified file
  102256. */
  102257. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  102258. /**
  102259. * Transform the url before loading if required.
  102260. * @param rootUrl the url of the texture
  102261. * @param textureFormatInUse defines the current compressed format in use iun the engine
  102262. * @returns the transformed texture
  102263. */
  102264. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  102265. /**
  102266. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  102267. * @param rootUrl the url of the texture
  102268. * @param textureFormatInUse defines the current compressed format in use iun the engine
  102269. * @returns the fallback texture
  102270. */
  102271. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  102272. /**
  102273. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  102274. * @param data contains the texture data
  102275. * @param texture defines the BabylonJS internal texture
  102276. * @param createPolynomials will be true if polynomials have been requested
  102277. * @param onLoad defines the callback to trigger once the texture is ready
  102278. * @param onError defines the callback to trigger in case of error
  102279. */
  102280. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  102281. /**
  102282. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  102283. * @param data contains the texture data
  102284. * @param texture defines the BabylonJS internal texture
  102285. * @param callback defines the method to call once ready to upload
  102286. */
  102287. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  102288. }
  102289. }
  102290. declare module BABYLON {
  102291. /** @hidden */
  102292. export var _forceSceneHelpersToBundle: boolean;
  102293. interface Scene {
  102294. /**
  102295. * Creates a default light for the scene.
  102296. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  102297. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  102298. */
  102299. createDefaultLight(replace?: boolean): void;
  102300. /**
  102301. * Creates a default camera for the scene.
  102302. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  102303. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  102304. * @param replace has default false, when true replaces the active camera in the scene
  102305. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  102306. */
  102307. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  102308. /**
  102309. * Creates a default camera and a default light.
  102310. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  102311. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  102312. * @param replace has the default false, when true replaces the active camera/light in the scene
  102313. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  102314. */
  102315. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  102316. /**
  102317. * Creates a new sky box
  102318. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  102319. * @param environmentTexture defines the texture to use as environment texture
  102320. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  102321. * @param scale defines the overall scale of the skybox
  102322. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  102323. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  102324. * @returns a new mesh holding the sky box
  102325. */
  102326. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  102327. /**
  102328. * Creates a new environment
  102329. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  102330. * @param options defines the options you can use to configure the environment
  102331. * @returns the new EnvironmentHelper
  102332. */
  102333. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  102334. /**
  102335. * Creates a new VREXperienceHelper
  102336. * @see http://doc.babylonjs.com/how_to/webvr_helper
  102337. * @param webVROptions defines the options used to create the new VREXperienceHelper
  102338. * @returns a new VREXperienceHelper
  102339. */
  102340. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  102341. /**
  102342. * Creates a new XREXperienceHelper
  102343. * @see http://doc.babylonjs.com/how_to/webxr
  102344. * @returns a promise for a new XREXperienceHelper
  102345. */
  102346. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  102347. }
  102348. }
  102349. declare module BABYLON {
  102350. /**
  102351. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  102352. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  102353. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  102354. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  102355. */
  102356. export class VideoDome extends TransformNode {
  102357. /**
  102358. * Define the video source as a Monoscopic panoramic 360 video.
  102359. */
  102360. static readonly MODE_MONOSCOPIC: number;
  102361. /**
  102362. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  102363. */
  102364. static readonly MODE_TOPBOTTOM: number;
  102365. /**
  102366. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  102367. */
  102368. static readonly MODE_SIDEBYSIDE: number;
  102369. private _useDirectMapping;
  102370. /**
  102371. * The video texture being displayed on the sphere
  102372. */
  102373. protected _videoTexture: VideoTexture;
  102374. /**
  102375. * Gets the video texture being displayed on the sphere
  102376. */
  102377. readonly videoTexture: VideoTexture;
  102378. /**
  102379. * The skybox material
  102380. */
  102381. protected _material: BackgroundMaterial;
  102382. /**
  102383. * The surface used for the skybox
  102384. */
  102385. protected _mesh: Mesh;
  102386. /**
  102387. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  102388. * Also see the options.resolution property.
  102389. */
  102390. fovMultiplier: number;
  102391. private _videoMode;
  102392. /**
  102393. * Gets or set the current video mode for the video. It can be:
  102394. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  102395. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  102396. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  102397. */
  102398. videoMode: number;
  102399. /**
  102400. * Oberserver used in Stereoscopic VR Mode.
  102401. */
  102402. private _onBeforeCameraRenderObserver;
  102403. /**
  102404. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  102405. * @param name Element's name, child elements will append suffixes for their own names.
  102406. * @param urlsOrVideo defines the url(s) or the video element to use
  102407. * @param options An object containing optional or exposed sub element properties
  102408. */
  102409. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  102410. resolution?: number;
  102411. clickToPlay?: boolean;
  102412. autoPlay?: boolean;
  102413. loop?: boolean;
  102414. size?: number;
  102415. poster?: string;
  102416. useDirectMapping?: boolean;
  102417. }, scene: Scene);
  102418. private _changeVideoMode;
  102419. /**
  102420. * Releases resources associated with this node.
  102421. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  102422. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  102423. */
  102424. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  102425. }
  102426. }
  102427. declare module BABYLON {
  102428. /**
  102429. * This class can be used to get instrumentation data from a Babylon engine
  102430. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  102431. */
  102432. export class EngineInstrumentation implements IDisposable {
  102433. /**
  102434. * Define the instrumented engine.
  102435. */
  102436. engine: Engine;
  102437. private _captureGPUFrameTime;
  102438. private _gpuFrameTimeToken;
  102439. private _gpuFrameTime;
  102440. private _captureShaderCompilationTime;
  102441. private _shaderCompilationTime;
  102442. private _onBeginFrameObserver;
  102443. private _onEndFrameObserver;
  102444. private _onBeforeShaderCompilationObserver;
  102445. private _onAfterShaderCompilationObserver;
  102446. /**
  102447. * Gets the perf counter used for GPU frame time
  102448. */
  102449. readonly gpuFrameTimeCounter: PerfCounter;
  102450. /**
  102451. * Gets the GPU frame time capture status
  102452. */
  102453. /**
  102454. * Enable or disable the GPU frame time capture
  102455. */
  102456. captureGPUFrameTime: boolean;
  102457. /**
  102458. * Gets the perf counter used for shader compilation time
  102459. */
  102460. readonly shaderCompilationTimeCounter: PerfCounter;
  102461. /**
  102462. * Gets the shader compilation time capture status
  102463. */
  102464. /**
  102465. * Enable or disable the shader compilation time capture
  102466. */
  102467. captureShaderCompilationTime: boolean;
  102468. /**
  102469. * Instantiates a new engine instrumentation.
  102470. * This class can be used to get instrumentation data from a Babylon engine
  102471. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  102472. * @param engine Defines the engine to instrument
  102473. */
  102474. constructor(
  102475. /**
  102476. * Define the instrumented engine.
  102477. */
  102478. engine: Engine);
  102479. /**
  102480. * Dispose and release associated resources.
  102481. */
  102482. dispose(): void;
  102483. }
  102484. }
  102485. declare module BABYLON {
  102486. /**
  102487. * This class can be used to get instrumentation data from a Babylon engine
  102488. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  102489. */
  102490. export class SceneInstrumentation implements IDisposable {
  102491. /**
  102492. * Defines the scene to instrument
  102493. */
  102494. scene: Scene;
  102495. private _captureActiveMeshesEvaluationTime;
  102496. private _activeMeshesEvaluationTime;
  102497. private _captureRenderTargetsRenderTime;
  102498. private _renderTargetsRenderTime;
  102499. private _captureFrameTime;
  102500. private _frameTime;
  102501. private _captureRenderTime;
  102502. private _renderTime;
  102503. private _captureInterFrameTime;
  102504. private _interFrameTime;
  102505. private _captureParticlesRenderTime;
  102506. private _particlesRenderTime;
  102507. private _captureSpritesRenderTime;
  102508. private _spritesRenderTime;
  102509. private _capturePhysicsTime;
  102510. private _physicsTime;
  102511. private _captureAnimationsTime;
  102512. private _animationsTime;
  102513. private _captureCameraRenderTime;
  102514. private _cameraRenderTime;
  102515. private _onBeforeActiveMeshesEvaluationObserver;
  102516. private _onAfterActiveMeshesEvaluationObserver;
  102517. private _onBeforeRenderTargetsRenderObserver;
  102518. private _onAfterRenderTargetsRenderObserver;
  102519. private _onAfterRenderObserver;
  102520. private _onBeforeDrawPhaseObserver;
  102521. private _onAfterDrawPhaseObserver;
  102522. private _onBeforeAnimationsObserver;
  102523. private _onBeforeParticlesRenderingObserver;
  102524. private _onAfterParticlesRenderingObserver;
  102525. private _onBeforeSpritesRenderingObserver;
  102526. private _onAfterSpritesRenderingObserver;
  102527. private _onBeforePhysicsObserver;
  102528. private _onAfterPhysicsObserver;
  102529. private _onAfterAnimationsObserver;
  102530. private _onBeforeCameraRenderObserver;
  102531. private _onAfterCameraRenderObserver;
  102532. /**
  102533. * Gets the perf counter used for active meshes evaluation time
  102534. */
  102535. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  102536. /**
  102537. * Gets the active meshes evaluation time capture status
  102538. */
  102539. /**
  102540. * Enable or disable the active meshes evaluation time capture
  102541. */
  102542. captureActiveMeshesEvaluationTime: boolean;
  102543. /**
  102544. * Gets the perf counter used for render targets render time
  102545. */
  102546. readonly renderTargetsRenderTimeCounter: PerfCounter;
  102547. /**
  102548. * Gets the render targets render time capture status
  102549. */
  102550. /**
  102551. * Enable or disable the render targets render time capture
  102552. */
  102553. captureRenderTargetsRenderTime: boolean;
  102554. /**
  102555. * Gets the perf counter used for particles render time
  102556. */
  102557. readonly particlesRenderTimeCounter: PerfCounter;
  102558. /**
  102559. * Gets the particles render time capture status
  102560. */
  102561. /**
  102562. * Enable or disable the particles render time capture
  102563. */
  102564. captureParticlesRenderTime: boolean;
  102565. /**
  102566. * Gets the perf counter used for sprites render time
  102567. */
  102568. readonly spritesRenderTimeCounter: PerfCounter;
  102569. /**
  102570. * Gets the sprites render time capture status
  102571. */
  102572. /**
  102573. * Enable or disable the sprites render time capture
  102574. */
  102575. captureSpritesRenderTime: boolean;
  102576. /**
  102577. * Gets the perf counter used for physics time
  102578. */
  102579. readonly physicsTimeCounter: PerfCounter;
  102580. /**
  102581. * Gets the physics time capture status
  102582. */
  102583. /**
  102584. * Enable or disable the physics time capture
  102585. */
  102586. capturePhysicsTime: boolean;
  102587. /**
  102588. * Gets the perf counter used for animations time
  102589. */
  102590. readonly animationsTimeCounter: PerfCounter;
  102591. /**
  102592. * Gets the animations time capture status
  102593. */
  102594. /**
  102595. * Enable or disable the animations time capture
  102596. */
  102597. captureAnimationsTime: boolean;
  102598. /**
  102599. * Gets the perf counter used for frame time capture
  102600. */
  102601. readonly frameTimeCounter: PerfCounter;
  102602. /**
  102603. * Gets the frame time capture status
  102604. */
  102605. /**
  102606. * Enable or disable the frame time capture
  102607. */
  102608. captureFrameTime: boolean;
  102609. /**
  102610. * Gets the perf counter used for inter-frames time capture
  102611. */
  102612. readonly interFrameTimeCounter: PerfCounter;
  102613. /**
  102614. * Gets the inter-frames time capture status
  102615. */
  102616. /**
  102617. * Enable or disable the inter-frames time capture
  102618. */
  102619. captureInterFrameTime: boolean;
  102620. /**
  102621. * Gets the perf counter used for render time capture
  102622. */
  102623. readonly renderTimeCounter: PerfCounter;
  102624. /**
  102625. * Gets the render time capture status
  102626. */
  102627. /**
  102628. * Enable or disable the render time capture
  102629. */
  102630. captureRenderTime: boolean;
  102631. /**
  102632. * Gets the perf counter used for camera render time capture
  102633. */
  102634. readonly cameraRenderTimeCounter: PerfCounter;
  102635. /**
  102636. * Gets the camera render time capture status
  102637. */
  102638. /**
  102639. * Enable or disable the camera render time capture
  102640. */
  102641. captureCameraRenderTime: boolean;
  102642. /**
  102643. * Gets the perf counter used for draw calls
  102644. */
  102645. readonly drawCallsCounter: PerfCounter;
  102646. /**
  102647. * Gets the perf counter used for texture collisions
  102648. */
  102649. readonly textureCollisionsCounter: PerfCounter;
  102650. /**
  102651. * Instantiates a new scene instrumentation.
  102652. * This class can be used to get instrumentation data from a Babylon engine
  102653. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  102654. * @param scene Defines the scene to instrument
  102655. */
  102656. constructor(
  102657. /**
  102658. * Defines the scene to instrument
  102659. */
  102660. scene: Scene);
  102661. /**
  102662. * Dispose and release associated resources.
  102663. */
  102664. dispose(): void;
  102665. }
  102666. }
  102667. declare module BABYLON {
  102668. /** @hidden */
  102669. export var glowMapGenerationPixelShader: {
  102670. name: string;
  102671. shader: string;
  102672. };
  102673. }
  102674. declare module BABYLON {
  102675. /** @hidden */
  102676. export var glowMapGenerationVertexShader: {
  102677. name: string;
  102678. shader: string;
  102679. };
  102680. }
  102681. declare module BABYLON {
  102682. /**
  102683. * Effect layer options. This helps customizing the behaviour
  102684. * of the effect layer.
  102685. */
  102686. export interface IEffectLayerOptions {
  102687. /**
  102688. * Multiplication factor apply to the canvas size to compute the render target size
  102689. * used to generated the objects (the smaller the faster).
  102690. */
  102691. mainTextureRatio: number;
  102692. /**
  102693. * Enforces a fixed size texture to ensure effect stability across devices.
  102694. */
  102695. mainTextureFixedSize?: number;
  102696. /**
  102697. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  102698. */
  102699. alphaBlendingMode: number;
  102700. /**
  102701. * The camera attached to the layer.
  102702. */
  102703. camera: Nullable<Camera>;
  102704. /**
  102705. * The rendering group to draw the layer in.
  102706. */
  102707. renderingGroupId: number;
  102708. }
  102709. /**
  102710. * The effect layer Helps adding post process effect blended with the main pass.
  102711. *
  102712. * This can be for instance use to generate glow or higlight effects on the scene.
  102713. *
  102714. * The effect layer class can not be used directly and is intented to inherited from to be
  102715. * customized per effects.
  102716. */
  102717. export abstract class EffectLayer {
  102718. private _vertexBuffers;
  102719. private _indexBuffer;
  102720. private _cachedDefines;
  102721. private _effectLayerMapGenerationEffect;
  102722. private _effectLayerOptions;
  102723. private _mergeEffect;
  102724. protected _scene: Scene;
  102725. protected _engine: Engine;
  102726. protected _maxSize: number;
  102727. protected _mainTextureDesiredSize: ISize;
  102728. protected _mainTexture: RenderTargetTexture;
  102729. protected _shouldRender: boolean;
  102730. protected _postProcesses: PostProcess[];
  102731. protected _textures: BaseTexture[];
  102732. protected _emissiveTextureAndColor: {
  102733. texture: Nullable<BaseTexture>;
  102734. color: Color4;
  102735. };
  102736. /**
  102737. * The name of the layer
  102738. */
  102739. name: string;
  102740. /**
  102741. * The clear color of the texture used to generate the glow map.
  102742. */
  102743. neutralColor: Color4;
  102744. /**
  102745. * Specifies wether the highlight layer is enabled or not.
  102746. */
  102747. isEnabled: boolean;
  102748. /**
  102749. * Gets the camera attached to the layer.
  102750. */
  102751. readonly camera: Nullable<Camera>;
  102752. /**
  102753. * Gets the rendering group id the layer should render in.
  102754. */
  102755. readonly renderingGroupId: number;
  102756. /**
  102757. * An event triggered when the effect layer has been disposed.
  102758. */
  102759. onDisposeObservable: Observable<EffectLayer>;
  102760. /**
  102761. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  102762. */
  102763. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  102764. /**
  102765. * An event triggered when the generated texture is being merged in the scene.
  102766. */
  102767. onBeforeComposeObservable: Observable<EffectLayer>;
  102768. /**
  102769. * An event triggered when the generated texture has been merged in the scene.
  102770. */
  102771. onAfterComposeObservable: Observable<EffectLayer>;
  102772. /**
  102773. * An event triggered when the efffect layer changes its size.
  102774. */
  102775. onSizeChangedObservable: Observable<EffectLayer>;
  102776. /** @hidden */
  102777. static _SceneComponentInitialization: (scene: Scene) => void;
  102778. /**
  102779. * Instantiates a new effect Layer and references it in the scene.
  102780. * @param name The name of the layer
  102781. * @param scene The scene to use the layer in
  102782. */
  102783. constructor(
  102784. /** The Friendly of the effect in the scene */
  102785. name: string, scene: Scene);
  102786. /**
  102787. * Get the effect name of the layer.
  102788. * @return The effect name
  102789. */
  102790. abstract getEffectName(): string;
  102791. /**
  102792. * Checks for the readiness of the element composing the layer.
  102793. * @param subMesh the mesh to check for
  102794. * @param useInstances specify wether or not to use instances to render the mesh
  102795. * @return true if ready otherwise, false
  102796. */
  102797. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  102798. /**
  102799. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  102800. * @returns true if the effect requires stencil during the main canvas render pass.
  102801. */
  102802. abstract needStencil(): boolean;
  102803. /**
  102804. * Create the merge effect. This is the shader use to blit the information back
  102805. * to the main canvas at the end of the scene rendering.
  102806. * @returns The effect containing the shader used to merge the effect on the main canvas
  102807. */
  102808. protected abstract _createMergeEffect(): Effect;
  102809. /**
  102810. * Creates the render target textures and post processes used in the effect layer.
  102811. */
  102812. protected abstract _createTextureAndPostProcesses(): void;
  102813. /**
  102814. * Implementation specific of rendering the generating effect on the main canvas.
  102815. * @param effect The effect used to render through
  102816. */
  102817. protected abstract _internalRender(effect: Effect): void;
  102818. /**
  102819. * Sets the required values for both the emissive texture and and the main color.
  102820. */
  102821. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  102822. /**
  102823. * Free any resources and references associated to a mesh.
  102824. * Internal use
  102825. * @param mesh The mesh to free.
  102826. */
  102827. abstract _disposeMesh(mesh: Mesh): void;
  102828. /**
  102829. * Serializes this layer (Glow or Highlight for example)
  102830. * @returns a serialized layer object
  102831. */
  102832. abstract serialize?(): any;
  102833. /**
  102834. * Initializes the effect layer with the required options.
  102835. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  102836. */
  102837. protected _init(options: Partial<IEffectLayerOptions>): void;
  102838. /**
  102839. * Generates the index buffer of the full screen quad blending to the main canvas.
  102840. */
  102841. private _generateIndexBuffer;
  102842. /**
  102843. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  102844. */
  102845. private _genrateVertexBuffer;
  102846. /**
  102847. * Sets the main texture desired size which is the closest power of two
  102848. * of the engine canvas size.
  102849. */
  102850. private _setMainTextureSize;
  102851. /**
  102852. * Creates the main texture for the effect layer.
  102853. */
  102854. protected _createMainTexture(): void;
  102855. /**
  102856. * Adds specific effects defines.
  102857. * @param defines The defines to add specifics to.
  102858. */
  102859. protected _addCustomEffectDefines(defines: string[]): void;
  102860. /**
  102861. * Checks for the readiness of the element composing the layer.
  102862. * @param subMesh the mesh to check for
  102863. * @param useInstances specify wether or not to use instances to render the mesh
  102864. * @param emissiveTexture the associated emissive texture used to generate the glow
  102865. * @return true if ready otherwise, false
  102866. */
  102867. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  102868. /**
  102869. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  102870. */
  102871. render(): void;
  102872. /**
  102873. * Determine if a given mesh will be used in the current effect.
  102874. * @param mesh mesh to test
  102875. * @returns true if the mesh will be used
  102876. */
  102877. hasMesh(mesh: AbstractMesh): boolean;
  102878. /**
  102879. * Returns true if the layer contains information to display, otherwise false.
  102880. * @returns true if the glow layer should be rendered
  102881. */
  102882. shouldRender(): boolean;
  102883. /**
  102884. * Returns true if the mesh should render, otherwise false.
  102885. * @param mesh The mesh to render
  102886. * @returns true if it should render otherwise false
  102887. */
  102888. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  102889. /**
  102890. * Returns true if the mesh can be rendered, otherwise false.
  102891. * @param mesh The mesh to render
  102892. * @param material The material used on the mesh
  102893. * @returns true if it can be rendered otherwise false
  102894. */
  102895. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  102896. /**
  102897. * Returns true if the mesh should render, otherwise false.
  102898. * @param mesh The mesh to render
  102899. * @returns true if it should render otherwise false
  102900. */
  102901. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  102902. /**
  102903. * Renders the submesh passed in parameter to the generation map.
  102904. */
  102905. protected _renderSubMesh(subMesh: SubMesh): void;
  102906. /**
  102907. * Rebuild the required buffers.
  102908. * @hidden Internal use only.
  102909. */
  102910. _rebuild(): void;
  102911. /**
  102912. * Dispose only the render target textures and post process.
  102913. */
  102914. private _disposeTextureAndPostProcesses;
  102915. /**
  102916. * Dispose the highlight layer and free resources.
  102917. */
  102918. dispose(): void;
  102919. /**
  102920. * Gets the class name of the effect layer
  102921. * @returns the string with the class name of the effect layer
  102922. */
  102923. getClassName(): string;
  102924. /**
  102925. * Creates an effect layer from parsed effect layer data
  102926. * @param parsedEffectLayer defines effect layer data
  102927. * @param scene defines the current scene
  102928. * @param rootUrl defines the root URL containing the effect layer information
  102929. * @returns a parsed effect Layer
  102930. */
  102931. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  102932. }
  102933. }
  102934. declare module BABYLON {
  102935. interface AbstractScene {
  102936. /**
  102937. * The list of effect layers (highlights/glow) added to the scene
  102938. * @see http://doc.babylonjs.com/how_to/highlight_layer
  102939. * @see http://doc.babylonjs.com/how_to/glow_layer
  102940. */
  102941. effectLayers: Array<EffectLayer>;
  102942. /**
  102943. * Removes the given effect layer from this scene.
  102944. * @param toRemove defines the effect layer to remove
  102945. * @returns the index of the removed effect layer
  102946. */
  102947. removeEffectLayer(toRemove: EffectLayer): number;
  102948. /**
  102949. * Adds the given effect layer to this scene
  102950. * @param newEffectLayer defines the effect layer to add
  102951. */
  102952. addEffectLayer(newEffectLayer: EffectLayer): void;
  102953. }
  102954. /**
  102955. * Defines the layer scene component responsible to manage any effect layers
  102956. * in a given scene.
  102957. */
  102958. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  102959. /**
  102960. * The component name helpfull to identify the component in the list of scene components.
  102961. */
  102962. readonly name: string;
  102963. /**
  102964. * The scene the component belongs to.
  102965. */
  102966. scene: Scene;
  102967. private _engine;
  102968. private _renderEffects;
  102969. private _needStencil;
  102970. private _previousStencilState;
  102971. /**
  102972. * Creates a new instance of the component for the given scene
  102973. * @param scene Defines the scene to register the component in
  102974. */
  102975. constructor(scene: Scene);
  102976. /**
  102977. * Registers the component in a given scene
  102978. */
  102979. register(): void;
  102980. /**
  102981. * Rebuilds the elements related to this component in case of
  102982. * context lost for instance.
  102983. */
  102984. rebuild(): void;
  102985. /**
  102986. * Serializes the component data to the specified json object
  102987. * @param serializationObject The object to serialize to
  102988. */
  102989. serialize(serializationObject: any): void;
  102990. /**
  102991. * Adds all the element from the container to the scene
  102992. * @param container the container holding the elements
  102993. */
  102994. addFromContainer(container: AbstractScene): void;
  102995. /**
  102996. * Removes all the elements in the container from the scene
  102997. * @param container contains the elements to remove
  102998. */
  102999. removeFromContainer(container: AbstractScene): void;
  103000. /**
  103001. * Disposes the component and the associated ressources.
  103002. */
  103003. dispose(): void;
  103004. private _isReadyForMesh;
  103005. private _renderMainTexture;
  103006. private _setStencil;
  103007. private _setStencilBack;
  103008. private _draw;
  103009. private _drawCamera;
  103010. private _drawRenderingGroup;
  103011. }
  103012. }
  103013. declare module BABYLON {
  103014. /** @hidden */
  103015. export var glowMapMergePixelShader: {
  103016. name: string;
  103017. shader: string;
  103018. };
  103019. }
  103020. declare module BABYLON {
  103021. /** @hidden */
  103022. export var glowMapMergeVertexShader: {
  103023. name: string;
  103024. shader: string;
  103025. };
  103026. }
  103027. declare module BABYLON {
  103028. interface AbstractScene {
  103029. /**
  103030. * Return a the first highlight layer of the scene with a given name.
  103031. * @param name The name of the highlight layer to look for.
  103032. * @return The highlight layer if found otherwise null.
  103033. */
  103034. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  103035. }
  103036. /**
  103037. * Glow layer options. This helps customizing the behaviour
  103038. * of the glow layer.
  103039. */
  103040. export interface IGlowLayerOptions {
  103041. /**
  103042. * Multiplication factor apply to the canvas size to compute the render target size
  103043. * used to generated the glowing objects (the smaller the faster).
  103044. */
  103045. mainTextureRatio: number;
  103046. /**
  103047. * Enforces a fixed size texture to ensure resize independant blur.
  103048. */
  103049. mainTextureFixedSize?: number;
  103050. /**
  103051. * How big is the kernel of the blur texture.
  103052. */
  103053. blurKernelSize: number;
  103054. /**
  103055. * The camera attached to the layer.
  103056. */
  103057. camera: Nullable<Camera>;
  103058. /**
  103059. * Enable MSAA by chosing the number of samples.
  103060. */
  103061. mainTextureSamples?: number;
  103062. /**
  103063. * The rendering group to draw the layer in.
  103064. */
  103065. renderingGroupId: number;
  103066. }
  103067. /**
  103068. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  103069. *
  103070. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  103071. * glowy meshes to your scene.
  103072. *
  103073. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  103074. */
  103075. export class GlowLayer extends EffectLayer {
  103076. /**
  103077. * Effect Name of the layer.
  103078. */
  103079. static readonly EffectName: string;
  103080. /**
  103081. * The default blur kernel size used for the glow.
  103082. */
  103083. static DefaultBlurKernelSize: number;
  103084. /**
  103085. * The default texture size ratio used for the glow.
  103086. */
  103087. static DefaultTextureRatio: number;
  103088. /**
  103089. * Sets the kernel size of the blur.
  103090. */
  103091. /**
  103092. * Gets the kernel size of the blur.
  103093. */
  103094. blurKernelSize: number;
  103095. /**
  103096. * Sets the glow intensity.
  103097. */
  103098. /**
  103099. * Gets the glow intensity.
  103100. */
  103101. intensity: number;
  103102. private _options;
  103103. private _intensity;
  103104. private _horizontalBlurPostprocess1;
  103105. private _verticalBlurPostprocess1;
  103106. private _horizontalBlurPostprocess2;
  103107. private _verticalBlurPostprocess2;
  103108. private _blurTexture1;
  103109. private _blurTexture2;
  103110. private _postProcesses1;
  103111. private _postProcesses2;
  103112. private _includedOnlyMeshes;
  103113. private _excludedMeshes;
  103114. /**
  103115. * Callback used to let the user override the color selection on a per mesh basis
  103116. */
  103117. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  103118. /**
  103119. * Callback used to let the user override the texture selection on a per mesh basis
  103120. */
  103121. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  103122. /**
  103123. * Instantiates a new glow Layer and references it to the scene.
  103124. * @param name The name of the layer
  103125. * @param scene The scene to use the layer in
  103126. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  103127. */
  103128. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  103129. /**
  103130. * Get the effect name of the layer.
  103131. * @return The effect name
  103132. */
  103133. getEffectName(): string;
  103134. /**
  103135. * Create the merge effect. This is the shader use to blit the information back
  103136. * to the main canvas at the end of the scene rendering.
  103137. */
  103138. protected _createMergeEffect(): Effect;
  103139. /**
  103140. * Creates the render target textures and post processes used in the glow layer.
  103141. */
  103142. protected _createTextureAndPostProcesses(): void;
  103143. /**
  103144. * Checks for the readiness of the element composing the layer.
  103145. * @param subMesh the mesh to check for
  103146. * @param useInstances specify wether or not to use instances to render the mesh
  103147. * @param emissiveTexture the associated emissive texture used to generate the glow
  103148. * @return true if ready otherwise, false
  103149. */
  103150. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  103151. /**
  103152. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  103153. */
  103154. needStencil(): boolean;
  103155. /**
  103156. * Returns true if the mesh can be rendered, otherwise false.
  103157. * @param mesh The mesh to render
  103158. * @param material The material used on the mesh
  103159. * @returns true if it can be rendered otherwise false
  103160. */
  103161. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  103162. /**
  103163. * Implementation specific of rendering the generating effect on the main canvas.
  103164. * @param effect The effect used to render through
  103165. */
  103166. protected _internalRender(effect: Effect): void;
  103167. /**
  103168. * Sets the required values for both the emissive texture and and the main color.
  103169. */
  103170. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  103171. /**
  103172. * Returns true if the mesh should render, otherwise false.
  103173. * @param mesh The mesh to render
  103174. * @returns true if it should render otherwise false
  103175. */
  103176. protected _shouldRenderMesh(mesh: Mesh): boolean;
  103177. /**
  103178. * Adds specific effects defines.
  103179. * @param defines The defines to add specifics to.
  103180. */
  103181. protected _addCustomEffectDefines(defines: string[]): void;
  103182. /**
  103183. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  103184. * @param mesh The mesh to exclude from the glow layer
  103185. */
  103186. addExcludedMesh(mesh: Mesh): void;
  103187. /**
  103188. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  103189. * @param mesh The mesh to remove
  103190. */
  103191. removeExcludedMesh(mesh: Mesh): void;
  103192. /**
  103193. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  103194. * @param mesh The mesh to include in the glow layer
  103195. */
  103196. addIncludedOnlyMesh(mesh: Mesh): void;
  103197. /**
  103198. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  103199. * @param mesh The mesh to remove
  103200. */
  103201. removeIncludedOnlyMesh(mesh: Mesh): void;
  103202. /**
  103203. * Determine if a given mesh will be used in the glow layer
  103204. * @param mesh The mesh to test
  103205. * @returns true if the mesh will be highlighted by the current glow layer
  103206. */
  103207. hasMesh(mesh: AbstractMesh): boolean;
  103208. /**
  103209. * Free any resources and references associated to a mesh.
  103210. * Internal use
  103211. * @param mesh The mesh to free.
  103212. * @hidden
  103213. */
  103214. _disposeMesh(mesh: Mesh): void;
  103215. /**
  103216. * Gets the class name of the effect layer
  103217. * @returns the string with the class name of the effect layer
  103218. */
  103219. getClassName(): string;
  103220. /**
  103221. * Serializes this glow layer
  103222. * @returns a serialized glow layer object
  103223. */
  103224. serialize(): any;
  103225. /**
  103226. * Creates a Glow Layer from parsed glow layer data
  103227. * @param parsedGlowLayer defines glow layer data
  103228. * @param scene defines the current scene
  103229. * @param rootUrl defines the root URL containing the glow layer information
  103230. * @returns a parsed Glow Layer
  103231. */
  103232. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  103233. }
  103234. }
  103235. declare module BABYLON {
  103236. /** @hidden */
  103237. export var glowBlurPostProcessPixelShader: {
  103238. name: string;
  103239. shader: string;
  103240. };
  103241. }
  103242. declare module BABYLON {
  103243. interface AbstractScene {
  103244. /**
  103245. * Return a the first highlight layer of the scene with a given name.
  103246. * @param name The name of the highlight layer to look for.
  103247. * @return The highlight layer if found otherwise null.
  103248. */
  103249. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  103250. }
  103251. /**
  103252. * Highlight layer options. This helps customizing the behaviour
  103253. * of the highlight layer.
  103254. */
  103255. export interface IHighlightLayerOptions {
  103256. /**
  103257. * Multiplication factor apply to the canvas size to compute the render target size
  103258. * used to generated the glowing objects (the smaller the faster).
  103259. */
  103260. mainTextureRatio: number;
  103261. /**
  103262. * Enforces a fixed size texture to ensure resize independant blur.
  103263. */
  103264. mainTextureFixedSize?: number;
  103265. /**
  103266. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  103267. * of the picture to blur (the smaller the faster).
  103268. */
  103269. blurTextureSizeRatio: number;
  103270. /**
  103271. * How big in texel of the blur texture is the vertical blur.
  103272. */
  103273. blurVerticalSize: number;
  103274. /**
  103275. * How big in texel of the blur texture is the horizontal blur.
  103276. */
  103277. blurHorizontalSize: number;
  103278. /**
  103279. * Alpha blending mode used to apply the blur. Default is combine.
  103280. */
  103281. alphaBlendingMode: number;
  103282. /**
  103283. * The camera attached to the layer.
  103284. */
  103285. camera: Nullable<Camera>;
  103286. /**
  103287. * Should we display highlight as a solid stroke?
  103288. */
  103289. isStroke?: boolean;
  103290. /**
  103291. * The rendering group to draw the layer in.
  103292. */
  103293. renderingGroupId: number;
  103294. }
  103295. /**
  103296. * The highlight layer Helps adding a glow effect around a mesh.
  103297. *
  103298. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  103299. * glowy meshes to your scene.
  103300. *
  103301. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  103302. */
  103303. export class HighlightLayer extends EffectLayer {
  103304. name: string;
  103305. /**
  103306. * Effect Name of the highlight layer.
  103307. */
  103308. static readonly EffectName: string;
  103309. /**
  103310. * The neutral color used during the preparation of the glow effect.
  103311. * This is black by default as the blend operation is a blend operation.
  103312. */
  103313. static NeutralColor: Color4;
  103314. /**
  103315. * Stencil value used for glowing meshes.
  103316. */
  103317. static GlowingMeshStencilReference: number;
  103318. /**
  103319. * Stencil value used for the other meshes in the scene.
  103320. */
  103321. static NormalMeshStencilReference: number;
  103322. /**
  103323. * Specifies whether or not the inner glow is ACTIVE in the layer.
  103324. */
  103325. innerGlow: boolean;
  103326. /**
  103327. * Specifies whether or not the outer glow is ACTIVE in the layer.
  103328. */
  103329. outerGlow: boolean;
  103330. /**
  103331. * Specifies the horizontal size of the blur.
  103332. */
  103333. /**
  103334. * Gets the horizontal size of the blur.
  103335. */
  103336. blurHorizontalSize: number;
  103337. /**
  103338. * Specifies the vertical size of the blur.
  103339. */
  103340. /**
  103341. * Gets the vertical size of the blur.
  103342. */
  103343. blurVerticalSize: number;
  103344. /**
  103345. * An event triggered when the highlight layer is being blurred.
  103346. */
  103347. onBeforeBlurObservable: Observable<HighlightLayer>;
  103348. /**
  103349. * An event triggered when the highlight layer has been blurred.
  103350. */
  103351. onAfterBlurObservable: Observable<HighlightLayer>;
  103352. private _instanceGlowingMeshStencilReference;
  103353. private _options;
  103354. private _downSamplePostprocess;
  103355. private _horizontalBlurPostprocess;
  103356. private _verticalBlurPostprocess;
  103357. private _blurTexture;
  103358. private _meshes;
  103359. private _excludedMeshes;
  103360. /**
  103361. * Instantiates a new highlight Layer and references it to the scene..
  103362. * @param name The name of the layer
  103363. * @param scene The scene to use the layer in
  103364. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  103365. */
  103366. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  103367. /**
  103368. * Get the effect name of the layer.
  103369. * @return The effect name
  103370. */
  103371. getEffectName(): string;
  103372. /**
  103373. * Create the merge effect. This is the shader use to blit the information back
  103374. * to the main canvas at the end of the scene rendering.
  103375. */
  103376. protected _createMergeEffect(): Effect;
  103377. /**
  103378. * Creates the render target textures and post processes used in the highlight layer.
  103379. */
  103380. protected _createTextureAndPostProcesses(): void;
  103381. /**
  103382. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  103383. */
  103384. needStencil(): boolean;
  103385. /**
  103386. * Checks for the readiness of the element composing the layer.
  103387. * @param subMesh the mesh to check for
  103388. * @param useInstances specify wether or not to use instances to render the mesh
  103389. * @param emissiveTexture the associated emissive texture used to generate the glow
  103390. * @return true if ready otherwise, false
  103391. */
  103392. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  103393. /**
  103394. * Implementation specific of rendering the generating effect on the main canvas.
  103395. * @param effect The effect used to render through
  103396. */
  103397. protected _internalRender(effect: Effect): void;
  103398. /**
  103399. * Returns true if the layer contains information to display, otherwise false.
  103400. */
  103401. shouldRender(): boolean;
  103402. /**
  103403. * Returns true if the mesh should render, otherwise false.
  103404. * @param mesh The mesh to render
  103405. * @returns true if it should render otherwise false
  103406. */
  103407. protected _shouldRenderMesh(mesh: Mesh): boolean;
  103408. /**
  103409. * Sets the required values for both the emissive texture and and the main color.
  103410. */
  103411. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  103412. /**
  103413. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  103414. * @param mesh The mesh to exclude from the highlight layer
  103415. */
  103416. addExcludedMesh(mesh: Mesh): void;
  103417. /**
  103418. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  103419. * @param mesh The mesh to highlight
  103420. */
  103421. removeExcludedMesh(mesh: Mesh): void;
  103422. /**
  103423. * Determine if a given mesh will be highlighted by the current HighlightLayer
  103424. * @param mesh mesh to test
  103425. * @returns true if the mesh will be highlighted by the current HighlightLayer
  103426. */
  103427. hasMesh(mesh: AbstractMesh): boolean;
  103428. /**
  103429. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  103430. * @param mesh The mesh to highlight
  103431. * @param color The color of the highlight
  103432. * @param glowEmissiveOnly Extract the glow from the emissive texture
  103433. */
  103434. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  103435. /**
  103436. * Remove a mesh from the highlight layer in order to make it stop glowing.
  103437. * @param mesh The mesh to highlight
  103438. */
  103439. removeMesh(mesh: Mesh): void;
  103440. /**
  103441. * Force the stencil to the normal expected value for none glowing parts
  103442. */
  103443. private _defaultStencilReference;
  103444. /**
  103445. * Free any resources and references associated to a mesh.
  103446. * Internal use
  103447. * @param mesh The mesh to free.
  103448. * @hidden
  103449. */
  103450. _disposeMesh(mesh: Mesh): void;
  103451. /**
  103452. * Dispose the highlight layer and free resources.
  103453. */
  103454. dispose(): void;
  103455. /**
  103456. * Gets the class name of the effect layer
  103457. * @returns the string with the class name of the effect layer
  103458. */
  103459. getClassName(): string;
  103460. /**
  103461. * Serializes this Highlight layer
  103462. * @returns a serialized Highlight layer object
  103463. */
  103464. serialize(): any;
  103465. /**
  103466. * Creates a Highlight layer from parsed Highlight layer data
  103467. * @param parsedHightlightLayer defines the Highlight layer data
  103468. * @param scene defines the current scene
  103469. * @param rootUrl defines the root URL containing the Highlight layer information
  103470. * @returns a parsed Highlight layer
  103471. */
  103472. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  103473. }
  103474. }
  103475. declare module BABYLON {
  103476. /** @hidden */
  103477. export var lensFlarePixelShader: {
  103478. name: string;
  103479. shader: string;
  103480. };
  103481. }
  103482. declare module BABYLON {
  103483. /** @hidden */
  103484. export var lensFlareVertexShader: {
  103485. name: string;
  103486. shader: string;
  103487. };
  103488. }
  103489. declare module BABYLON {
  103490. /**
  103491. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  103492. * It is usually composed of several `lensFlare`.
  103493. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  103494. */
  103495. export class LensFlareSystem {
  103496. /**
  103497. * Define the name of the lens flare system
  103498. */
  103499. name: string;
  103500. /**
  103501. * List of lens flares used in this system.
  103502. */
  103503. lensFlares: LensFlare[];
  103504. /**
  103505. * Define a limit from the border the lens flare can be visible.
  103506. */
  103507. borderLimit: number;
  103508. /**
  103509. * Define a viewport border we do not want to see the lens flare in.
  103510. */
  103511. viewportBorder: number;
  103512. /**
  103513. * Define a predicate which could limit the list of meshes able to occlude the effect.
  103514. */
  103515. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  103516. /**
  103517. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  103518. */
  103519. layerMask: number;
  103520. /**
  103521. * Define the id of the lens flare system in the scene.
  103522. * (equal to name by default)
  103523. */
  103524. id: string;
  103525. private _scene;
  103526. private _emitter;
  103527. private _vertexBuffers;
  103528. private _indexBuffer;
  103529. private _effect;
  103530. private _positionX;
  103531. private _positionY;
  103532. private _isEnabled;
  103533. /** @hidden */
  103534. static _SceneComponentInitialization: (scene: Scene) => void;
  103535. /**
  103536. * Instantiates a lens flare system.
  103537. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  103538. * It is usually composed of several `lensFlare`.
  103539. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  103540. * @param name Define the name of the lens flare system in the scene
  103541. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  103542. * @param scene Define the scene the lens flare system belongs to
  103543. */
  103544. constructor(
  103545. /**
  103546. * Define the name of the lens flare system
  103547. */
  103548. name: string, emitter: any, scene: Scene);
  103549. /**
  103550. * Define if the lens flare system is enabled.
  103551. */
  103552. isEnabled: boolean;
  103553. /**
  103554. * Get the scene the effects belongs to.
  103555. * @returns the scene holding the lens flare system
  103556. */
  103557. getScene(): Scene;
  103558. /**
  103559. * Get the emitter of the lens flare system.
  103560. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  103561. * @returns the emitter of the lens flare system
  103562. */
  103563. getEmitter(): any;
  103564. /**
  103565. * Set the emitter of the lens flare system.
  103566. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  103567. * @param newEmitter Define the new emitter of the system
  103568. */
  103569. setEmitter(newEmitter: any): void;
  103570. /**
  103571. * Get the lens flare system emitter position.
  103572. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  103573. * @returns the position
  103574. */
  103575. getEmitterPosition(): Vector3;
  103576. /**
  103577. * @hidden
  103578. */
  103579. computeEffectivePosition(globalViewport: Viewport): boolean;
  103580. /** @hidden */
  103581. _isVisible(): boolean;
  103582. /**
  103583. * @hidden
  103584. */
  103585. render(): boolean;
  103586. /**
  103587. * Dispose and release the lens flare with its associated resources.
  103588. */
  103589. dispose(): void;
  103590. /**
  103591. * Parse a lens flare system from a JSON repressentation
  103592. * @param parsedLensFlareSystem Define the JSON to parse
  103593. * @param scene Define the scene the parsed system should be instantiated in
  103594. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  103595. * @returns the parsed system
  103596. */
  103597. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  103598. /**
  103599. * Serialize the current Lens Flare System into a JSON representation.
  103600. * @returns the serialized JSON
  103601. */
  103602. serialize(): any;
  103603. }
  103604. }
  103605. declare module BABYLON {
  103606. /**
  103607. * This represents one of the lens effect in a `lensFlareSystem`.
  103608. * It controls one of the indiviual texture used in the effect.
  103609. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  103610. */
  103611. export class LensFlare {
  103612. /**
  103613. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  103614. */
  103615. size: number;
  103616. /**
  103617. * 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.
  103618. */
  103619. position: number;
  103620. /**
  103621. * Define the lens color.
  103622. */
  103623. color: Color3;
  103624. /**
  103625. * Define the lens texture.
  103626. */
  103627. texture: Nullable<Texture>;
  103628. /**
  103629. * Define the alpha mode to render this particular lens.
  103630. */
  103631. alphaMode: number;
  103632. private _system;
  103633. /**
  103634. * Creates a new Lens Flare.
  103635. * This represents one of the lens effect in a `lensFlareSystem`.
  103636. * It controls one of the indiviual texture used in the effect.
  103637. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  103638. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  103639. * @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.
  103640. * @param color Define the lens color
  103641. * @param imgUrl Define the lens texture url
  103642. * @param system Define the `lensFlareSystem` this flare is part of
  103643. * @returns The newly created Lens Flare
  103644. */
  103645. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  103646. /**
  103647. * Instantiates a new Lens Flare.
  103648. * This represents one of the lens effect in a `lensFlareSystem`.
  103649. * It controls one of the indiviual texture used in the effect.
  103650. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  103651. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  103652. * @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.
  103653. * @param color Define the lens color
  103654. * @param imgUrl Define the lens texture url
  103655. * @param system Define the `lensFlareSystem` this flare is part of
  103656. */
  103657. constructor(
  103658. /**
  103659. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  103660. */
  103661. size: number,
  103662. /**
  103663. * 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.
  103664. */
  103665. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  103666. /**
  103667. * Dispose and release the lens flare with its associated resources.
  103668. */
  103669. dispose(): void;
  103670. }
  103671. }
  103672. declare module BABYLON {
  103673. interface AbstractScene {
  103674. /**
  103675. * The list of lens flare system added to the scene
  103676. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  103677. */
  103678. lensFlareSystems: Array<LensFlareSystem>;
  103679. /**
  103680. * Removes the given lens flare system from this scene.
  103681. * @param toRemove The lens flare system to remove
  103682. * @returns The index of the removed lens flare system
  103683. */
  103684. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  103685. /**
  103686. * Adds the given lens flare system to this scene
  103687. * @param newLensFlareSystem The lens flare system to add
  103688. */
  103689. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  103690. /**
  103691. * Gets a lens flare system using its name
  103692. * @param name defines the name to look for
  103693. * @returns the lens flare system or null if not found
  103694. */
  103695. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  103696. /**
  103697. * Gets a lens flare system using its id
  103698. * @param id defines the id to look for
  103699. * @returns the lens flare system or null if not found
  103700. */
  103701. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  103702. }
  103703. /**
  103704. * Defines the lens flare scene component responsible to manage any lens flares
  103705. * in a given scene.
  103706. */
  103707. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  103708. /**
  103709. * The component name helpfull to identify the component in the list of scene components.
  103710. */
  103711. readonly name: string;
  103712. /**
  103713. * The scene the component belongs to.
  103714. */
  103715. scene: Scene;
  103716. /**
  103717. * Creates a new instance of the component for the given scene
  103718. * @param scene Defines the scene to register the component in
  103719. */
  103720. constructor(scene: Scene);
  103721. /**
  103722. * Registers the component in a given scene
  103723. */
  103724. register(): void;
  103725. /**
  103726. * Rebuilds the elements related to this component in case of
  103727. * context lost for instance.
  103728. */
  103729. rebuild(): void;
  103730. /**
  103731. * Adds all the element from the container to the scene
  103732. * @param container the container holding the elements
  103733. */
  103734. addFromContainer(container: AbstractScene): void;
  103735. /**
  103736. * Removes all the elements in the container from the scene
  103737. * @param container contains the elements to remove
  103738. */
  103739. removeFromContainer(container: AbstractScene): void;
  103740. /**
  103741. * Serializes the component data to the specified json object
  103742. * @param serializationObject The object to serialize to
  103743. */
  103744. serialize(serializationObject: any): void;
  103745. /**
  103746. * Disposes the component and the associated ressources.
  103747. */
  103748. dispose(): void;
  103749. private _draw;
  103750. }
  103751. }
  103752. declare module BABYLON {
  103753. /**
  103754. * Defines the shadow generator component responsible to manage any shadow generators
  103755. * in a given scene.
  103756. */
  103757. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  103758. /**
  103759. * The component name helpfull to identify the component in the list of scene components.
  103760. */
  103761. readonly name: string;
  103762. /**
  103763. * The scene the component belongs to.
  103764. */
  103765. scene: Scene;
  103766. /**
  103767. * Creates a new instance of the component for the given scene
  103768. * @param scene Defines the scene to register the component in
  103769. */
  103770. constructor(scene: Scene);
  103771. /**
  103772. * Registers the component in a given scene
  103773. */
  103774. register(): void;
  103775. /**
  103776. * Rebuilds the elements related to this component in case of
  103777. * context lost for instance.
  103778. */
  103779. rebuild(): void;
  103780. /**
  103781. * Serializes the component data to the specified json object
  103782. * @param serializationObject The object to serialize to
  103783. */
  103784. serialize(serializationObject: any): void;
  103785. /**
  103786. * Adds all the element from the container to the scene
  103787. * @param container the container holding the elements
  103788. */
  103789. addFromContainer(container: AbstractScene): void;
  103790. /**
  103791. * Removes all the elements in the container from the scene
  103792. * @param container contains the elements to remove
  103793. */
  103794. removeFromContainer(container: AbstractScene): void;
  103795. /**
  103796. * Rebuilds the elements related to this component in case of
  103797. * context lost for instance.
  103798. */
  103799. dispose(): void;
  103800. private _gatherRenderTargets;
  103801. }
  103802. }
  103803. declare module BABYLON {
  103804. /**
  103805. * A directional light is defined by a direction (what a surprise!).
  103806. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  103807. * 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.
  103808. * Documentation: https://doc.babylonjs.com/babylon101/lights
  103809. */
  103810. export class DirectionalLight extends ShadowLight {
  103811. private _shadowFrustumSize;
  103812. /**
  103813. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  103814. */
  103815. /**
  103816. * Specifies a fix frustum size for the shadow generation.
  103817. */
  103818. shadowFrustumSize: number;
  103819. private _shadowOrthoScale;
  103820. /**
  103821. * Gets the shadow projection scale against the optimal computed one.
  103822. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  103823. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  103824. */
  103825. /**
  103826. * Sets the shadow projection scale against the optimal computed one.
  103827. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  103828. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  103829. */
  103830. shadowOrthoScale: number;
  103831. /**
  103832. * Automatically compute the projection matrix to best fit (including all the casters)
  103833. * on each frame.
  103834. */
  103835. autoUpdateExtends: boolean;
  103836. private _orthoLeft;
  103837. private _orthoRight;
  103838. private _orthoTop;
  103839. private _orthoBottom;
  103840. /**
  103841. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  103842. * The directional light is emitted from everywhere in the given direction.
  103843. * It can cast shadows.
  103844. * Documentation : https://doc.babylonjs.com/babylon101/lights
  103845. * @param name The friendly name of the light
  103846. * @param direction The direction of the light
  103847. * @param scene The scene the light belongs to
  103848. */
  103849. constructor(name: string, direction: Vector3, scene: Scene);
  103850. /**
  103851. * Returns the string "DirectionalLight".
  103852. * @return The class name
  103853. */
  103854. getClassName(): string;
  103855. /**
  103856. * Returns the integer 1.
  103857. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  103858. */
  103859. getTypeID(): number;
  103860. /**
  103861. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  103862. * Returns the DirectionalLight Shadow projection matrix.
  103863. */
  103864. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  103865. /**
  103866. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  103867. * Returns the DirectionalLight Shadow projection matrix.
  103868. */
  103869. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  103870. /**
  103871. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  103872. * Returns the DirectionalLight Shadow projection matrix.
  103873. */
  103874. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  103875. protected _buildUniformLayout(): void;
  103876. /**
  103877. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  103878. * @param effect The effect to update
  103879. * @param lightIndex The index of the light in the effect to update
  103880. * @returns The directional light
  103881. */
  103882. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  103883. /**
  103884. * Gets the minZ used for shadow according to both the scene and the light.
  103885. *
  103886. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  103887. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  103888. * @param activeCamera The camera we are returning the min for
  103889. * @returns the depth min z
  103890. */
  103891. getDepthMinZ(activeCamera: Camera): number;
  103892. /**
  103893. * Gets the maxZ used for shadow according to both the scene and the light.
  103894. *
  103895. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  103896. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  103897. * @param activeCamera The camera we are returning the max for
  103898. * @returns the depth max z
  103899. */
  103900. getDepthMaxZ(activeCamera: Camera): number;
  103901. /**
  103902. * Prepares the list of defines specific to the light type.
  103903. * @param defines the list of defines
  103904. * @param lightIndex defines the index of the light for the effect
  103905. */
  103906. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  103907. }
  103908. }
  103909. declare module BABYLON {
  103910. /**
  103911. * A point light is a light defined by an unique point in world space.
  103912. * The light is emitted in every direction from this point.
  103913. * A good example of a point light is a standard light bulb.
  103914. * Documentation: https://doc.babylonjs.com/babylon101/lights
  103915. */
  103916. export class PointLight extends ShadowLight {
  103917. private _shadowAngle;
  103918. /**
  103919. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  103920. * This specifies what angle the shadow will use to be created.
  103921. *
  103922. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  103923. */
  103924. /**
  103925. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  103926. * This specifies what angle the shadow will use to be created.
  103927. *
  103928. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  103929. */
  103930. shadowAngle: number;
  103931. /**
  103932. * Gets the direction if it has been set.
  103933. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  103934. */
  103935. /**
  103936. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  103937. */
  103938. direction: Vector3;
  103939. /**
  103940. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  103941. * A PointLight emits the light in every direction.
  103942. * It can cast shadows.
  103943. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  103944. * ```javascript
  103945. * var pointLight = new PointLight("pl", camera.position, scene);
  103946. * ```
  103947. * Documentation : https://doc.babylonjs.com/babylon101/lights
  103948. * @param name The light friendly name
  103949. * @param position The position of the point light in the scene
  103950. * @param scene The scene the lights belongs to
  103951. */
  103952. constructor(name: string, position: Vector3, scene: Scene);
  103953. /**
  103954. * Returns the string "PointLight"
  103955. * @returns the class name
  103956. */
  103957. getClassName(): string;
  103958. /**
  103959. * Returns the integer 0.
  103960. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  103961. */
  103962. getTypeID(): number;
  103963. /**
  103964. * Specifies wether or not the shadowmap should be a cube texture.
  103965. * @returns true if the shadowmap needs to be a cube texture.
  103966. */
  103967. needCube(): boolean;
  103968. /**
  103969. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  103970. * @param faceIndex The index of the face we are computed the direction to generate shadow
  103971. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  103972. */
  103973. getShadowDirection(faceIndex?: number): Vector3;
  103974. /**
  103975. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  103976. * - fov = PI / 2
  103977. * - aspect ratio : 1.0
  103978. * - z-near and far equal to the active camera minZ and maxZ.
  103979. * Returns the PointLight.
  103980. */
  103981. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  103982. protected _buildUniformLayout(): void;
  103983. /**
  103984. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  103985. * @param effect The effect to update
  103986. * @param lightIndex The index of the light in the effect to update
  103987. * @returns The point light
  103988. */
  103989. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  103990. /**
  103991. * Prepares the list of defines specific to the light type.
  103992. * @param defines the list of defines
  103993. * @param lightIndex defines the index of the light for the effect
  103994. */
  103995. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  103996. }
  103997. }
  103998. declare module BABYLON {
  103999. /**
  104000. * A spot light is defined by a position, a direction, an angle, and an exponent.
  104001. * These values define a cone of light starting from the position, emitting toward the direction.
  104002. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  104003. * and the exponent defines the speed of the decay of the light with distance (reach).
  104004. * Documentation: https://doc.babylonjs.com/babylon101/lights
  104005. */
  104006. export class SpotLight extends ShadowLight {
  104007. private _angle;
  104008. private _innerAngle;
  104009. private _cosHalfAngle;
  104010. private _lightAngleScale;
  104011. private _lightAngleOffset;
  104012. /**
  104013. * Gets the cone angle of the spot light in Radians.
  104014. */
  104015. /**
  104016. * Sets the cone angle of the spot light in Radians.
  104017. */
  104018. angle: number;
  104019. /**
  104020. * Only used in gltf falloff mode, this defines the angle where
  104021. * the directional falloff will start before cutting at angle which could be seen
  104022. * as outer angle.
  104023. */
  104024. /**
  104025. * Only used in gltf falloff mode, this defines the angle where
  104026. * the directional falloff will start before cutting at angle which could be seen
  104027. * as outer angle.
  104028. */
  104029. innerAngle: number;
  104030. private _shadowAngleScale;
  104031. /**
  104032. * Allows scaling the angle of the light for shadow generation only.
  104033. */
  104034. /**
  104035. * Allows scaling the angle of the light for shadow generation only.
  104036. */
  104037. shadowAngleScale: number;
  104038. /**
  104039. * The light decay speed with the distance from the emission spot.
  104040. */
  104041. exponent: number;
  104042. private _projectionTextureMatrix;
  104043. /**
  104044. * Allows reading the projecton texture
  104045. */
  104046. readonly projectionTextureMatrix: Matrix;
  104047. protected _projectionTextureLightNear: number;
  104048. /**
  104049. * Gets the near clip of the Spotlight for texture projection.
  104050. */
  104051. /**
  104052. * Sets the near clip of the Spotlight for texture projection.
  104053. */
  104054. projectionTextureLightNear: number;
  104055. protected _projectionTextureLightFar: number;
  104056. /**
  104057. * Gets the far clip of the Spotlight for texture projection.
  104058. */
  104059. /**
  104060. * Sets the far clip of the Spotlight for texture projection.
  104061. */
  104062. projectionTextureLightFar: number;
  104063. protected _projectionTextureUpDirection: Vector3;
  104064. /**
  104065. * Gets the Up vector of the Spotlight for texture projection.
  104066. */
  104067. /**
  104068. * Sets the Up vector of the Spotlight for texture projection.
  104069. */
  104070. projectionTextureUpDirection: Vector3;
  104071. private _projectionTexture;
  104072. /**
  104073. * Gets the projection texture of the light.
  104074. */
  104075. /**
  104076. * Sets the projection texture of the light.
  104077. */
  104078. projectionTexture: Nullable<BaseTexture>;
  104079. private _projectionTextureViewLightDirty;
  104080. private _projectionTextureProjectionLightDirty;
  104081. private _projectionTextureDirty;
  104082. private _projectionTextureViewTargetVector;
  104083. private _projectionTextureViewLightMatrix;
  104084. private _projectionTextureProjectionLightMatrix;
  104085. private _projectionTextureScalingMatrix;
  104086. /**
  104087. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  104088. * It can cast shadows.
  104089. * Documentation : https://doc.babylonjs.com/babylon101/lights
  104090. * @param name The light friendly name
  104091. * @param position The position of the spot light in the scene
  104092. * @param direction The direction of the light in the scene
  104093. * @param angle The cone angle of the light in Radians
  104094. * @param exponent The light decay speed with the distance from the emission spot
  104095. * @param scene The scene the lights belongs to
  104096. */
  104097. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  104098. /**
  104099. * Returns the string "SpotLight".
  104100. * @returns the class name
  104101. */
  104102. getClassName(): string;
  104103. /**
  104104. * Returns the integer 2.
  104105. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  104106. */
  104107. getTypeID(): number;
  104108. /**
  104109. * Overrides the direction setter to recompute the projection texture view light Matrix.
  104110. */
  104111. protected _setDirection(value: Vector3): void;
  104112. /**
  104113. * Overrides the position setter to recompute the projection texture view light Matrix.
  104114. */
  104115. protected _setPosition(value: Vector3): void;
  104116. /**
  104117. * 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.
  104118. * Returns the SpotLight.
  104119. */
  104120. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  104121. protected _computeProjectionTextureViewLightMatrix(): void;
  104122. protected _computeProjectionTextureProjectionLightMatrix(): void;
  104123. /**
  104124. * Main function for light texture projection matrix computing.
  104125. */
  104126. protected _computeProjectionTextureMatrix(): void;
  104127. protected _buildUniformLayout(): void;
  104128. private _computeAngleValues;
  104129. /**
  104130. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  104131. * @param effect The effect to update
  104132. * @param lightIndex The index of the light in the effect to update
  104133. * @returns The spot light
  104134. */
  104135. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  104136. /**
  104137. * Disposes the light and the associated resources.
  104138. */
  104139. dispose(): void;
  104140. /**
  104141. * Prepares the list of defines specific to the light type.
  104142. * @param defines the list of defines
  104143. * @param lightIndex defines the index of the light for the effect
  104144. */
  104145. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  104146. }
  104147. }
  104148. declare module BABYLON {
  104149. /**
  104150. * Header information of HDR texture files.
  104151. */
  104152. export interface HDRInfo {
  104153. /**
  104154. * The height of the texture in pixels.
  104155. */
  104156. height: number;
  104157. /**
  104158. * The width of the texture in pixels.
  104159. */
  104160. width: number;
  104161. /**
  104162. * The index of the beginning of the data in the binary file.
  104163. */
  104164. dataPosition: number;
  104165. }
  104166. /**
  104167. * This groups tools to convert HDR texture to native colors array.
  104168. */
  104169. export class HDRTools {
  104170. private static Ldexp;
  104171. private static Rgbe2float;
  104172. private static readStringLine;
  104173. /**
  104174. * Reads header information from an RGBE texture stored in a native array.
  104175. * More information on this format are available here:
  104176. * https://en.wikipedia.org/wiki/RGBE_image_format
  104177. *
  104178. * @param uint8array The binary file stored in native array.
  104179. * @return The header information.
  104180. */
  104181. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  104182. /**
  104183. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  104184. * This RGBE texture needs to store the information as a panorama.
  104185. *
  104186. * More information on this format are available here:
  104187. * https://en.wikipedia.org/wiki/RGBE_image_format
  104188. *
  104189. * @param buffer The binary file stored in an array buffer.
  104190. * @param size The expected size of the extracted cubemap.
  104191. * @return The Cube Map information.
  104192. */
  104193. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  104194. /**
  104195. * Returns the pixels data extracted from an RGBE texture.
  104196. * This pixels will be stored left to right up to down in the R G B order in one array.
  104197. *
  104198. * More information on this format are available here:
  104199. * https://en.wikipedia.org/wiki/RGBE_image_format
  104200. *
  104201. * @param uint8array The binary file stored in an array buffer.
  104202. * @param hdrInfo The header information of the file.
  104203. * @return The pixels data in RGB right to left up to down order.
  104204. */
  104205. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  104206. private static RGBE_ReadPixels_RLE;
  104207. }
  104208. }
  104209. declare module BABYLON {
  104210. /**
  104211. * This represents a texture coming from an HDR input.
  104212. *
  104213. * The only supported format is currently panorama picture stored in RGBE format.
  104214. * Example of such files can be found on HDRLib: http://hdrlib.com/
  104215. */
  104216. export class HDRCubeTexture extends BaseTexture {
  104217. private static _facesMapping;
  104218. private _generateHarmonics;
  104219. private _noMipmap;
  104220. private _textureMatrix;
  104221. private _size;
  104222. private _onLoad;
  104223. private _onError;
  104224. /**
  104225. * The texture URL.
  104226. */
  104227. url: string;
  104228. /**
  104229. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  104230. */
  104231. coordinatesMode: number;
  104232. protected _isBlocking: boolean;
  104233. /**
  104234. * Sets wether or not the texture is blocking during loading.
  104235. */
  104236. /**
  104237. * Gets wether or not the texture is blocking during loading.
  104238. */
  104239. isBlocking: boolean;
  104240. protected _rotationY: number;
  104241. /**
  104242. * Sets texture matrix rotation angle around Y axis in radians.
  104243. */
  104244. /**
  104245. * Gets texture matrix rotation angle around Y axis radians.
  104246. */
  104247. rotationY: number;
  104248. /**
  104249. * Gets or sets the center of the bounding box associated with the cube texture
  104250. * It must define where the camera used to render the texture was set
  104251. */
  104252. boundingBoxPosition: Vector3;
  104253. private _boundingBoxSize;
  104254. /**
  104255. * Gets or sets the size of the bounding box associated with the cube texture
  104256. * When defined, the cubemap will switch to local mode
  104257. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  104258. * @example https://www.babylonjs-playground.com/#RNASML
  104259. */
  104260. boundingBoxSize: Vector3;
  104261. /**
  104262. * Instantiates an HDRTexture from the following parameters.
  104263. *
  104264. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  104265. * @param scene The scene the texture will be used in
  104266. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  104267. * @param noMipmap Forces to not generate the mipmap if true
  104268. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  104269. * @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)
  104270. * @param reserved Reserved flag for internal use.
  104271. */
  104272. 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>);
  104273. /**
  104274. * Get the current class name of the texture useful for serialization or dynamic coding.
  104275. * @returns "HDRCubeTexture"
  104276. */
  104277. getClassName(): string;
  104278. /**
  104279. * Occurs when the file is raw .hdr file.
  104280. */
  104281. private loadTexture;
  104282. clone(): HDRCubeTexture;
  104283. delayLoad(): void;
  104284. /**
  104285. * Get the texture reflection matrix used to rotate/transform the reflection.
  104286. * @returns the reflection matrix
  104287. */
  104288. getReflectionTextureMatrix(): Matrix;
  104289. /**
  104290. * Set the texture reflection matrix used to rotate/transform the reflection.
  104291. * @param value Define the reflection matrix to set
  104292. */
  104293. setReflectionTextureMatrix(value: Matrix): void;
  104294. /**
  104295. * Parses a JSON representation of an HDR Texture in order to create the texture
  104296. * @param parsedTexture Define the JSON representation
  104297. * @param scene Define the scene the texture should be created in
  104298. * @param rootUrl Define the root url in case we need to load relative dependencies
  104299. * @returns the newly created texture after parsing
  104300. */
  104301. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  104302. serialize(): any;
  104303. }
  104304. }
  104305. declare module BABYLON {
  104306. /**
  104307. * Class used to control physics engine
  104308. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  104309. */
  104310. export class PhysicsEngine implements IPhysicsEngine {
  104311. private _physicsPlugin;
  104312. /**
  104313. * Global value used to control the smallest number supported by the simulation
  104314. */
  104315. static Epsilon: number;
  104316. private _impostors;
  104317. private _joints;
  104318. /**
  104319. * Gets the gravity vector used by the simulation
  104320. */
  104321. gravity: Vector3;
  104322. /**
  104323. * Factory used to create the default physics plugin.
  104324. * @returns The default physics plugin
  104325. */
  104326. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  104327. /**
  104328. * Creates a new Physics Engine
  104329. * @param gravity defines the gravity vector used by the simulation
  104330. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  104331. */
  104332. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  104333. /**
  104334. * Sets the gravity vector used by the simulation
  104335. * @param gravity defines the gravity vector to use
  104336. */
  104337. setGravity(gravity: Vector3): void;
  104338. /**
  104339. * Set the time step of the physics engine.
  104340. * Default is 1/60.
  104341. * To slow it down, enter 1/600 for example.
  104342. * To speed it up, 1/30
  104343. * @param newTimeStep defines the new timestep to apply to this world.
  104344. */
  104345. setTimeStep(newTimeStep?: number): void;
  104346. /**
  104347. * Get the time step of the physics engine.
  104348. * @returns the current time step
  104349. */
  104350. getTimeStep(): number;
  104351. /**
  104352. * Release all resources
  104353. */
  104354. dispose(): void;
  104355. /**
  104356. * Gets the name of the current physics plugin
  104357. * @returns the name of the plugin
  104358. */
  104359. getPhysicsPluginName(): string;
  104360. /**
  104361. * Adding a new impostor for the impostor tracking.
  104362. * This will be done by the impostor itself.
  104363. * @param impostor the impostor to add
  104364. */
  104365. addImpostor(impostor: PhysicsImpostor): void;
  104366. /**
  104367. * Remove an impostor from the engine.
  104368. * This impostor and its mesh will not longer be updated by the physics engine.
  104369. * @param impostor the impostor to remove
  104370. */
  104371. removeImpostor(impostor: PhysicsImpostor): void;
  104372. /**
  104373. * Add a joint to the physics engine
  104374. * @param mainImpostor defines the main impostor to which the joint is added.
  104375. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  104376. * @param joint defines the joint that will connect both impostors.
  104377. */
  104378. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  104379. /**
  104380. * Removes a joint from the simulation
  104381. * @param mainImpostor defines the impostor used with the joint
  104382. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  104383. * @param joint defines the joint to remove
  104384. */
  104385. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  104386. /**
  104387. * Called by the scene. No need to call it.
  104388. * @param delta defines the timespam between frames
  104389. */
  104390. _step(delta: number): void;
  104391. /**
  104392. * Gets the current plugin used to run the simulation
  104393. * @returns current plugin
  104394. */
  104395. getPhysicsPlugin(): IPhysicsEnginePlugin;
  104396. /**
  104397. * Gets the list of physic impostors
  104398. * @returns an array of PhysicsImpostor
  104399. */
  104400. getImpostors(): Array<PhysicsImpostor>;
  104401. /**
  104402. * Gets the impostor for a physics enabled object
  104403. * @param object defines the object impersonated by the impostor
  104404. * @returns the PhysicsImpostor or null if not found
  104405. */
  104406. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  104407. /**
  104408. * Gets the impostor for a physics body object
  104409. * @param body defines physics body used by the impostor
  104410. * @returns the PhysicsImpostor or null if not found
  104411. */
  104412. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  104413. }
  104414. }
  104415. declare module BABYLON {
  104416. /** @hidden */
  104417. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  104418. private _useDeltaForWorldStep;
  104419. world: any;
  104420. name: string;
  104421. private _physicsMaterials;
  104422. private _fixedTimeStep;
  104423. BJSCANNON: any;
  104424. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  104425. setGravity(gravity: Vector3): void;
  104426. setTimeStep(timeStep: number): void;
  104427. getTimeStep(): number;
  104428. executeStep(delta: number): void;
  104429. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  104430. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  104431. generatePhysicsBody(impostor: PhysicsImpostor): void;
  104432. private _processChildMeshes;
  104433. removePhysicsBody(impostor: PhysicsImpostor): void;
  104434. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  104435. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  104436. private _addMaterial;
  104437. private _checkWithEpsilon;
  104438. private _createShape;
  104439. private _createHeightmap;
  104440. private _minus90X;
  104441. private _plus90X;
  104442. private _tmpPosition;
  104443. private _tmpDeltaPosition;
  104444. private _tmpUnityRotation;
  104445. private _updatePhysicsBodyTransformation;
  104446. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  104447. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  104448. isSupported(): boolean;
  104449. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  104450. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  104451. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  104452. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  104453. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  104454. getBodyMass(impostor: PhysicsImpostor): number;
  104455. getBodyFriction(impostor: PhysicsImpostor): number;
  104456. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  104457. getBodyRestitution(impostor: PhysicsImpostor): number;
  104458. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  104459. sleepBody(impostor: PhysicsImpostor): void;
  104460. wakeUpBody(impostor: PhysicsImpostor): void;
  104461. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  104462. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  104463. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  104464. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  104465. getRadius(impostor: PhysicsImpostor): number;
  104466. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  104467. dispose(): void;
  104468. private _extendNamespace;
  104469. }
  104470. }
  104471. declare module BABYLON {
  104472. /** @hidden */
  104473. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  104474. world: any;
  104475. name: string;
  104476. BJSOIMO: any;
  104477. constructor(iterations?: number, oimoInjection?: any);
  104478. setGravity(gravity: Vector3): void;
  104479. setTimeStep(timeStep: number): void;
  104480. getTimeStep(): number;
  104481. private _tmpImpostorsArray;
  104482. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  104483. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  104484. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  104485. generatePhysicsBody(impostor: PhysicsImpostor): void;
  104486. private _tmpPositionVector;
  104487. removePhysicsBody(impostor: PhysicsImpostor): void;
  104488. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  104489. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  104490. isSupported(): boolean;
  104491. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  104492. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  104493. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  104494. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  104495. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  104496. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  104497. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  104498. getBodyMass(impostor: PhysicsImpostor): number;
  104499. getBodyFriction(impostor: PhysicsImpostor): number;
  104500. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  104501. getBodyRestitution(impostor: PhysicsImpostor): number;
  104502. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  104503. sleepBody(impostor: PhysicsImpostor): void;
  104504. wakeUpBody(impostor: PhysicsImpostor): void;
  104505. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  104506. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  104507. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  104508. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  104509. getRadius(impostor: PhysicsImpostor): number;
  104510. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  104511. dispose(): void;
  104512. }
  104513. }
  104514. declare module BABYLON {
  104515. interface AbstractScene {
  104516. /**
  104517. * The list of reflection probes added to the scene
  104518. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  104519. */
  104520. reflectionProbes: Array<ReflectionProbe>;
  104521. /**
  104522. * Removes the given reflection probe from this scene.
  104523. * @param toRemove The reflection probe to remove
  104524. * @returns The index of the removed reflection probe
  104525. */
  104526. removeReflectionProbe(toRemove: ReflectionProbe): number;
  104527. /**
  104528. * Adds the given reflection probe to this scene.
  104529. * @param newReflectionProbe The reflection probe to add
  104530. */
  104531. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  104532. }
  104533. /**
  104534. * Class used to generate realtime reflection / refraction cube textures
  104535. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  104536. */
  104537. export class ReflectionProbe {
  104538. /** defines the name of the probe */
  104539. name: string;
  104540. private _scene;
  104541. private _renderTargetTexture;
  104542. private _projectionMatrix;
  104543. private _viewMatrix;
  104544. private _target;
  104545. private _add;
  104546. private _attachedMesh;
  104547. private _invertYAxis;
  104548. /** Gets or sets probe position (center of the cube map) */
  104549. position: Vector3;
  104550. /**
  104551. * Creates a new reflection probe
  104552. * @param name defines the name of the probe
  104553. * @param size defines the texture resolution (for each face)
  104554. * @param scene defines the hosting scene
  104555. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  104556. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  104557. */
  104558. constructor(
  104559. /** defines the name of the probe */
  104560. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  104561. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  104562. samples: number;
  104563. /** Gets or sets the refresh rate to use (on every frame by default) */
  104564. refreshRate: number;
  104565. /**
  104566. * Gets the hosting scene
  104567. * @returns a Scene
  104568. */
  104569. getScene(): Scene;
  104570. /** Gets the internal CubeTexture used to render to */
  104571. readonly cubeTexture: RenderTargetTexture;
  104572. /** Gets the list of meshes to render */
  104573. readonly renderList: Nullable<AbstractMesh[]>;
  104574. /**
  104575. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  104576. * @param mesh defines the mesh to attach to
  104577. */
  104578. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  104579. /**
  104580. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  104581. * @param renderingGroupId The rendering group id corresponding to its index
  104582. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  104583. */
  104584. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  104585. /**
  104586. * Clean all associated resources
  104587. */
  104588. dispose(): void;
  104589. /**
  104590. * Converts the reflection probe information to a readable string for debug purpose.
  104591. * @param fullDetails Supports for multiple levels of logging within scene loading
  104592. * @returns the human readable reflection probe info
  104593. */
  104594. toString(fullDetails?: boolean): string;
  104595. /**
  104596. * Get the class name of the relfection probe.
  104597. * @returns "ReflectionProbe"
  104598. */
  104599. getClassName(): string;
  104600. /**
  104601. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  104602. * @returns The JSON representation of the texture
  104603. */
  104604. serialize(): any;
  104605. /**
  104606. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  104607. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  104608. * @param scene Define the scene the parsed reflection probe should be instantiated in
  104609. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  104610. * @returns The parsed reflection probe if successful
  104611. */
  104612. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  104613. }
  104614. }
  104615. declare module BABYLON {
  104616. /** @hidden */
  104617. export var _BabylonLoaderRegistered: boolean;
  104618. }
  104619. declare module BABYLON {
  104620. /**
  104621. * The Physically based simple base material of BJS.
  104622. *
  104623. * This enables better naming and convention enforcements on top of the pbrMaterial.
  104624. * It is used as the base class for both the specGloss and metalRough conventions.
  104625. */
  104626. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  104627. /**
  104628. * Number of Simultaneous lights allowed on the material.
  104629. */
  104630. maxSimultaneousLights: number;
  104631. /**
  104632. * If sets to true, disables all the lights affecting the material.
  104633. */
  104634. disableLighting: boolean;
  104635. /**
  104636. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  104637. */
  104638. environmentTexture: BaseTexture;
  104639. /**
  104640. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  104641. */
  104642. invertNormalMapX: boolean;
  104643. /**
  104644. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  104645. */
  104646. invertNormalMapY: boolean;
  104647. /**
  104648. * Normal map used in the model.
  104649. */
  104650. normalTexture: BaseTexture;
  104651. /**
  104652. * Emissivie color used to self-illuminate the model.
  104653. */
  104654. emissiveColor: Color3;
  104655. /**
  104656. * Emissivie texture used to self-illuminate the model.
  104657. */
  104658. emissiveTexture: BaseTexture;
  104659. /**
  104660. * Occlusion Channel Strenght.
  104661. */
  104662. occlusionStrength: number;
  104663. /**
  104664. * Occlusion Texture of the material (adding extra occlusion effects).
  104665. */
  104666. occlusionTexture: BaseTexture;
  104667. /**
  104668. * Defines the alpha limits in alpha test mode.
  104669. */
  104670. alphaCutOff: number;
  104671. /**
  104672. * Gets the current double sided mode.
  104673. */
  104674. /**
  104675. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  104676. */
  104677. doubleSided: boolean;
  104678. /**
  104679. * Stores the pre-calculated light information of a mesh in a texture.
  104680. */
  104681. lightmapTexture: BaseTexture;
  104682. /**
  104683. * If true, the light map contains occlusion information instead of lighting info.
  104684. */
  104685. useLightmapAsShadowmap: boolean;
  104686. /**
  104687. * Instantiates a new PBRMaterial instance.
  104688. *
  104689. * @param name The material name
  104690. * @param scene The scene the material will be use in.
  104691. */
  104692. constructor(name: string, scene: Scene);
  104693. getClassName(): string;
  104694. }
  104695. }
  104696. declare module BABYLON {
  104697. /**
  104698. * The PBR material of BJS following the metal roughness convention.
  104699. *
  104700. * This fits to the PBR convention in the GLTF definition:
  104701. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  104702. */
  104703. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  104704. /**
  104705. * The base color has two different interpretations depending on the value of metalness.
  104706. * When the material is a metal, the base color is the specific measured reflectance value
  104707. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  104708. * of the material.
  104709. */
  104710. baseColor: Color3;
  104711. /**
  104712. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  104713. * well as opacity information in the alpha channel.
  104714. */
  104715. baseTexture: BaseTexture;
  104716. /**
  104717. * Specifies the metallic scalar value of the material.
  104718. * Can also be used to scale the metalness values of the metallic texture.
  104719. */
  104720. metallic: number;
  104721. /**
  104722. * Specifies the roughness scalar value of the material.
  104723. * Can also be used to scale the roughness values of the metallic texture.
  104724. */
  104725. roughness: number;
  104726. /**
  104727. * Texture containing both the metallic value in the B channel and the
  104728. * roughness value in the G channel to keep better precision.
  104729. */
  104730. metallicRoughnessTexture: BaseTexture;
  104731. /**
  104732. * Instantiates a new PBRMetalRoughnessMaterial instance.
  104733. *
  104734. * @param name The material name
  104735. * @param scene The scene the material will be use in.
  104736. */
  104737. constructor(name: string, scene: Scene);
  104738. /**
  104739. * Return the currrent class name of the material.
  104740. */
  104741. getClassName(): string;
  104742. /**
  104743. * Makes a duplicate of the current material.
  104744. * @param name - name to use for the new material.
  104745. */
  104746. clone(name: string): PBRMetallicRoughnessMaterial;
  104747. /**
  104748. * Serialize the material to a parsable JSON object.
  104749. */
  104750. serialize(): any;
  104751. /**
  104752. * Parses a JSON object correponding to the serialize function.
  104753. */
  104754. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  104755. }
  104756. }
  104757. declare module BABYLON {
  104758. /**
  104759. * The PBR material of BJS following the specular glossiness convention.
  104760. *
  104761. * This fits to the PBR convention in the GLTF definition:
  104762. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  104763. */
  104764. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  104765. /**
  104766. * Specifies the diffuse color of the material.
  104767. */
  104768. diffuseColor: Color3;
  104769. /**
  104770. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  104771. * channel.
  104772. */
  104773. diffuseTexture: BaseTexture;
  104774. /**
  104775. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  104776. */
  104777. specularColor: Color3;
  104778. /**
  104779. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  104780. */
  104781. glossiness: number;
  104782. /**
  104783. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  104784. */
  104785. specularGlossinessTexture: BaseTexture;
  104786. /**
  104787. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  104788. *
  104789. * @param name The material name
  104790. * @param scene The scene the material will be use in.
  104791. */
  104792. constructor(name: string, scene: Scene);
  104793. /**
  104794. * Return the currrent class name of the material.
  104795. */
  104796. getClassName(): string;
  104797. /**
  104798. * Makes a duplicate of the current material.
  104799. * @param name - name to use for the new material.
  104800. */
  104801. clone(name: string): PBRSpecularGlossinessMaterial;
  104802. /**
  104803. * Serialize the material to a parsable JSON object.
  104804. */
  104805. serialize(): any;
  104806. /**
  104807. * Parses a JSON object correponding to the serialize function.
  104808. */
  104809. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  104810. }
  104811. }
  104812. declare module BABYLON {
  104813. /**
  104814. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  104815. * It can help converting any input color in a desired output one. This can then be used to create effects
  104816. * from sepia, black and white to sixties or futuristic rendering...
  104817. *
  104818. * The only supported format is currently 3dl.
  104819. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  104820. */
  104821. export class ColorGradingTexture extends BaseTexture {
  104822. /**
  104823. * The current texture matrix. (will always be identity in color grading texture)
  104824. */
  104825. private _textureMatrix;
  104826. /**
  104827. * The texture URL.
  104828. */
  104829. url: string;
  104830. /**
  104831. * Empty line regex stored for GC.
  104832. */
  104833. private static _noneEmptyLineRegex;
  104834. private _engine;
  104835. /**
  104836. * Instantiates a ColorGradingTexture from the following parameters.
  104837. *
  104838. * @param url The location of the color gradind data (currently only supporting 3dl)
  104839. * @param scene The scene the texture will be used in
  104840. */
  104841. constructor(url: string, scene: Scene);
  104842. /**
  104843. * Returns the texture matrix used in most of the material.
  104844. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  104845. */
  104846. getTextureMatrix(): Matrix;
  104847. /**
  104848. * Occurs when the file being loaded is a .3dl LUT file.
  104849. */
  104850. private load3dlTexture;
  104851. /**
  104852. * Starts the loading process of the texture.
  104853. */
  104854. private loadTexture;
  104855. /**
  104856. * Clones the color gradind texture.
  104857. */
  104858. clone(): ColorGradingTexture;
  104859. /**
  104860. * Called during delayed load for textures.
  104861. */
  104862. delayLoad(): void;
  104863. /**
  104864. * Parses a color grading texture serialized by Babylon.
  104865. * @param parsedTexture The texture information being parsedTexture
  104866. * @param scene The scene to load the texture in
  104867. * @param rootUrl The root url of the data assets to load
  104868. * @return A color gradind texture
  104869. */
  104870. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  104871. /**
  104872. * Serializes the LUT texture to json format.
  104873. */
  104874. serialize(): any;
  104875. }
  104876. }
  104877. declare module BABYLON {
  104878. /**
  104879. * Based on jsTGALoader - Javascript loader for TGA file
  104880. * By Vincent Thibault
  104881. * @see http://blog.robrowser.com/javascript-tga-loader.html
  104882. */
  104883. export class TGATools {
  104884. private static _TYPE_INDEXED;
  104885. private static _TYPE_RGB;
  104886. private static _TYPE_GREY;
  104887. private static _TYPE_RLE_INDEXED;
  104888. private static _TYPE_RLE_RGB;
  104889. private static _TYPE_RLE_GREY;
  104890. private static _ORIGIN_MASK;
  104891. private static _ORIGIN_SHIFT;
  104892. private static _ORIGIN_BL;
  104893. private static _ORIGIN_BR;
  104894. private static _ORIGIN_UL;
  104895. private static _ORIGIN_UR;
  104896. /**
  104897. * Gets the header of a TGA file
  104898. * @param data defines the TGA data
  104899. * @returns the header
  104900. */
  104901. static GetTGAHeader(data: Uint8Array): any;
  104902. /**
  104903. * Uploads TGA content to a Babylon Texture
  104904. * @hidden
  104905. */
  104906. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  104907. /** @hidden */
  104908. 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;
  104909. /** @hidden */
  104910. 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;
  104911. /** @hidden */
  104912. 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;
  104913. /** @hidden */
  104914. 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;
  104915. /** @hidden */
  104916. 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;
  104917. /** @hidden */
  104918. 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;
  104919. }
  104920. }
  104921. declare module BABYLON {
  104922. /**
  104923. * Implementation of the TGA Texture Loader.
  104924. * @hidden
  104925. */
  104926. export class _TGATextureLoader implements IInternalTextureLoader {
  104927. /**
  104928. * Defines wether the loader supports cascade loading the different faces.
  104929. */
  104930. readonly supportCascades: boolean;
  104931. /**
  104932. * This returns if the loader support the current file information.
  104933. * @param extension defines the file extension of the file being loaded
  104934. * @param textureFormatInUse defines the current compressed format in use iun the engine
  104935. * @param fallback defines the fallback internal texture if any
  104936. * @param isBase64 defines whether the texture is encoded as a base64
  104937. * @param isBuffer defines whether the texture data are stored as a buffer
  104938. * @returns true if the loader can load the specified file
  104939. */
  104940. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  104941. /**
  104942. * Transform the url before loading if required.
  104943. * @param rootUrl the url of the texture
  104944. * @param textureFormatInUse defines the current compressed format in use iun the engine
  104945. * @returns the transformed texture
  104946. */
  104947. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  104948. /**
  104949. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  104950. * @param rootUrl the url of the texture
  104951. * @param textureFormatInUse defines the current compressed format in use iun the engine
  104952. * @returns the fallback texture
  104953. */
  104954. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  104955. /**
  104956. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  104957. * @param data contains the texture data
  104958. * @param texture defines the BabylonJS internal texture
  104959. * @param createPolynomials will be true if polynomials have been requested
  104960. * @param onLoad defines the callback to trigger once the texture is ready
  104961. * @param onError defines the callback to trigger in case of error
  104962. */
  104963. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  104964. /**
  104965. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  104966. * @param data contains the texture data
  104967. * @param texture defines the BabylonJS internal texture
  104968. * @param callback defines the method to call once ready to upload
  104969. */
  104970. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  104971. }
  104972. }
  104973. declare module BABYLON {
  104974. /**
  104975. * 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.
  104976. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  104977. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  104978. */
  104979. export class CustomProceduralTexture extends ProceduralTexture {
  104980. private _animate;
  104981. private _time;
  104982. private _config;
  104983. private _texturePath;
  104984. /**
  104985. * Instantiates a new Custom Procedural Texture.
  104986. * 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.
  104987. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  104988. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  104989. * @param name Define the name of the texture
  104990. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  104991. * @param size Define the size of the texture to create
  104992. * @param scene Define the scene the texture belongs to
  104993. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  104994. * @param generateMipMaps Define if the texture should creates mip maps or not
  104995. */
  104996. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  104997. private _loadJson;
  104998. /**
  104999. * Is the texture ready to be used ? (rendered at least once)
  105000. * @returns true if ready, otherwise, false.
  105001. */
  105002. isReady(): boolean;
  105003. /**
  105004. * Render the texture to its associated render target.
  105005. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  105006. */
  105007. render(useCameraPostProcess?: boolean): void;
  105008. /**
  105009. * Update the list of dependant textures samplers in the shader.
  105010. */
  105011. updateTextures(): void;
  105012. /**
  105013. * Update the uniform values of the procedural texture in the shader.
  105014. */
  105015. updateShaderUniforms(): void;
  105016. /**
  105017. * Define if the texture animates or not.
  105018. */
  105019. animate: boolean;
  105020. }
  105021. }
  105022. declare module BABYLON {
  105023. /** @hidden */
  105024. export var noisePixelShader: {
  105025. name: string;
  105026. shader: string;
  105027. };
  105028. }
  105029. declare module BABYLON {
  105030. /**
  105031. * Class used to generate noise procedural textures
  105032. */
  105033. export class NoiseProceduralTexture extends ProceduralTexture {
  105034. private _time;
  105035. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  105036. brightness: number;
  105037. /** Defines the number of octaves to process */
  105038. octaves: number;
  105039. /** Defines the level of persistence (0.8 by default) */
  105040. persistence: number;
  105041. /** Gets or sets animation speed factor (default is 1) */
  105042. animationSpeedFactor: number;
  105043. /**
  105044. * Creates a new NoiseProceduralTexture
  105045. * @param name defines the name fo the texture
  105046. * @param size defines the size of the texture (default is 256)
  105047. * @param scene defines the hosting scene
  105048. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  105049. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  105050. */
  105051. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  105052. private _updateShaderUniforms;
  105053. protected _getDefines(): string;
  105054. /** Generate the current state of the procedural texture */
  105055. render(useCameraPostProcess?: boolean): void;
  105056. /**
  105057. * Serializes this noise procedural texture
  105058. * @returns a serialized noise procedural texture object
  105059. */
  105060. serialize(): any;
  105061. /**
  105062. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  105063. * @param parsedTexture defines parsed texture data
  105064. * @param scene defines the current scene
  105065. * @param rootUrl defines the root URL containing noise procedural texture information
  105066. * @returns a parsed NoiseProceduralTexture
  105067. */
  105068. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  105069. }
  105070. }
  105071. declare module BABYLON {
  105072. /**
  105073. * Raw cube texture where the raw buffers are passed in
  105074. */
  105075. export class RawCubeTexture extends CubeTexture {
  105076. /**
  105077. * Creates a cube texture where the raw buffers are passed in.
  105078. * @param scene defines the scene the texture is attached to
  105079. * @param data defines the array of data to use to create each face
  105080. * @param size defines the size of the textures
  105081. * @param format defines the format of the data
  105082. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  105083. * @param generateMipMaps defines if the engine should generate the mip levels
  105084. * @param invertY defines if data must be stored with Y axis inverted
  105085. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  105086. * @param compression defines the compression used (null by default)
  105087. */
  105088. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  105089. /**
  105090. * Updates the raw cube texture.
  105091. * @param data defines the data to store
  105092. * @param format defines the data format
  105093. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  105094. * @param invertY defines if data must be stored with Y axis inverted
  105095. * @param compression defines the compression used (null by default)
  105096. * @param level defines which level of the texture to update
  105097. */
  105098. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  105099. /**
  105100. * Updates a raw cube texture with RGBD encoded data.
  105101. * @param data defines the array of data [mipmap][face] to use to create each face
  105102. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  105103. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  105104. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  105105. * @returns a promsie that resolves when the operation is complete
  105106. */
  105107. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  105108. /**
  105109. * Clones the raw cube texture.
  105110. * @return a new cube texture
  105111. */
  105112. clone(): CubeTexture;
  105113. /** @hidden */
  105114. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  105115. }
  105116. }
  105117. declare module BABYLON {
  105118. /**
  105119. * Class used to store 3D textures containing user data
  105120. */
  105121. export class RawTexture3D extends Texture {
  105122. /** Gets or sets the texture format to use */
  105123. format: number;
  105124. private _engine;
  105125. /**
  105126. * Create a new RawTexture3D
  105127. * @param data defines the data of the texture
  105128. * @param width defines the width of the texture
  105129. * @param height defines the height of the texture
  105130. * @param depth defines the depth of the texture
  105131. * @param format defines the texture format to use
  105132. * @param scene defines the hosting scene
  105133. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  105134. * @param invertY defines if texture must be stored with Y axis inverted
  105135. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  105136. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  105137. */
  105138. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  105139. /** Gets or sets the texture format to use */
  105140. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  105141. /**
  105142. * Update the texture with new data
  105143. * @param data defines the data to store in the texture
  105144. */
  105145. update(data: ArrayBufferView): void;
  105146. }
  105147. }
  105148. declare module BABYLON {
  105149. /**
  105150. * Creates a refraction texture used by refraction channel of the standard material.
  105151. * It is like a mirror but to see through a material.
  105152. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  105153. */
  105154. export class RefractionTexture extends RenderTargetTexture {
  105155. /**
  105156. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  105157. * 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.
  105158. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  105159. */
  105160. refractionPlane: Plane;
  105161. /**
  105162. * Define how deep under the surface we should see.
  105163. */
  105164. depth: number;
  105165. /**
  105166. * Creates a refraction texture used by refraction channel of the standard material.
  105167. * It is like a mirror but to see through a material.
  105168. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  105169. * @param name Define the texture name
  105170. * @param size Define the size of the underlying texture
  105171. * @param scene Define the scene the refraction belongs to
  105172. * @param generateMipMaps Define if we need to generate mips level for the refraction
  105173. */
  105174. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  105175. /**
  105176. * Clone the refraction texture.
  105177. * @returns the cloned texture
  105178. */
  105179. clone(): RefractionTexture;
  105180. /**
  105181. * Serialize the texture to a JSON representation you could use in Parse later on
  105182. * @returns the serialized JSON representation
  105183. */
  105184. serialize(): any;
  105185. }
  105186. }
  105187. declare module BABYLON {
  105188. /**
  105189. * Configuration for Draco compression
  105190. */
  105191. export interface IDracoCompressionConfiguration {
  105192. /**
  105193. * Configuration for the decoder.
  105194. */
  105195. decoder?: {
  105196. /**
  105197. * The url to the WebAssembly module.
  105198. */
  105199. wasmUrl?: string;
  105200. /**
  105201. * The url to the WebAssembly binary.
  105202. */
  105203. wasmBinaryUrl?: string;
  105204. /**
  105205. * The url to the fallback JavaScript module.
  105206. */
  105207. fallbackUrl?: string;
  105208. };
  105209. }
  105210. /**
  105211. * Draco compression (https://google.github.io/draco/)
  105212. *
  105213. * This class wraps the Draco module.
  105214. *
  105215. * **Encoder**
  105216. *
  105217. * The encoder is not currently implemented.
  105218. *
  105219. * **Decoder**
  105220. *
  105221. * 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.
  105222. *
  105223. * To update the configuration, use the following code:
  105224. * ```javascript
  105225. * DracoCompression.Configuration = {
  105226. * decoder: {
  105227. * wasmUrl: "<url to the WebAssembly library>",
  105228. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  105229. * fallbackUrl: "<url to the fallback JavaScript library>",
  105230. * }
  105231. * };
  105232. * ```
  105233. *
  105234. * 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.
  105235. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  105236. * Use `DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  105237. *
  105238. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  105239. * ```javascript
  105240. * var dracoCompression = new DracoCompression();
  105241. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  105242. * [VertexBuffer.PositionKind]: 0
  105243. * });
  105244. * ```
  105245. *
  105246. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  105247. */
  105248. export class DracoCompression implements IDisposable {
  105249. private static _DecoderModulePromise;
  105250. /**
  105251. * The configuration. Defaults to the following urls:
  105252. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  105253. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  105254. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  105255. */
  105256. static Configuration: IDracoCompressionConfiguration;
  105257. /**
  105258. * Returns true if the decoder is available.
  105259. */
  105260. static readonly DecoderAvailable: boolean;
  105261. /**
  105262. * Constructor
  105263. */
  105264. constructor();
  105265. /**
  105266. * Stop all async operations and release resources.
  105267. */
  105268. dispose(): void;
  105269. /**
  105270. * Decode Draco compressed mesh data to vertex data.
  105271. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  105272. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  105273. * @returns A promise that resolves with the decoded vertex data
  105274. */
  105275. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes: {
  105276. [kind: string]: number;
  105277. }): Promise<VertexData>;
  105278. private static _GetDecoderModule;
  105279. private static _LoadScriptAsync;
  105280. private static _LoadFileAsync;
  105281. }
  105282. }
  105283. declare module BABYLON {
  105284. /**
  105285. * Class for building Constructive Solid Geometry
  105286. */
  105287. export class CSG {
  105288. private polygons;
  105289. /**
  105290. * The world matrix
  105291. */
  105292. matrix: Matrix;
  105293. /**
  105294. * Stores the position
  105295. */
  105296. position: Vector3;
  105297. /**
  105298. * Stores the rotation
  105299. */
  105300. rotation: Vector3;
  105301. /**
  105302. * Stores the rotation quaternion
  105303. */
  105304. rotationQuaternion: Nullable<Quaternion>;
  105305. /**
  105306. * Stores the scaling vector
  105307. */
  105308. scaling: Vector3;
  105309. /**
  105310. * Convert the Mesh to CSG
  105311. * @param mesh The Mesh to convert to CSG
  105312. * @returns A new CSG from the Mesh
  105313. */
  105314. static FromMesh(mesh: Mesh): CSG;
  105315. /**
  105316. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  105317. * @param polygons Polygons used to construct a CSG solid
  105318. */
  105319. private static FromPolygons;
  105320. /**
  105321. * Clones, or makes a deep copy, of the CSG
  105322. * @returns A new CSG
  105323. */
  105324. clone(): CSG;
  105325. /**
  105326. * Unions this CSG with another CSG
  105327. * @param csg The CSG to union against this CSG
  105328. * @returns The unioned CSG
  105329. */
  105330. union(csg: CSG): CSG;
  105331. /**
  105332. * Unions this CSG with another CSG in place
  105333. * @param csg The CSG to union against this CSG
  105334. */
  105335. unionInPlace(csg: CSG): void;
  105336. /**
  105337. * Subtracts this CSG with another CSG
  105338. * @param csg The CSG to subtract against this CSG
  105339. * @returns A new CSG
  105340. */
  105341. subtract(csg: CSG): CSG;
  105342. /**
  105343. * Subtracts this CSG with another CSG in place
  105344. * @param csg The CSG to subtact against this CSG
  105345. */
  105346. subtractInPlace(csg: CSG): void;
  105347. /**
  105348. * Intersect this CSG with another CSG
  105349. * @param csg The CSG to intersect against this CSG
  105350. * @returns A new CSG
  105351. */
  105352. intersect(csg: CSG): CSG;
  105353. /**
  105354. * Intersects this CSG with another CSG in place
  105355. * @param csg The CSG to intersect against this CSG
  105356. */
  105357. intersectInPlace(csg: CSG): void;
  105358. /**
  105359. * Return a new CSG solid with solid and empty space switched. This solid is
  105360. * not modified.
  105361. * @returns A new CSG solid with solid and empty space switched
  105362. */
  105363. inverse(): CSG;
  105364. /**
  105365. * Inverses the CSG in place
  105366. */
  105367. inverseInPlace(): void;
  105368. /**
  105369. * This is used to keep meshes transformations so they can be restored
  105370. * when we build back a Babylon Mesh
  105371. * NB : All CSG operations are performed in world coordinates
  105372. * @param csg The CSG to copy the transform attributes from
  105373. * @returns This CSG
  105374. */
  105375. copyTransformAttributes(csg: CSG): CSG;
  105376. /**
  105377. * Build Raw mesh from CSG
  105378. * Coordinates here are in world space
  105379. * @param name The name of the mesh geometry
  105380. * @param scene The Scene
  105381. * @param keepSubMeshes Specifies if the submeshes should be kept
  105382. * @returns A new Mesh
  105383. */
  105384. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  105385. /**
  105386. * Build Mesh from CSG taking material and transforms into account
  105387. * @param name The name of the Mesh
  105388. * @param material The material of the Mesh
  105389. * @param scene The Scene
  105390. * @param keepSubMeshes Specifies if submeshes should be kept
  105391. * @returns The new Mesh
  105392. */
  105393. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  105394. }
  105395. }
  105396. declare module BABYLON {
  105397. /**
  105398. * Class used to create a trail following a mesh
  105399. */
  105400. export class TrailMesh extends Mesh {
  105401. private _generator;
  105402. private _autoStart;
  105403. private _running;
  105404. private _diameter;
  105405. private _length;
  105406. private _sectionPolygonPointsCount;
  105407. private _sectionVectors;
  105408. private _sectionNormalVectors;
  105409. private _beforeRenderObserver;
  105410. /**
  105411. * @constructor
  105412. * @param name The value used by scene.getMeshByName() to do a lookup.
  105413. * @param generator The mesh to generate a trail.
  105414. * @param scene The scene to add this mesh to.
  105415. * @param diameter Diameter of trailing mesh. Default is 1.
  105416. * @param length Length of trailing mesh. Default is 60.
  105417. * @param autoStart Automatically start trailing mesh. Default true.
  105418. */
  105419. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  105420. /**
  105421. * "TrailMesh"
  105422. * @returns "TrailMesh"
  105423. */
  105424. getClassName(): string;
  105425. private _createMesh;
  105426. /**
  105427. * Start trailing mesh.
  105428. */
  105429. start(): void;
  105430. /**
  105431. * Stop trailing mesh.
  105432. */
  105433. stop(): void;
  105434. /**
  105435. * Update trailing mesh geometry.
  105436. */
  105437. update(): void;
  105438. /**
  105439. * Returns a new TrailMesh object.
  105440. * @param name is a string, the name given to the new mesh
  105441. * @param newGenerator use new generator object for cloned trail mesh
  105442. * @returns a new mesh
  105443. */
  105444. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  105445. /**
  105446. * Serializes this trail mesh
  105447. * @param serializationObject object to write serialization to
  105448. */
  105449. serialize(serializationObject: any): void;
  105450. /**
  105451. * Parses a serialized trail mesh
  105452. * @param parsedMesh the serialized mesh
  105453. * @param scene the scene to create the trail mesh in
  105454. * @returns the created trail mesh
  105455. */
  105456. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  105457. }
  105458. }
  105459. declare module BABYLON {
  105460. /**
  105461. * Class containing static functions to help procedurally build meshes
  105462. */
  105463. export class RibbonBuilder {
  105464. /**
  105465. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  105466. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  105467. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  105468. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  105469. * * 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
  105470. * * 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
  105471. * * 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
  105472. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105473. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  105474. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  105475. * * 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
  105476. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  105477. * * 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
  105478. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  105479. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105480. * @param name defines the name of the mesh
  105481. * @param options defines the options used to create the mesh
  105482. * @param scene defines the hosting scene
  105483. * @returns the ribbon mesh
  105484. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  105485. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  105486. */
  105487. static CreateRibbon(name: string, options: {
  105488. pathArray: Vector3[][];
  105489. closeArray?: boolean;
  105490. closePath?: boolean;
  105491. offset?: number;
  105492. updatable?: boolean;
  105493. sideOrientation?: number;
  105494. frontUVs?: Vector4;
  105495. backUVs?: Vector4;
  105496. instance?: Mesh;
  105497. invertUV?: boolean;
  105498. uvs?: Vector2[];
  105499. colors?: Color4[];
  105500. }, scene?: Nullable<Scene>): Mesh;
  105501. }
  105502. }
  105503. declare module BABYLON {
  105504. /**
  105505. * Class containing static functions to help procedurally build meshes
  105506. */
  105507. export class TorusKnotBuilder {
  105508. /**
  105509. * Creates a torus knot mesh
  105510. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  105511. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  105512. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  105513. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  105514. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105515. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  105516. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  105517. * @param name defines the name of the mesh
  105518. * @param options defines the options used to create the mesh
  105519. * @param scene defines the hosting scene
  105520. * @returns the torus knot mesh
  105521. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  105522. */
  105523. static CreateTorusKnot(name: string, options: {
  105524. radius?: number;
  105525. tube?: number;
  105526. radialSegments?: number;
  105527. tubularSegments?: number;
  105528. p?: number;
  105529. q?: number;
  105530. updatable?: boolean;
  105531. sideOrientation?: number;
  105532. frontUVs?: Vector4;
  105533. backUVs?: Vector4;
  105534. }, scene: any): Mesh;
  105535. }
  105536. }
  105537. declare module BABYLON {
  105538. /**
  105539. * Polygon
  105540. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  105541. */
  105542. export class Polygon {
  105543. /**
  105544. * Creates a rectangle
  105545. * @param xmin bottom X coord
  105546. * @param ymin bottom Y coord
  105547. * @param xmax top X coord
  105548. * @param ymax top Y coord
  105549. * @returns points that make the resulting rectation
  105550. */
  105551. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  105552. /**
  105553. * Creates a circle
  105554. * @param radius radius of circle
  105555. * @param cx scale in x
  105556. * @param cy scale in y
  105557. * @param numberOfSides number of sides that make up the circle
  105558. * @returns points that make the resulting circle
  105559. */
  105560. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  105561. /**
  105562. * Creates a polygon from input string
  105563. * @param input Input polygon data
  105564. * @returns the parsed points
  105565. */
  105566. static Parse(input: string): Vector2[];
  105567. /**
  105568. * Starts building a polygon from x and y coordinates
  105569. * @param x x coordinate
  105570. * @param y y coordinate
  105571. * @returns the started path2
  105572. */
  105573. static StartingAt(x: number, y: number): Path2;
  105574. }
  105575. /**
  105576. * Builds a polygon
  105577. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  105578. */
  105579. export class PolygonMeshBuilder {
  105580. private _points;
  105581. private _outlinepoints;
  105582. private _holes;
  105583. private _name;
  105584. private _scene;
  105585. private _epoints;
  105586. private _eholes;
  105587. private _addToepoint;
  105588. /**
  105589. * Babylon reference to the earcut plugin.
  105590. */
  105591. bjsEarcut: any;
  105592. /**
  105593. * Creates a PolygonMeshBuilder
  105594. * @param name name of the builder
  105595. * @param contours Path of the polygon
  105596. * @param scene scene to add to
  105597. * @param earcutInjection can be used to inject your own earcut reference
  105598. */
  105599. constructor(name: string, contours: Path2 | Vector2[] | any, scene: Scene, earcutInjection?: any);
  105600. /**
  105601. * Adds a whole within the polygon
  105602. * @param hole Array of points defining the hole
  105603. * @returns this
  105604. */
  105605. addHole(hole: Vector2[]): PolygonMeshBuilder;
  105606. /**
  105607. * Creates the polygon
  105608. * @param updatable If the mesh should be updatable
  105609. * @param depth The depth of the mesh created
  105610. * @returns the created mesh
  105611. */
  105612. build(updatable?: boolean, depth?: number): Mesh;
  105613. /**
  105614. * Adds a side to the polygon
  105615. * @param positions points that make the polygon
  105616. * @param normals normals of the polygon
  105617. * @param uvs uvs of the polygon
  105618. * @param indices indices of the polygon
  105619. * @param bounds bounds of the polygon
  105620. * @param points points of the polygon
  105621. * @param depth depth of the polygon
  105622. * @param flip flip of the polygon
  105623. */
  105624. private addSide;
  105625. }
  105626. }
  105627. declare module BABYLON {
  105628. /**
  105629. * Class containing static functions to help procedurally build meshes
  105630. */
  105631. export class PolygonBuilder {
  105632. /**
  105633. * Creates a polygon mesh
  105634. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  105635. * * 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
  105636. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  105637. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105638. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  105639. * * Remember you can only change the shape positions, not their number when updating a polygon
  105640. * @param name defines the name of the mesh
  105641. * @param options defines the options used to create the mesh
  105642. * @param scene defines the hosting scene
  105643. * @param earcutInjection can be used to inject your own earcut reference
  105644. * @returns the polygon mesh
  105645. */
  105646. static CreatePolygon(name: string, options: {
  105647. shape: Vector3[];
  105648. holes?: Vector3[][];
  105649. depth?: number;
  105650. faceUV?: Vector4[];
  105651. faceColors?: Color4[];
  105652. updatable?: boolean;
  105653. sideOrientation?: number;
  105654. frontUVs?: Vector4;
  105655. backUVs?: Vector4;
  105656. }, scene: Scene, earcutInjection?: any): Mesh;
  105657. /**
  105658. * Creates an extruded polygon mesh, with depth in the Y direction.
  105659. * * 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)
  105660. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  105661. * @param name defines the name of the mesh
  105662. * @param options defines the options used to create the mesh
  105663. * @param scene defines the hosting scene
  105664. * @param earcutInjection can be used to inject your own earcut reference
  105665. * @returns the polygon mesh
  105666. */
  105667. static ExtrudePolygon(name: string, options: {
  105668. shape: Vector3[];
  105669. holes?: Vector3[][];
  105670. depth?: number;
  105671. faceUV?: Vector4[];
  105672. faceColors?: Color4[];
  105673. updatable?: boolean;
  105674. sideOrientation?: number;
  105675. frontUVs?: Vector4;
  105676. backUVs?: Vector4;
  105677. }, scene: Scene, earcutInjection?: any): Mesh;
  105678. }
  105679. }
  105680. declare module BABYLON {
  105681. /**
  105682. * Class containing static functions to help procedurally build meshes
  105683. */
  105684. export class ShapeBuilder {
  105685. /**
  105686. * 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.
  105687. * * 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.
  105688. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  105689. * * 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.
  105690. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  105691. * * 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
  105692. * * 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
  105693. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  105694. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105695. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  105696. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  105697. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  105698. * @param name defines the name of the mesh
  105699. * @param options defines the options used to create the mesh
  105700. * @param scene defines the hosting scene
  105701. * @returns the extruded shape mesh
  105702. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  105703. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  105704. */
  105705. static ExtrudeShape(name: string, options: {
  105706. shape: Vector3[];
  105707. path: Vector3[];
  105708. scale?: number;
  105709. rotation?: number;
  105710. cap?: number;
  105711. updatable?: boolean;
  105712. sideOrientation?: number;
  105713. frontUVs?: Vector4;
  105714. backUVs?: Vector4;
  105715. instance?: Mesh;
  105716. invertUV?: boolean;
  105717. }, scene?: Nullable<Scene>): Mesh;
  105718. /**
  105719. * Creates an custom extruded shape mesh.
  105720. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  105721. * * 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.
  105722. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  105723. * * 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
  105724. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  105725. * * 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
  105726. * * It must returns a float value that will be the scale value applied to the shape on each path point
  105727. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  105728. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  105729. * * 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
  105730. * * 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
  105731. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  105732. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105733. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  105734. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  105735. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105736. * @param name defines the name of the mesh
  105737. * @param options defines the options used to create the mesh
  105738. * @param scene defines the hosting scene
  105739. * @returns the custom extruded shape mesh
  105740. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  105741. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  105742. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  105743. */
  105744. static ExtrudeShapeCustom(name: string, options: {
  105745. shape: Vector3[];
  105746. path: Vector3[];
  105747. scaleFunction?: any;
  105748. rotationFunction?: any;
  105749. ribbonCloseArray?: boolean;
  105750. ribbonClosePath?: boolean;
  105751. cap?: number;
  105752. updatable?: boolean;
  105753. sideOrientation?: number;
  105754. frontUVs?: Vector4;
  105755. backUVs?: Vector4;
  105756. instance?: Mesh;
  105757. invertUV?: boolean;
  105758. }, scene: Scene): Mesh;
  105759. private static _ExtrudeShapeGeneric;
  105760. }
  105761. }
  105762. declare module BABYLON {
  105763. /**
  105764. * Class containing static functions to help procedurally build meshes
  105765. */
  105766. export class LatheBuilder {
  105767. /**
  105768. * Creates lathe mesh.
  105769. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  105770. * * 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
  105771. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  105772. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  105773. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  105774. * * 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
  105775. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  105776. * * 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
  105777. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105778. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  105779. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  105780. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105781. * @param name defines the name of the mesh
  105782. * @param options defines the options used to create the mesh
  105783. * @param scene defines the hosting scene
  105784. * @returns the lathe mesh
  105785. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  105786. */
  105787. static CreateLathe(name: string, options: {
  105788. shape: Vector3[];
  105789. radius?: number;
  105790. tessellation?: number;
  105791. clip?: number;
  105792. arc?: number;
  105793. closed?: boolean;
  105794. updatable?: boolean;
  105795. sideOrientation?: number;
  105796. frontUVs?: Vector4;
  105797. backUVs?: Vector4;
  105798. cap?: number;
  105799. invertUV?: boolean;
  105800. }, scene: Scene): Mesh;
  105801. }
  105802. }
  105803. declare module BABYLON {
  105804. /**
  105805. * Class containing static functions to help procedurally build meshes
  105806. */
  105807. export class TubeBuilder {
  105808. /**
  105809. * Creates a tube mesh.
  105810. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  105811. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  105812. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  105813. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  105814. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  105815. * * 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)
  105816. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  105817. * * 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
  105818. * * 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
  105819. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105820. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  105821. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  105822. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105823. * @param name defines the name of the mesh
  105824. * @param options defines the options used to create the mesh
  105825. * @param scene defines the hosting scene
  105826. * @returns the tube mesh
  105827. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  105828. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  105829. */
  105830. static CreateTube(name: string, options: {
  105831. path: Vector3[];
  105832. radius?: number;
  105833. tessellation?: number;
  105834. radiusFunction?: {
  105835. (i: number, distance: number): number;
  105836. };
  105837. cap?: number;
  105838. arc?: number;
  105839. updatable?: boolean;
  105840. sideOrientation?: number;
  105841. frontUVs?: Vector4;
  105842. backUVs?: Vector4;
  105843. instance?: Mesh;
  105844. invertUV?: boolean;
  105845. }, scene: Scene): Mesh;
  105846. }
  105847. }
  105848. declare module BABYLON {
  105849. /**
  105850. * Class containing static functions to help procedurally build meshes
  105851. */
  105852. export class IcoSphereBuilder {
  105853. /**
  105854. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  105855. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  105856. * * 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`)
  105857. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  105858. * * 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
  105859. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105860. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  105861. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105862. * @param name defines the name of the mesh
  105863. * @param options defines the options used to create the mesh
  105864. * @param scene defines the hosting scene
  105865. * @returns the icosahedron mesh
  105866. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  105867. */
  105868. static CreateIcoSphere(name: string, options: {
  105869. radius?: number;
  105870. radiusX?: number;
  105871. radiusY?: number;
  105872. radiusZ?: number;
  105873. flat?: boolean;
  105874. subdivisions?: number;
  105875. sideOrientation?: number;
  105876. frontUVs?: Vector4;
  105877. backUVs?: Vector4;
  105878. updatable?: boolean;
  105879. }, scene: Scene): Mesh;
  105880. }
  105881. }
  105882. declare module BABYLON {
  105883. /**
  105884. * Class containing static functions to help procedurally build meshes
  105885. */
  105886. export class DecalBuilder {
  105887. /**
  105888. * Creates a decal mesh.
  105889. * 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
  105890. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  105891. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  105892. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  105893. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  105894. * @param name defines the name of the mesh
  105895. * @param sourceMesh defines the mesh where the decal must be applied
  105896. * @param options defines the options used to create the mesh
  105897. * @param scene defines the hosting scene
  105898. * @returns the decal mesh
  105899. * @see https://doc.babylonjs.com/how_to/decals
  105900. */
  105901. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  105902. position?: Vector3;
  105903. normal?: Vector3;
  105904. size?: Vector3;
  105905. angle?: number;
  105906. }): Mesh;
  105907. }
  105908. }
  105909. declare module BABYLON {
  105910. /**
  105911. * Class containing static functions to help procedurally build meshes
  105912. */
  105913. export class MeshBuilder {
  105914. /**
  105915. * Creates a box mesh
  105916. * * The parameter `size` sets the size (float) of each box side (default 1)
  105917. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  105918. * * 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)
  105919. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  105920. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105921. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  105922. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105923. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  105924. * @param name defines the name of the mesh
  105925. * @param options defines the options used to create the mesh
  105926. * @param scene defines the hosting scene
  105927. * @returns the box mesh
  105928. */
  105929. static CreateBox(name: string, options: {
  105930. size?: number;
  105931. width?: number;
  105932. height?: number;
  105933. depth?: number;
  105934. faceUV?: Vector4[];
  105935. faceColors?: Color4[];
  105936. sideOrientation?: number;
  105937. frontUVs?: Vector4;
  105938. backUVs?: Vector4;
  105939. updatable?: boolean;
  105940. }, scene?: Nullable<Scene>): Mesh;
  105941. /**
  105942. * Creates a sphere mesh
  105943. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  105944. * * 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`)
  105945. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  105946. * * 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
  105947. * * 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)
  105948. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105949. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  105950. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105951. * @param name defines the name of the mesh
  105952. * @param options defines the options used to create the mesh
  105953. * @param scene defines the hosting scene
  105954. * @returns the sphere mesh
  105955. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  105956. */
  105957. static CreateSphere(name: string, options: {
  105958. segments?: number;
  105959. diameter?: number;
  105960. diameterX?: number;
  105961. diameterY?: number;
  105962. diameterZ?: number;
  105963. arc?: number;
  105964. slice?: number;
  105965. sideOrientation?: number;
  105966. frontUVs?: Vector4;
  105967. backUVs?: Vector4;
  105968. updatable?: boolean;
  105969. }, scene: any): Mesh;
  105970. /**
  105971. * Creates a plane polygonal mesh. By default, this is a disc
  105972. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  105973. * * 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
  105974. * * 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
  105975. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105976. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  105977. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105978. * @param name defines the name of the mesh
  105979. * @param options defines the options used to create the mesh
  105980. * @param scene defines the hosting scene
  105981. * @returns the plane polygonal mesh
  105982. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  105983. */
  105984. static CreateDisc(name: string, options: {
  105985. radius?: number;
  105986. tessellation?: number;
  105987. arc?: number;
  105988. updatable?: boolean;
  105989. sideOrientation?: number;
  105990. frontUVs?: Vector4;
  105991. backUVs?: Vector4;
  105992. }, scene?: Nullable<Scene>): Mesh;
  105993. /**
  105994. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  105995. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  105996. * * 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`)
  105997. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  105998. * * 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
  105999. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106000. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106001. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106002. * @param name defines the name of the mesh
  106003. * @param options defines the options used to create the mesh
  106004. * @param scene defines the hosting scene
  106005. * @returns the icosahedron mesh
  106006. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  106007. */
  106008. static CreateIcoSphere(name: string, options: {
  106009. radius?: number;
  106010. radiusX?: number;
  106011. radiusY?: number;
  106012. radiusZ?: number;
  106013. flat?: boolean;
  106014. subdivisions?: number;
  106015. sideOrientation?: number;
  106016. frontUVs?: Vector4;
  106017. backUVs?: Vector4;
  106018. updatable?: boolean;
  106019. }, scene: Scene): Mesh;
  106020. /**
  106021. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  106022. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  106023. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  106024. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  106025. * * 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
  106026. * * 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
  106027. * * 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
  106028. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106029. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106030. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  106031. * * 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
  106032. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  106033. * * 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
  106034. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  106035. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106036. * @param name defines the name of the mesh
  106037. * @param options defines the options used to create the mesh
  106038. * @param scene defines the hosting scene
  106039. * @returns the ribbon mesh
  106040. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  106041. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  106042. */
  106043. static CreateRibbon(name: string, options: {
  106044. pathArray: Vector3[][];
  106045. closeArray?: boolean;
  106046. closePath?: boolean;
  106047. offset?: number;
  106048. updatable?: boolean;
  106049. sideOrientation?: number;
  106050. frontUVs?: Vector4;
  106051. backUVs?: Vector4;
  106052. instance?: Mesh;
  106053. invertUV?: boolean;
  106054. uvs?: Vector2[];
  106055. colors?: Color4[];
  106056. }, scene?: Nullable<Scene>): Mesh;
  106057. /**
  106058. * Creates a cylinder or a cone mesh
  106059. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  106060. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  106061. * * 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.
  106062. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  106063. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  106064. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  106065. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  106066. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  106067. * * 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).
  106068. * * 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
  106069. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  106070. * * 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
  106071. * * 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.
  106072. * * If `enclose` is false, a ring surface is one element.
  106073. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  106074. * * 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
  106075. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106076. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106077. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  106078. * @param name defines the name of the mesh
  106079. * @param options defines the options used to create the mesh
  106080. * @param scene defines the hosting scene
  106081. * @returns the cylinder mesh
  106082. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  106083. */
  106084. static CreateCylinder(name: string, options: {
  106085. height?: number;
  106086. diameterTop?: number;
  106087. diameterBottom?: number;
  106088. diameter?: number;
  106089. tessellation?: number;
  106090. subdivisions?: number;
  106091. arc?: number;
  106092. faceColors?: Color4[];
  106093. faceUV?: Vector4[];
  106094. updatable?: boolean;
  106095. hasRings?: boolean;
  106096. enclose?: boolean;
  106097. sideOrientation?: number;
  106098. frontUVs?: Vector4;
  106099. backUVs?: Vector4;
  106100. }, scene: any): Mesh;
  106101. /**
  106102. * Creates a torus mesh
  106103. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  106104. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  106105. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  106106. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106107. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106108. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  106109. * @param name defines the name of the mesh
  106110. * @param options defines the options used to create the mesh
  106111. * @param scene defines the hosting scene
  106112. * @returns the torus mesh
  106113. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  106114. */
  106115. static CreateTorus(name: string, options: {
  106116. diameter?: number;
  106117. thickness?: number;
  106118. tessellation?: number;
  106119. updatable?: boolean;
  106120. sideOrientation?: number;
  106121. frontUVs?: Vector4;
  106122. backUVs?: Vector4;
  106123. }, scene: any): Mesh;
  106124. /**
  106125. * Creates a torus knot mesh
  106126. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  106127. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  106128. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  106129. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  106130. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106131. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106132. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  106133. * @param name defines the name of the mesh
  106134. * @param options defines the options used to create the mesh
  106135. * @param scene defines the hosting scene
  106136. * @returns the torus knot mesh
  106137. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  106138. */
  106139. static CreateTorusKnot(name: string, options: {
  106140. radius?: number;
  106141. tube?: number;
  106142. radialSegments?: number;
  106143. tubularSegments?: number;
  106144. p?: number;
  106145. q?: number;
  106146. updatable?: boolean;
  106147. sideOrientation?: number;
  106148. frontUVs?: Vector4;
  106149. backUVs?: Vector4;
  106150. }, scene: any): Mesh;
  106151. /**
  106152. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  106153. * * 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
  106154. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  106155. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  106156. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  106157. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  106158. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  106159. * * 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
  106160. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  106161. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106162. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  106163. * @param name defines the name of the new line system
  106164. * @param options defines the options used to create the line system
  106165. * @param scene defines the hosting scene
  106166. * @returns a new line system mesh
  106167. */
  106168. static CreateLineSystem(name: string, options: {
  106169. lines: Vector3[][];
  106170. updatable?: boolean;
  106171. instance?: Nullable<LinesMesh>;
  106172. colors?: Nullable<Color4[][]>;
  106173. useVertexAlpha?: boolean;
  106174. }, scene: Nullable<Scene>): LinesMesh;
  106175. /**
  106176. * Creates a line mesh
  106177. * 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
  106178. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  106179. * * The parameter `points` is an array successive Vector3
  106180. * * 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
  106181. * * The optional parameter `colors` is an array of successive Color4, one per line point
  106182. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  106183. * * When updating an instance, remember that only point positions can change, not the number of points
  106184. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106185. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  106186. * @param name defines the name of the new line system
  106187. * @param options defines the options used to create the line system
  106188. * @param scene defines the hosting scene
  106189. * @returns a new line mesh
  106190. */
  106191. static CreateLines(name: string, options: {
  106192. points: Vector3[];
  106193. updatable?: boolean;
  106194. instance?: Nullable<LinesMesh>;
  106195. colors?: Color4[];
  106196. useVertexAlpha?: boolean;
  106197. }, scene?: Nullable<Scene>): LinesMesh;
  106198. /**
  106199. * Creates a dashed line mesh
  106200. * * 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
  106201. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  106202. * * The parameter `points` is an array successive Vector3
  106203. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  106204. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  106205. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  106206. * * 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
  106207. * * When updating an instance, remember that only point positions can change, not the number of points
  106208. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106209. * @param name defines the name of the mesh
  106210. * @param options defines the options used to create the mesh
  106211. * @param scene defines the hosting scene
  106212. * @returns the dashed line mesh
  106213. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  106214. */
  106215. static CreateDashedLines(name: string, options: {
  106216. points: Vector3[];
  106217. dashSize?: number;
  106218. gapSize?: number;
  106219. dashNb?: number;
  106220. updatable?: boolean;
  106221. instance?: LinesMesh;
  106222. }, scene?: Nullable<Scene>): LinesMesh;
  106223. /**
  106224. * 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.
  106225. * * 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.
  106226. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  106227. * * 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.
  106228. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  106229. * * 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
  106230. * * 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
  106231. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  106232. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106233. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106234. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  106235. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  106236. * @param name defines the name of the mesh
  106237. * @param options defines the options used to create the mesh
  106238. * @param scene defines the hosting scene
  106239. * @returns the extruded shape mesh
  106240. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  106241. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  106242. */
  106243. static ExtrudeShape(name: string, options: {
  106244. shape: Vector3[];
  106245. path: Vector3[];
  106246. scale?: number;
  106247. rotation?: number;
  106248. cap?: number;
  106249. updatable?: boolean;
  106250. sideOrientation?: number;
  106251. frontUVs?: Vector4;
  106252. backUVs?: Vector4;
  106253. instance?: Mesh;
  106254. invertUV?: boolean;
  106255. }, scene?: Nullable<Scene>): Mesh;
  106256. /**
  106257. * Creates an custom extruded shape mesh.
  106258. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  106259. * * 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.
  106260. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  106261. * * 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
  106262. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  106263. * * 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
  106264. * * It must returns a float value that will be the scale value applied to the shape on each path point
  106265. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  106266. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  106267. * * 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
  106268. * * 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
  106269. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  106270. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106271. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106272. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  106273. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106274. * @param name defines the name of the mesh
  106275. * @param options defines the options used to create the mesh
  106276. * @param scene defines the hosting scene
  106277. * @returns the custom extruded shape mesh
  106278. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  106279. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  106280. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  106281. */
  106282. static ExtrudeShapeCustom(name: string, options: {
  106283. shape: Vector3[];
  106284. path: Vector3[];
  106285. scaleFunction?: any;
  106286. rotationFunction?: any;
  106287. ribbonCloseArray?: boolean;
  106288. ribbonClosePath?: boolean;
  106289. cap?: number;
  106290. updatable?: boolean;
  106291. sideOrientation?: number;
  106292. frontUVs?: Vector4;
  106293. backUVs?: Vector4;
  106294. instance?: Mesh;
  106295. invertUV?: boolean;
  106296. }, scene: Scene): Mesh;
  106297. /**
  106298. * Creates lathe mesh.
  106299. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  106300. * * 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
  106301. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  106302. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  106303. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  106304. * * 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
  106305. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  106306. * * 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
  106307. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106308. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106309. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  106310. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106311. * @param name defines the name of the mesh
  106312. * @param options defines the options used to create the mesh
  106313. * @param scene defines the hosting scene
  106314. * @returns the lathe mesh
  106315. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  106316. */
  106317. static CreateLathe(name: string, options: {
  106318. shape: Vector3[];
  106319. radius?: number;
  106320. tessellation?: number;
  106321. clip?: number;
  106322. arc?: number;
  106323. closed?: boolean;
  106324. updatable?: boolean;
  106325. sideOrientation?: number;
  106326. frontUVs?: Vector4;
  106327. backUVs?: Vector4;
  106328. cap?: number;
  106329. invertUV?: boolean;
  106330. }, scene: Scene): Mesh;
  106331. /**
  106332. * Creates a plane mesh
  106333. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  106334. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  106335. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  106336. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106337. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106338. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106339. * @param name defines the name of the mesh
  106340. * @param options defines the options used to create the mesh
  106341. * @param scene defines the hosting scene
  106342. * @returns the plane mesh
  106343. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  106344. */
  106345. static CreatePlane(name: string, options: {
  106346. size?: number;
  106347. width?: number;
  106348. height?: number;
  106349. sideOrientation?: number;
  106350. frontUVs?: Vector4;
  106351. backUVs?: Vector4;
  106352. updatable?: boolean;
  106353. sourcePlane?: Plane;
  106354. }, scene: Scene): Mesh;
  106355. /**
  106356. * Creates a ground mesh
  106357. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  106358. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  106359. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106360. * @param name defines the name of the mesh
  106361. * @param options defines the options used to create the mesh
  106362. * @param scene defines the hosting scene
  106363. * @returns the ground mesh
  106364. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  106365. */
  106366. static CreateGround(name: string, options: {
  106367. width?: number;
  106368. height?: number;
  106369. subdivisions?: number;
  106370. subdivisionsX?: number;
  106371. subdivisionsY?: number;
  106372. updatable?: boolean;
  106373. }, scene: any): Mesh;
  106374. /**
  106375. * Creates a tiled ground mesh
  106376. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  106377. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  106378. * * 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
  106379. * * 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
  106380. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  106381. * @param name defines the name of the mesh
  106382. * @param options defines the options used to create the mesh
  106383. * @param scene defines the hosting scene
  106384. * @returns the tiled ground mesh
  106385. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  106386. */
  106387. static CreateTiledGround(name: string, options: {
  106388. xmin: number;
  106389. zmin: number;
  106390. xmax: number;
  106391. zmax: number;
  106392. subdivisions?: {
  106393. w: number;
  106394. h: number;
  106395. };
  106396. precision?: {
  106397. w: number;
  106398. h: number;
  106399. };
  106400. updatable?: boolean;
  106401. }, scene: Scene): Mesh;
  106402. /**
  106403. * Creates a ground mesh from a height map
  106404. * * The parameter `url` sets the URL of the height map image resource.
  106405. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  106406. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  106407. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  106408. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  106409. * * 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.
  106410. * * 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).
  106411. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  106412. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  106413. * @param name defines the name of the mesh
  106414. * @param url defines the url to the height map
  106415. * @param options defines the options used to create the mesh
  106416. * @param scene defines the hosting scene
  106417. * @returns the ground mesh
  106418. * @see https://doc.babylonjs.com/babylon101/height_map
  106419. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  106420. */
  106421. static CreateGroundFromHeightMap(name: string, url: string, options: {
  106422. width?: number;
  106423. height?: number;
  106424. subdivisions?: number;
  106425. minHeight?: number;
  106426. maxHeight?: number;
  106427. colorFilter?: Color3;
  106428. alphaFilter?: number;
  106429. updatable?: boolean;
  106430. onReady?: (mesh: GroundMesh) => void;
  106431. }, scene: Scene): GroundMesh;
  106432. /**
  106433. * Creates a polygon mesh
  106434. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  106435. * * 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
  106436. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106437. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106438. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  106439. * * Remember you can only change the shape positions, not their number when updating a polygon
  106440. * @param name defines the name of the mesh
  106441. * @param options defines the options used to create the mesh
  106442. * @param scene defines the hosting scene
  106443. * @param earcutInjection can be used to inject your own earcut reference
  106444. * @returns the polygon mesh
  106445. */
  106446. static CreatePolygon(name: string, options: {
  106447. shape: Vector3[];
  106448. holes?: Vector3[][];
  106449. depth?: number;
  106450. faceUV?: Vector4[];
  106451. faceColors?: Color4[];
  106452. updatable?: boolean;
  106453. sideOrientation?: number;
  106454. frontUVs?: Vector4;
  106455. backUVs?: Vector4;
  106456. }, scene: Scene, earcutInjection?: any): Mesh;
  106457. /**
  106458. * Creates an extruded polygon mesh, with depth in the Y direction.
  106459. * * 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)
  106460. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  106461. * @param name defines the name of the mesh
  106462. * @param options defines the options used to create the mesh
  106463. * @param scene defines the hosting scene
  106464. * @param earcutInjection can be used to inject your own earcut reference
  106465. * @returns the polygon mesh
  106466. */
  106467. static ExtrudePolygon(name: string, options: {
  106468. shape: Vector3[];
  106469. holes?: Vector3[][];
  106470. depth?: number;
  106471. faceUV?: Vector4[];
  106472. faceColors?: Color4[];
  106473. updatable?: boolean;
  106474. sideOrientation?: number;
  106475. frontUVs?: Vector4;
  106476. backUVs?: Vector4;
  106477. }, scene: Scene, earcutInjection?: any): Mesh;
  106478. /**
  106479. * Creates a tube mesh.
  106480. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  106481. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  106482. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  106483. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  106484. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  106485. * * 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)
  106486. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  106487. * * 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
  106488. * * 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
  106489. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106490. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106491. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  106492. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106493. * @param name defines the name of the mesh
  106494. * @param options defines the options used to create the mesh
  106495. * @param scene defines the hosting scene
  106496. * @returns the tube mesh
  106497. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  106498. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  106499. */
  106500. static CreateTube(name: string, options: {
  106501. path: Vector3[];
  106502. radius?: number;
  106503. tessellation?: number;
  106504. radiusFunction?: {
  106505. (i: number, distance: number): number;
  106506. };
  106507. cap?: number;
  106508. arc?: number;
  106509. updatable?: boolean;
  106510. sideOrientation?: number;
  106511. frontUVs?: Vector4;
  106512. backUVs?: Vector4;
  106513. instance?: Mesh;
  106514. invertUV?: boolean;
  106515. }, scene: Scene): Mesh;
  106516. /**
  106517. * Creates a polyhedron mesh
  106518. * * 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
  106519. * * The parameter `size` (positive float, default 1) sets the polygon size
  106520. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  106521. * * 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`
  106522. * * 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
  106523. * * 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)`)
  106524. * * 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
  106525. * * 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
  106526. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106527. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106528. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106529. * @param name defines the name of the mesh
  106530. * @param options defines the options used to create the mesh
  106531. * @param scene defines the hosting scene
  106532. * @returns the polyhedron mesh
  106533. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  106534. */
  106535. static CreatePolyhedron(name: string, options: {
  106536. type?: number;
  106537. size?: number;
  106538. sizeX?: number;
  106539. sizeY?: number;
  106540. sizeZ?: number;
  106541. custom?: any;
  106542. faceUV?: Vector4[];
  106543. faceColors?: Color4[];
  106544. flat?: boolean;
  106545. updatable?: boolean;
  106546. sideOrientation?: number;
  106547. frontUVs?: Vector4;
  106548. backUVs?: Vector4;
  106549. }, scene: Scene): Mesh;
  106550. /**
  106551. * Creates a decal mesh.
  106552. * 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
  106553. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  106554. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  106555. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  106556. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  106557. * @param name defines the name of the mesh
  106558. * @param sourceMesh defines the mesh where the decal must be applied
  106559. * @param options defines the options used to create the mesh
  106560. * @param scene defines the hosting scene
  106561. * @returns the decal mesh
  106562. * @see https://doc.babylonjs.com/how_to/decals
  106563. */
  106564. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  106565. position?: Vector3;
  106566. normal?: Vector3;
  106567. size?: Vector3;
  106568. angle?: number;
  106569. }): Mesh;
  106570. }
  106571. }
  106572. declare module BABYLON {
  106573. /**
  106574. * A simplifier interface for future simplification implementations
  106575. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  106576. */
  106577. export interface ISimplifier {
  106578. /**
  106579. * Simplification of a given mesh according to the given settings.
  106580. * Since this requires computation, it is assumed that the function runs async.
  106581. * @param settings The settings of the simplification, including quality and distance
  106582. * @param successCallback A callback that will be called after the mesh was simplified.
  106583. * @param errorCallback in case of an error, this callback will be called. optional.
  106584. */
  106585. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  106586. }
  106587. /**
  106588. * Expected simplification settings.
  106589. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  106590. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  106591. */
  106592. export interface ISimplificationSettings {
  106593. /**
  106594. * Gets or sets the expected quality
  106595. */
  106596. quality: number;
  106597. /**
  106598. * Gets or sets the distance when this optimized version should be used
  106599. */
  106600. distance: number;
  106601. /**
  106602. * Gets an already optimized mesh
  106603. */
  106604. optimizeMesh?: boolean;
  106605. }
  106606. /**
  106607. * Class used to specify simplification options
  106608. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  106609. */
  106610. export class SimplificationSettings implements ISimplificationSettings {
  106611. /** expected quality */
  106612. quality: number;
  106613. /** distance when this optimized version should be used */
  106614. distance: number;
  106615. /** already optimized mesh */
  106616. optimizeMesh?: boolean | undefined;
  106617. /**
  106618. * Creates a SimplificationSettings
  106619. * @param quality expected quality
  106620. * @param distance distance when this optimized version should be used
  106621. * @param optimizeMesh already optimized mesh
  106622. */
  106623. constructor(
  106624. /** expected quality */
  106625. quality: number,
  106626. /** distance when this optimized version should be used */
  106627. distance: number,
  106628. /** already optimized mesh */
  106629. optimizeMesh?: boolean | undefined);
  106630. }
  106631. /**
  106632. * Interface used to define a simplification task
  106633. */
  106634. export interface ISimplificationTask {
  106635. /**
  106636. * Array of settings
  106637. */
  106638. settings: Array<ISimplificationSettings>;
  106639. /**
  106640. * Simplification type
  106641. */
  106642. simplificationType: SimplificationType;
  106643. /**
  106644. * Mesh to simplify
  106645. */
  106646. mesh: Mesh;
  106647. /**
  106648. * Callback called on success
  106649. */
  106650. successCallback?: () => void;
  106651. /**
  106652. * Defines if parallel processing can be used
  106653. */
  106654. parallelProcessing: boolean;
  106655. }
  106656. /**
  106657. * Queue used to order the simplification tasks
  106658. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  106659. */
  106660. export class SimplificationQueue {
  106661. private _simplificationArray;
  106662. /**
  106663. * Gets a boolean indicating that the process is still running
  106664. */
  106665. running: boolean;
  106666. /**
  106667. * Creates a new queue
  106668. */
  106669. constructor();
  106670. /**
  106671. * Adds a new simplification task
  106672. * @param task defines a task to add
  106673. */
  106674. addTask(task: ISimplificationTask): void;
  106675. /**
  106676. * Execute next task
  106677. */
  106678. executeNext(): void;
  106679. /**
  106680. * Execute a simplification task
  106681. * @param task defines the task to run
  106682. */
  106683. runSimplification(task: ISimplificationTask): void;
  106684. private getSimplifier;
  106685. }
  106686. /**
  106687. * The implemented types of simplification
  106688. * At the moment only Quadratic Error Decimation is implemented
  106689. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  106690. */
  106691. export enum SimplificationType {
  106692. /** Quadratic error decimation */
  106693. QUADRATIC = 0
  106694. }
  106695. }
  106696. declare module BABYLON {
  106697. interface Scene {
  106698. /** @hidden (Backing field) */
  106699. _simplificationQueue: SimplificationQueue;
  106700. /**
  106701. * Gets or sets the simplification queue attached to the scene
  106702. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  106703. */
  106704. simplificationQueue: SimplificationQueue;
  106705. }
  106706. interface Mesh {
  106707. /**
  106708. * Simplify the mesh according to the given array of settings.
  106709. * Function will return immediately and will simplify async
  106710. * @param settings a collection of simplification settings
  106711. * @param parallelProcessing should all levels calculate parallel or one after the other
  106712. * @param simplificationType the type of simplification to run
  106713. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  106714. * @returns the current mesh
  106715. */
  106716. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  106717. }
  106718. /**
  106719. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  106720. * created in a scene
  106721. */
  106722. export class SimplicationQueueSceneComponent implements ISceneComponent {
  106723. /**
  106724. * The component name helpfull to identify the component in the list of scene components.
  106725. */
  106726. readonly name: string;
  106727. /**
  106728. * The scene the component belongs to.
  106729. */
  106730. scene: Scene;
  106731. /**
  106732. * Creates a new instance of the component for the given scene
  106733. * @param scene Defines the scene to register the component in
  106734. */
  106735. constructor(scene: Scene);
  106736. /**
  106737. * Registers the component in a given scene
  106738. */
  106739. register(): void;
  106740. /**
  106741. * Rebuilds the elements related to this component in case of
  106742. * context lost for instance.
  106743. */
  106744. rebuild(): void;
  106745. /**
  106746. * Disposes the component and the associated ressources
  106747. */
  106748. dispose(): void;
  106749. private _beforeCameraUpdate;
  106750. }
  106751. }
  106752. declare module BABYLON {
  106753. /**
  106754. * Class used to enable access to IndexedDB
  106755. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  106756. */
  106757. export class Database implements IOfflineProvider {
  106758. private _callbackManifestChecked;
  106759. private _currentSceneUrl;
  106760. private _db;
  106761. private _enableSceneOffline;
  106762. private _enableTexturesOffline;
  106763. private _manifestVersionFound;
  106764. private _mustUpdateRessources;
  106765. private _hasReachedQuota;
  106766. private _isSupported;
  106767. private _idbFactory;
  106768. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  106769. private static IsUASupportingBlobStorage;
  106770. /**
  106771. * Gets a boolean indicating if Database storate is enabled (off by default)
  106772. */
  106773. static IDBStorageEnabled: boolean;
  106774. /**
  106775. * Gets a boolean indicating if scene must be saved in the database
  106776. */
  106777. readonly enableSceneOffline: boolean;
  106778. /**
  106779. * Gets a boolean indicating if textures must be saved in the database
  106780. */
  106781. readonly enableTexturesOffline: boolean;
  106782. /**
  106783. * Creates a new Database
  106784. * @param urlToScene defines the url to load the scene
  106785. * @param callbackManifestChecked defines the callback to use when manifest is checked
  106786. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  106787. */
  106788. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  106789. private static _ParseURL;
  106790. private static _ReturnFullUrlLocation;
  106791. private _checkManifestFile;
  106792. /**
  106793. * Open the database and make it available
  106794. * @param successCallback defines the callback to call on success
  106795. * @param errorCallback defines the callback to call on error
  106796. */
  106797. open(successCallback: () => void, errorCallback: () => void): void;
  106798. /**
  106799. * Loads an image from the database
  106800. * @param url defines the url to load from
  106801. * @param image defines the target DOM image
  106802. */
  106803. loadImage(url: string, image: HTMLImageElement): void;
  106804. private _loadImageFromDBAsync;
  106805. private _saveImageIntoDBAsync;
  106806. private _checkVersionFromDB;
  106807. private _loadVersionFromDBAsync;
  106808. private _saveVersionIntoDBAsync;
  106809. /**
  106810. * Loads a file from database
  106811. * @param url defines the URL to load from
  106812. * @param sceneLoaded defines a callback to call on success
  106813. * @param progressCallBack defines a callback to call when progress changed
  106814. * @param errorCallback defines a callback to call on error
  106815. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  106816. */
  106817. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  106818. private _loadFileAsync;
  106819. private _saveFileAsync;
  106820. /**
  106821. * Validates if xhr data is correct
  106822. * @param xhr defines the request to validate
  106823. * @param dataType defines the expected data type
  106824. * @returns true if data is correct
  106825. */
  106826. private static _ValidateXHRData;
  106827. }
  106828. }
  106829. declare module BABYLON {
  106830. /** @hidden */
  106831. export var gpuUpdateParticlesPixelShader: {
  106832. name: string;
  106833. shader: string;
  106834. };
  106835. }
  106836. declare module BABYLON {
  106837. /** @hidden */
  106838. export var gpuUpdateParticlesVertexShader: {
  106839. name: string;
  106840. shader: string;
  106841. };
  106842. }
  106843. declare module BABYLON {
  106844. /** @hidden */
  106845. export var clipPlaneFragmentDeclaration2: {
  106846. name: string;
  106847. shader: string;
  106848. };
  106849. }
  106850. declare module BABYLON {
  106851. /** @hidden */
  106852. export var gpuRenderParticlesPixelShader: {
  106853. name: string;
  106854. shader: string;
  106855. };
  106856. }
  106857. declare module BABYLON {
  106858. /** @hidden */
  106859. export var clipPlaneVertexDeclaration2: {
  106860. name: string;
  106861. shader: string;
  106862. };
  106863. }
  106864. declare module BABYLON {
  106865. /** @hidden */
  106866. export var gpuRenderParticlesVertexShader: {
  106867. name: string;
  106868. shader: string;
  106869. };
  106870. }
  106871. declare module BABYLON {
  106872. /**
  106873. * This represents a GPU particle system in Babylon
  106874. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  106875. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  106876. */
  106877. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  106878. /**
  106879. * The layer mask we are rendering the particles through.
  106880. */
  106881. layerMask: number;
  106882. private _capacity;
  106883. private _activeCount;
  106884. private _currentActiveCount;
  106885. private _accumulatedCount;
  106886. private _renderEffect;
  106887. private _updateEffect;
  106888. private _buffer0;
  106889. private _buffer1;
  106890. private _spriteBuffer;
  106891. private _updateVAO;
  106892. private _renderVAO;
  106893. private _targetIndex;
  106894. private _sourceBuffer;
  106895. private _targetBuffer;
  106896. private _engine;
  106897. private _currentRenderId;
  106898. private _started;
  106899. private _stopped;
  106900. private _timeDelta;
  106901. private _randomTexture;
  106902. private _randomTexture2;
  106903. private _attributesStrideSize;
  106904. private _updateEffectOptions;
  106905. private _randomTextureSize;
  106906. private _actualFrame;
  106907. private readonly _rawTextureWidth;
  106908. /**
  106909. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  106910. */
  106911. static readonly IsSupported: boolean;
  106912. /**
  106913. * An event triggered when the system is disposed.
  106914. */
  106915. onDisposeObservable: Observable<GPUParticleSystem>;
  106916. /**
  106917. * Gets the maximum number of particles active at the same time.
  106918. * @returns The max number of active particles.
  106919. */
  106920. getCapacity(): number;
  106921. /**
  106922. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  106923. * to override the particles.
  106924. */
  106925. forceDepthWrite: boolean;
  106926. /**
  106927. * Gets or set the number of active particles
  106928. */
  106929. activeParticleCount: number;
  106930. private _preWarmDone;
  106931. /**
  106932. * Is this system ready to be used/rendered
  106933. * @return true if the system is ready
  106934. */
  106935. isReady(): boolean;
  106936. /**
  106937. * Gets if the system has been started. (Note: this will still be true after stop is called)
  106938. * @returns True if it has been started, otherwise false.
  106939. */
  106940. isStarted(): boolean;
  106941. /**
  106942. * Starts the particle system and begins to emit
  106943. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  106944. */
  106945. start(delay?: number): void;
  106946. /**
  106947. * Stops the particle system.
  106948. */
  106949. stop(): void;
  106950. /**
  106951. * Remove all active particles
  106952. */
  106953. reset(): void;
  106954. /**
  106955. * Returns the string "GPUParticleSystem"
  106956. * @returns a string containing the class name
  106957. */
  106958. getClassName(): string;
  106959. private _colorGradientsTexture;
  106960. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  106961. /**
  106962. * Adds a new color gradient
  106963. * @param gradient defines the gradient to use (between 0 and 1)
  106964. * @param color1 defines the color to affect to the specified gradient
  106965. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  106966. * @returns the current particle system
  106967. */
  106968. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  106969. /**
  106970. * Remove a specific color gradient
  106971. * @param gradient defines the gradient to remove
  106972. * @returns the current particle system
  106973. */
  106974. removeColorGradient(gradient: number): GPUParticleSystem;
  106975. private _angularSpeedGradientsTexture;
  106976. private _sizeGradientsTexture;
  106977. private _velocityGradientsTexture;
  106978. private _limitVelocityGradientsTexture;
  106979. private _dragGradientsTexture;
  106980. private _addFactorGradient;
  106981. /**
  106982. * Adds a new size gradient
  106983. * @param gradient defines the gradient to use (between 0 and 1)
  106984. * @param factor defines the size factor to affect to the specified gradient
  106985. * @returns the current particle system
  106986. */
  106987. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  106988. /**
  106989. * Remove a specific size gradient
  106990. * @param gradient defines the gradient to remove
  106991. * @returns the current particle system
  106992. */
  106993. removeSizeGradient(gradient: number): GPUParticleSystem;
  106994. /**
  106995. * Adds a new angular speed gradient
  106996. * @param gradient defines the gradient to use (between 0 and 1)
  106997. * @param factor defines the angular speed to affect to the specified gradient
  106998. * @returns the current particle system
  106999. */
  107000. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  107001. /**
  107002. * Remove a specific angular speed gradient
  107003. * @param gradient defines the gradient to remove
  107004. * @returns the current particle system
  107005. */
  107006. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  107007. /**
  107008. * Adds a new velocity gradient
  107009. * @param gradient defines the gradient to use (between 0 and 1)
  107010. * @param factor defines the velocity to affect to the specified gradient
  107011. * @returns the current particle system
  107012. */
  107013. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  107014. /**
  107015. * Remove a specific velocity gradient
  107016. * @param gradient defines the gradient to remove
  107017. * @returns the current particle system
  107018. */
  107019. removeVelocityGradient(gradient: number): GPUParticleSystem;
  107020. /**
  107021. * Adds a new limit velocity gradient
  107022. * @param gradient defines the gradient to use (between 0 and 1)
  107023. * @param factor defines the limit velocity value to affect to the specified gradient
  107024. * @returns the current particle system
  107025. */
  107026. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  107027. /**
  107028. * Remove a specific limit velocity gradient
  107029. * @param gradient defines the gradient to remove
  107030. * @returns the current particle system
  107031. */
  107032. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  107033. /**
  107034. * Adds a new drag gradient
  107035. * @param gradient defines the gradient to use (between 0 and 1)
  107036. * @param factor defines the drag value to affect to the specified gradient
  107037. * @returns the current particle system
  107038. */
  107039. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  107040. /**
  107041. * Remove a specific drag gradient
  107042. * @param gradient defines the gradient to remove
  107043. * @returns the current particle system
  107044. */
  107045. removeDragGradient(gradient: number): GPUParticleSystem;
  107046. /**
  107047. * Not supported by GPUParticleSystem
  107048. * @param gradient defines the gradient to use (between 0 and 1)
  107049. * @param factor defines the emit rate value to affect to the specified gradient
  107050. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  107051. * @returns the current particle system
  107052. */
  107053. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  107054. /**
  107055. * Not supported by GPUParticleSystem
  107056. * @param gradient defines the gradient to remove
  107057. * @returns the current particle system
  107058. */
  107059. removeEmitRateGradient(gradient: number): IParticleSystem;
  107060. /**
  107061. * Not supported by GPUParticleSystem
  107062. * @param gradient defines the gradient to use (between 0 and 1)
  107063. * @param factor defines the start size value to affect to the specified gradient
  107064. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  107065. * @returns the current particle system
  107066. */
  107067. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  107068. /**
  107069. * Not supported by GPUParticleSystem
  107070. * @param gradient defines the gradient to remove
  107071. * @returns the current particle system
  107072. */
  107073. removeStartSizeGradient(gradient: number): IParticleSystem;
  107074. /**
  107075. * Not supported by GPUParticleSystem
  107076. * @param gradient defines the gradient to use (between 0 and 1)
  107077. * @param min defines the color remap minimal range
  107078. * @param max defines the color remap maximal range
  107079. * @returns the current particle system
  107080. */
  107081. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  107082. /**
  107083. * Not supported by GPUParticleSystem
  107084. * @param gradient defines the gradient to remove
  107085. * @returns the current particle system
  107086. */
  107087. removeColorRemapGradient(): IParticleSystem;
  107088. /**
  107089. * Not supported by GPUParticleSystem
  107090. * @param gradient defines the gradient to use (between 0 and 1)
  107091. * @param min defines the alpha remap minimal range
  107092. * @param max defines the alpha remap maximal range
  107093. * @returns the current particle system
  107094. */
  107095. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  107096. /**
  107097. * Not supported by GPUParticleSystem
  107098. * @param gradient defines the gradient to remove
  107099. * @returns the current particle system
  107100. */
  107101. removeAlphaRemapGradient(): IParticleSystem;
  107102. /**
  107103. * Not supported by GPUParticleSystem
  107104. * @param gradient defines the gradient to use (between 0 and 1)
  107105. * @param color defines the color to affect to the specified gradient
  107106. * @returns the current particle system
  107107. */
  107108. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  107109. /**
  107110. * Not supported by GPUParticleSystem
  107111. * @param gradient defines the gradient to remove
  107112. * @returns the current particle system
  107113. */
  107114. removeRampGradient(): IParticleSystem;
  107115. /**
  107116. * Not supported by GPUParticleSystem
  107117. * @returns the list of ramp gradients
  107118. */
  107119. getRampGradients(): Nullable<Array<Color3Gradient>>;
  107120. /**
  107121. * Not supported by GPUParticleSystem
  107122. * Gets or sets a boolean indicating that ramp gradients must be used
  107123. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  107124. */
  107125. useRampGradients: boolean;
  107126. /**
  107127. * Not supported by GPUParticleSystem
  107128. * @param gradient defines the gradient to use (between 0 and 1)
  107129. * @param factor defines the life time factor to affect to the specified gradient
  107130. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  107131. * @returns the current particle system
  107132. */
  107133. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  107134. /**
  107135. * Not supported by GPUParticleSystem
  107136. * @param gradient defines the gradient to remove
  107137. * @returns the current particle system
  107138. */
  107139. removeLifeTimeGradient(gradient: number): IParticleSystem;
  107140. /**
  107141. * Instantiates a GPU particle system.
  107142. * 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.
  107143. * @param name The name of the particle system
  107144. * @param options The options used to create the system
  107145. * @param scene The scene the particle system belongs to
  107146. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  107147. */
  107148. constructor(name: string, options: Partial<{
  107149. capacity: number;
  107150. randomTextureSize: number;
  107151. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  107152. protected _reset(): void;
  107153. private _createUpdateVAO;
  107154. private _createRenderVAO;
  107155. private _initialize;
  107156. /** @hidden */
  107157. _recreateUpdateEffect(): void;
  107158. /** @hidden */
  107159. _recreateRenderEffect(): void;
  107160. /**
  107161. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  107162. * @param preWarm defines if we are in the pre-warmimg phase
  107163. */
  107164. animate(preWarm?: boolean): void;
  107165. private _createFactorGradientTexture;
  107166. private _createSizeGradientTexture;
  107167. private _createAngularSpeedGradientTexture;
  107168. private _createVelocityGradientTexture;
  107169. private _createLimitVelocityGradientTexture;
  107170. private _createDragGradientTexture;
  107171. private _createColorGradientTexture;
  107172. /**
  107173. * Renders the particle system in its current state
  107174. * @param preWarm defines if the system should only update the particles but not render them
  107175. * @returns the current number of particles
  107176. */
  107177. render(preWarm?: boolean): number;
  107178. /**
  107179. * Rebuilds the particle system
  107180. */
  107181. rebuild(): void;
  107182. private _releaseBuffers;
  107183. private _releaseVAOs;
  107184. /**
  107185. * Disposes the particle system and free the associated resources
  107186. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  107187. */
  107188. dispose(disposeTexture?: boolean): void;
  107189. /**
  107190. * Clones the particle system.
  107191. * @param name The name of the cloned object
  107192. * @param newEmitter The new emitter to use
  107193. * @returns the cloned particle system
  107194. */
  107195. clone(name: string, newEmitter: any): GPUParticleSystem;
  107196. /**
  107197. * Serializes the particle system to a JSON object.
  107198. * @returns the JSON object
  107199. */
  107200. serialize(): any;
  107201. /**
  107202. * Parses a JSON object to create a GPU particle system.
  107203. * @param parsedParticleSystem The JSON object to parse
  107204. * @param scene The scene to create the particle system in
  107205. * @param rootUrl The root url to use to load external dependencies like texture
  107206. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  107207. * @returns the parsed GPU particle system
  107208. */
  107209. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  107210. }
  107211. }
  107212. declare module BABYLON {
  107213. /**
  107214. * Represents a set of particle systems working together to create a specific effect
  107215. */
  107216. export class ParticleSystemSet implements IDisposable {
  107217. private _emitterCreationOptions;
  107218. private _emitterNode;
  107219. /**
  107220. * Gets the particle system list
  107221. */
  107222. systems: IParticleSystem[];
  107223. /**
  107224. * Gets the emitter node used with this set
  107225. */
  107226. readonly emitterNode: Nullable<TransformNode>;
  107227. /**
  107228. * Creates a new emitter mesh as a sphere
  107229. * @param options defines the options used to create the sphere
  107230. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  107231. * @param scene defines the hosting scene
  107232. */
  107233. setEmitterAsSphere(options: {
  107234. diameter: number;
  107235. segments: number;
  107236. color: Color3;
  107237. }, renderingGroupId: number, scene: Scene): void;
  107238. /**
  107239. * Starts all particle systems of the set
  107240. * @param emitter defines an optional mesh to use as emitter for the particle systems
  107241. */
  107242. start(emitter?: AbstractMesh): void;
  107243. /**
  107244. * Release all associated resources
  107245. */
  107246. dispose(): void;
  107247. /**
  107248. * Serialize the set into a JSON compatible object
  107249. * @returns a JSON compatible representation of the set
  107250. */
  107251. serialize(): any;
  107252. /**
  107253. * Parse a new ParticleSystemSet from a serialized source
  107254. * @param data defines a JSON compatible representation of the set
  107255. * @param scene defines the hosting scene
  107256. * @param gpu defines if we want GPU particles or CPU particles
  107257. * @returns a new ParticleSystemSet
  107258. */
  107259. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  107260. }
  107261. }
  107262. declare module BABYLON {
  107263. /**
  107264. * This class is made for on one-liner static method to help creating particle system set.
  107265. */
  107266. export class ParticleHelper {
  107267. /**
  107268. * Gets or sets base Assets URL
  107269. */
  107270. static BaseAssetsUrl: string;
  107271. /**
  107272. * Create a default particle system that you can tweak
  107273. * @param emitter defines the emitter to use
  107274. * @param capacity defines the system capacity (default is 500 particles)
  107275. * @param scene defines the hosting scene
  107276. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  107277. * @returns the new Particle system
  107278. */
  107279. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  107280. /**
  107281. * This is the main static method (one-liner) of this helper to create different particle systems
  107282. * @param type This string represents the type to the particle system to create
  107283. * @param scene The scene where the particle system should live
  107284. * @param gpu If the system will use gpu
  107285. * @returns the ParticleSystemSet created
  107286. */
  107287. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  107288. /**
  107289. * Static function used to export a particle system to a ParticleSystemSet variable.
  107290. * Please note that the emitter shape is not exported
  107291. * @param systems defines the particle systems to export
  107292. * @returns the created particle system set
  107293. */
  107294. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  107295. }
  107296. }
  107297. declare module BABYLON {
  107298. interface Engine {
  107299. /**
  107300. * Create an effect to use with particle systems.
  107301. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  107302. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  107303. * @param uniformsNames defines a list of attribute names
  107304. * @param samplers defines an array of string used to represent textures
  107305. * @param defines defines the string containing the defines to use to compile the shaders
  107306. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  107307. * @param onCompiled defines a function to call when the effect creation is successful
  107308. * @param onError defines a function to call when the effect creation has failed
  107309. * @returns the new Effect
  107310. */
  107311. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  107312. }
  107313. interface Mesh {
  107314. /**
  107315. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  107316. * @returns an array of IParticleSystem
  107317. */
  107318. getEmittedParticleSystems(): IParticleSystem[];
  107319. /**
  107320. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  107321. * @returns an array of IParticleSystem
  107322. */
  107323. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  107324. }
  107325. /**
  107326. * @hidden
  107327. */
  107328. export var _IDoNeedToBeInTheBuild: number;
  107329. }
  107330. declare module BABYLON {
  107331. interface Scene {
  107332. /** @hidden (Backing field) */
  107333. _physicsEngine: Nullable<IPhysicsEngine>;
  107334. /**
  107335. * Gets the current physics engine
  107336. * @returns a IPhysicsEngine or null if none attached
  107337. */
  107338. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  107339. /**
  107340. * Enables physics to the current scene
  107341. * @param gravity defines the scene's gravity for the physics engine
  107342. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  107343. * @return a boolean indicating if the physics engine was initialized
  107344. */
  107345. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  107346. /**
  107347. * Disables and disposes the physics engine associated with the scene
  107348. */
  107349. disablePhysicsEngine(): void;
  107350. /**
  107351. * Gets a boolean indicating if there is an active physics engine
  107352. * @returns a boolean indicating if there is an active physics engine
  107353. */
  107354. isPhysicsEnabled(): boolean;
  107355. /**
  107356. * Deletes a physics compound impostor
  107357. * @param compound defines the compound to delete
  107358. */
  107359. deleteCompoundImpostor(compound: any): void;
  107360. /**
  107361. * An event triggered when physic simulation is about to be run
  107362. */
  107363. onBeforePhysicsObservable: Observable<Scene>;
  107364. /**
  107365. * An event triggered when physic simulation has been done
  107366. */
  107367. onAfterPhysicsObservable: Observable<Scene>;
  107368. }
  107369. interface AbstractMesh {
  107370. /** @hidden */
  107371. _physicsImpostor: Nullable<PhysicsImpostor>;
  107372. /**
  107373. * Gets or sets impostor used for physic simulation
  107374. * @see http://doc.babylonjs.com/features/physics_engine
  107375. */
  107376. physicsImpostor: Nullable<PhysicsImpostor>;
  107377. /**
  107378. * Gets the current physics impostor
  107379. * @see http://doc.babylonjs.com/features/physics_engine
  107380. * @returns a physics impostor or null
  107381. */
  107382. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  107383. /** Apply a physic impulse to the mesh
  107384. * @param force defines the force to apply
  107385. * @param contactPoint defines where to apply the force
  107386. * @returns the current mesh
  107387. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  107388. */
  107389. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  107390. /**
  107391. * Creates a physic joint between two meshes
  107392. * @param otherMesh defines the other mesh to use
  107393. * @param pivot1 defines the pivot to use on this mesh
  107394. * @param pivot2 defines the pivot to use on the other mesh
  107395. * @param options defines additional options (can be plugin dependent)
  107396. * @returns the current mesh
  107397. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  107398. */
  107399. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  107400. /** @hidden */
  107401. _disposePhysicsObserver: Nullable<Observer<Node>>;
  107402. }
  107403. /**
  107404. * Defines the physics engine scene component responsible to manage a physics engine
  107405. */
  107406. export class PhysicsEngineSceneComponent implements ISceneComponent {
  107407. /**
  107408. * The component name helpful to identify the component in the list of scene components.
  107409. */
  107410. readonly name: string;
  107411. /**
  107412. * The scene the component belongs to.
  107413. */
  107414. scene: Scene;
  107415. /**
  107416. * Creates a new instance of the component for the given scene
  107417. * @param scene Defines the scene to register the component in
  107418. */
  107419. constructor(scene: Scene);
  107420. /**
  107421. * Registers the component in a given scene
  107422. */
  107423. register(): void;
  107424. /**
  107425. * Rebuilds the elements related to this component in case of
  107426. * context lost for instance.
  107427. */
  107428. rebuild(): void;
  107429. /**
  107430. * Disposes the component and the associated ressources
  107431. */
  107432. dispose(): void;
  107433. }
  107434. }
  107435. declare module BABYLON {
  107436. /**
  107437. * A helper for physics simulations
  107438. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107439. */
  107440. export class PhysicsHelper {
  107441. private _scene;
  107442. private _physicsEngine;
  107443. /**
  107444. * Initializes the Physics helper
  107445. * @param scene Babylon.js scene
  107446. */
  107447. constructor(scene: Scene);
  107448. /**
  107449. * Applies a radial explosion impulse
  107450. * @param origin the origin of the explosion
  107451. * @param radius the explosion radius
  107452. * @param strength the explosion strength
  107453. * @param falloff possible options: Constant & Linear. Defaults to Constant
  107454. * @returns A physics radial explosion event, or null
  107455. */
  107456. applyRadialExplosionImpulse(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  107457. /**
  107458. * Applies a radial explosion force
  107459. * @param origin the origin of the explosion
  107460. * @param radius the explosion radius
  107461. * @param strength the explosion strength
  107462. * @param falloff possible options: Constant & Linear. Defaults to Constant
  107463. * @returns A physics radial explosion event, or null
  107464. */
  107465. applyRadialExplosionForce(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  107466. /**
  107467. * Creates a gravitational field
  107468. * @param origin the origin of the explosion
  107469. * @param radius the explosion radius
  107470. * @param strength the explosion strength
  107471. * @param falloff possible options: Constant & Linear. Defaults to Constant
  107472. * @returns A physics gravitational field event, or null
  107473. */
  107474. gravitationalField(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  107475. /**
  107476. * Creates a physics updraft event
  107477. * @param origin the origin of the updraft
  107478. * @param radius the radius of the updraft
  107479. * @param strength the strength of the updraft
  107480. * @param height the height of the updraft
  107481. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  107482. * @returns A physics updraft event, or null
  107483. */
  107484. updraft(origin: Vector3, radius: number, strength: number, height: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  107485. /**
  107486. * Creates a physics vortex event
  107487. * @param origin the of the vortex
  107488. * @param radius the radius of the vortex
  107489. * @param strength the strength of the vortex
  107490. * @param height the height of the vortex
  107491. * @returns a Physics vortex event, or null
  107492. * A physics vortex event or null
  107493. */
  107494. vortex(origin: Vector3, radius: number, strength: number, height: number): Nullable<PhysicsVortexEvent>;
  107495. }
  107496. /**
  107497. * Represents a physics radial explosion event
  107498. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107499. */
  107500. export class PhysicsRadialExplosionEvent {
  107501. private _scene;
  107502. private _sphere;
  107503. private _sphereOptions;
  107504. private _rays;
  107505. private _dataFetched;
  107506. /**
  107507. * Initializes a radial explosioin event
  107508. * @param scene BabylonJS scene
  107509. */
  107510. constructor(scene: Scene);
  107511. /**
  107512. * Returns the data related to the radial explosion event (sphere & rays).
  107513. * @returns The radial explosion event data
  107514. */
  107515. getData(): PhysicsRadialExplosionEventData;
  107516. /**
  107517. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  107518. * @param impostor A physics imposter
  107519. * @param origin the origin of the explosion
  107520. * @param radius the explosion radius
  107521. * @param strength the explosion strength
  107522. * @param falloff possible options: Constant & Linear
  107523. * @returns {Nullable<PhysicsForceAndContactPoint>} A physics force and contact point, or null
  107524. */
  107525. getImpostorForceAndContactPoint(impostor: PhysicsImpostor, origin: Vector3, radius: number, strength: number, falloff: PhysicsRadialImpulseFalloff): Nullable<PhysicsForceAndContactPoint>;
  107526. /**
  107527. * Disposes the sphere.
  107528. * @param force Specifies if the sphere should be disposed by force
  107529. */
  107530. dispose(force?: boolean): void;
  107531. /*** Helpers ***/
  107532. private _prepareSphere;
  107533. private _intersectsWithSphere;
  107534. }
  107535. /**
  107536. * Represents a gravitational field event
  107537. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107538. */
  107539. export class PhysicsGravitationalFieldEvent {
  107540. private _physicsHelper;
  107541. private _scene;
  107542. private _origin;
  107543. private _radius;
  107544. private _strength;
  107545. private _falloff;
  107546. private _tickCallback;
  107547. private _sphere;
  107548. private _dataFetched;
  107549. /**
  107550. * Initializes the physics gravitational field event
  107551. * @param physicsHelper A physics helper
  107552. * @param scene BabylonJS scene
  107553. * @param origin The origin position of the gravitational field event
  107554. * @param radius The radius of the gravitational field event
  107555. * @param strength The strength of the gravitational field event
  107556. * @param falloff The falloff for the gravitational field event
  107557. */
  107558. constructor(physicsHelper: PhysicsHelper, scene: Scene, origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff);
  107559. /**
  107560. * Returns the data related to the gravitational field event (sphere).
  107561. * @returns A gravitational field event
  107562. */
  107563. getData(): PhysicsGravitationalFieldEventData;
  107564. /**
  107565. * Enables the gravitational field.
  107566. */
  107567. enable(): void;
  107568. /**
  107569. * Disables the gravitational field.
  107570. */
  107571. disable(): void;
  107572. /**
  107573. * Disposes the sphere.
  107574. * @param force The force to dispose from the gravitational field event
  107575. */
  107576. dispose(force?: boolean): void;
  107577. private _tick;
  107578. }
  107579. /**
  107580. * Represents a physics updraft event
  107581. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107582. */
  107583. export class PhysicsUpdraftEvent {
  107584. private _scene;
  107585. private _origin;
  107586. private _radius;
  107587. private _strength;
  107588. private _height;
  107589. private _updraftMode;
  107590. private _physicsEngine;
  107591. private _originTop;
  107592. private _originDirection;
  107593. private _tickCallback;
  107594. private _cylinder;
  107595. private _cylinderPosition;
  107596. private _dataFetched;
  107597. /**
  107598. * Initializes the physics updraft event
  107599. * @param _scene BabylonJS scene
  107600. * @param _origin The origin position of the updraft
  107601. * @param _radius The radius of the updraft
  107602. * @param _strength The strength of the updraft
  107603. * @param _height The height of the updraft
  107604. * @param _updraftMode The mode of the updraft
  107605. */
  107606. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number, _updraftMode: PhysicsUpdraftMode);
  107607. /**
  107608. * Returns the data related to the updraft event (cylinder).
  107609. * @returns A physics updraft event
  107610. */
  107611. getData(): PhysicsUpdraftEventData;
  107612. /**
  107613. * Enables the updraft.
  107614. */
  107615. enable(): void;
  107616. /**
  107617. * Disables the cortex.
  107618. */
  107619. disable(): void;
  107620. /**
  107621. * Disposes the sphere.
  107622. * @param force Specifies if the updraft should be disposed by force
  107623. */
  107624. dispose(force?: boolean): void;
  107625. private getImpostorForceAndContactPoint;
  107626. private _tick;
  107627. /*** Helpers ***/
  107628. private _prepareCylinder;
  107629. private _intersectsWithCylinder;
  107630. }
  107631. /**
  107632. * Represents a physics vortex event
  107633. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107634. */
  107635. export class PhysicsVortexEvent {
  107636. private _scene;
  107637. private _origin;
  107638. private _radius;
  107639. private _strength;
  107640. private _height;
  107641. private _physicsEngine;
  107642. private _originTop;
  107643. private _centripetalForceThreshold;
  107644. private _updraftMultiplier;
  107645. private _tickCallback;
  107646. private _cylinder;
  107647. private _cylinderPosition;
  107648. private _dataFetched;
  107649. /**
  107650. * Initializes the physics vortex event
  107651. * @param _scene The BabylonJS scene
  107652. * @param _origin The origin position of the vortex
  107653. * @param _radius The radius of the vortex
  107654. * @param _strength The strength of the vortex
  107655. * @param _height The height of the vortex
  107656. */
  107657. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number);
  107658. /**
  107659. * Returns the data related to the vortex event (cylinder).
  107660. * @returns The physics vortex event data
  107661. */
  107662. getData(): PhysicsVortexEventData;
  107663. /**
  107664. * Enables the vortex.
  107665. */
  107666. enable(): void;
  107667. /**
  107668. * Disables the cortex.
  107669. */
  107670. disable(): void;
  107671. /**
  107672. * Disposes the sphere.
  107673. * @param force
  107674. */
  107675. dispose(force?: boolean): void;
  107676. private getImpostorForceAndContactPoint;
  107677. private _tick;
  107678. /*** Helpers ***/
  107679. private _prepareCylinder;
  107680. private _intersectsWithCylinder;
  107681. }
  107682. /**
  107683. * The strenght of the force in correspondence to the distance of the affected object
  107684. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107685. */
  107686. export enum PhysicsRadialImpulseFalloff {
  107687. /** Defines that impulse is constant in strength across it's whole radius */
  107688. Constant = 0,
  107689. /** DEfines that impulse gets weaker if it's further from the origin */
  107690. Linear = 1
  107691. }
  107692. /**
  107693. * The strength of the force in correspondence to the distance of the affected object
  107694. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107695. */
  107696. export enum PhysicsUpdraftMode {
  107697. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  107698. Center = 0,
  107699. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  107700. Perpendicular = 1
  107701. }
  107702. /**
  107703. * Interface for a physics force and contact point
  107704. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107705. */
  107706. export interface PhysicsForceAndContactPoint {
  107707. /**
  107708. * The force applied at the contact point
  107709. */
  107710. force: Vector3;
  107711. /**
  107712. * The contact point
  107713. */
  107714. contactPoint: Vector3;
  107715. }
  107716. /**
  107717. * Interface for radial explosion event data
  107718. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107719. */
  107720. export interface PhysicsRadialExplosionEventData {
  107721. /**
  107722. * A sphere used for the radial explosion event
  107723. */
  107724. sphere: Mesh;
  107725. /**
  107726. * An array of rays for the radial explosion event
  107727. */
  107728. rays: Array<Ray>;
  107729. }
  107730. /**
  107731. * Interface for gravitational field event data
  107732. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107733. */
  107734. export interface PhysicsGravitationalFieldEventData {
  107735. /**
  107736. * A sphere mesh used for the gravitational field event
  107737. */
  107738. sphere: Mesh;
  107739. }
  107740. /**
  107741. * Interface for updraft event data
  107742. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107743. */
  107744. export interface PhysicsUpdraftEventData {
  107745. /**
  107746. * A cylinder used for the updraft event
  107747. */
  107748. cylinder: Mesh;
  107749. }
  107750. /**
  107751. * Interface for vortex event data
  107752. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107753. */
  107754. export interface PhysicsVortexEventData {
  107755. /**
  107756. * A cylinder used for the vortex event
  107757. */
  107758. cylinder: Mesh;
  107759. }
  107760. }
  107761. declare module BABYLON {
  107762. /**
  107763. * AmmoJS Physics plugin
  107764. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107765. * @see https://github.com/kripken/ammo.js/
  107766. */
  107767. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  107768. private _useDeltaForWorldStep;
  107769. /**
  107770. * Reference to the Ammo library
  107771. */
  107772. bjsAMMO: any;
  107773. /**
  107774. * Created ammoJS world which physics bodies are added to
  107775. */
  107776. world: any;
  107777. /**
  107778. * Name of the plugin
  107779. */
  107780. name: string;
  107781. private _timeStep;
  107782. private _fixedTimeStep;
  107783. private _maxSteps;
  107784. private _tmpQuaternion;
  107785. private _tmpAmmoTransform;
  107786. private _tmpAmmoQuaternion;
  107787. private _tmpAmmoConcreteContactResultCallback;
  107788. private _collisionConfiguration;
  107789. private _dispatcher;
  107790. private _overlappingPairCache;
  107791. private _solver;
  107792. private _tmpAmmoVectorA;
  107793. private _tmpAmmoVectorB;
  107794. private _tmpAmmoVectorC;
  107795. private _tmpContactCallbackResult;
  107796. private static readonly DISABLE_COLLISION_FLAG;
  107797. private static readonly KINEMATIC_FLAG;
  107798. private static readonly DISABLE_DEACTIVATION_FLAG;
  107799. /**
  107800. * Initializes the ammoJS plugin
  107801. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  107802. * @param ammoInjection can be used to inject your own ammo reference
  107803. */
  107804. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any);
  107805. /**
  107806. * Sets the gravity of the physics world (m/(s^2))
  107807. * @param gravity Gravity to set
  107808. */
  107809. setGravity(gravity: Vector3): void;
  107810. /**
  107811. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  107812. * @param timeStep timestep to use in seconds
  107813. */
  107814. setTimeStep(timeStep: number): void;
  107815. /**
  107816. * 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)
  107817. * @param fixedTimeStep fixedTimeStep to use in seconds
  107818. */
  107819. setFixedTimeStep(fixedTimeStep: number): void;
  107820. /**
  107821. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  107822. * @param maxSteps the maximum number of steps by the physics engine per frame
  107823. */
  107824. setMaxSteps(maxSteps: number): void;
  107825. /**
  107826. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  107827. * @returns the current timestep in seconds
  107828. */
  107829. getTimeStep(): number;
  107830. private _isImpostorInContact;
  107831. private _isImpostorPairInContact;
  107832. private _stepSimulation;
  107833. /**
  107834. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  107835. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  107836. * After the step the babylon meshes are set to the position of the physics imposters
  107837. * @param delta amount of time to step forward
  107838. * @param impostors array of imposters to update before/after the step
  107839. */
  107840. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  107841. private _tmpVector;
  107842. private _tmpMatrix;
  107843. /**
  107844. * Applies an implulse on the imposter
  107845. * @param impostor imposter to apply impulse
  107846. * @param force amount of force to be applied to the imposter
  107847. * @param contactPoint the location to apply the impulse on the imposter
  107848. */
  107849. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  107850. /**
  107851. * Applies a force on the imposter
  107852. * @param impostor imposter to apply force
  107853. * @param force amount of force to be applied to the imposter
  107854. * @param contactPoint the location to apply the force on the imposter
  107855. */
  107856. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  107857. /**
  107858. * Creates a physics body using the plugin
  107859. * @param impostor the imposter to create the physics body on
  107860. */
  107861. generatePhysicsBody(impostor: PhysicsImpostor): void;
  107862. /**
  107863. * Removes the physics body from the imposter and disposes of the body's memory
  107864. * @param impostor imposter to remove the physics body from
  107865. */
  107866. removePhysicsBody(impostor: PhysicsImpostor): void;
  107867. /**
  107868. * Generates a joint
  107869. * @param impostorJoint the imposter joint to create the joint with
  107870. */
  107871. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  107872. /**
  107873. * Removes a joint
  107874. * @param impostorJoint the imposter joint to remove the joint from
  107875. */
  107876. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  107877. private _addMeshVerts;
  107878. private _createShape;
  107879. /**
  107880. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  107881. * @param impostor imposter containing the physics body and babylon object
  107882. */
  107883. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  107884. /**
  107885. * Sets the babylon object's position/rotation from the physics body's position/rotation
  107886. * @param impostor imposter containing the physics body and babylon object
  107887. * @param newPosition new position
  107888. * @param newRotation new rotation
  107889. */
  107890. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  107891. /**
  107892. * If this plugin is supported
  107893. * @returns true if its supported
  107894. */
  107895. isSupported(): boolean;
  107896. /**
  107897. * Sets the linear velocity of the physics body
  107898. * @param impostor imposter to set the velocity on
  107899. * @param velocity velocity to set
  107900. */
  107901. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  107902. /**
  107903. * Sets the angular velocity of the physics body
  107904. * @param impostor imposter to set the velocity on
  107905. * @param velocity velocity to set
  107906. */
  107907. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  107908. /**
  107909. * gets the linear velocity
  107910. * @param impostor imposter to get linear velocity from
  107911. * @returns linear velocity
  107912. */
  107913. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  107914. /**
  107915. * gets the angular velocity
  107916. * @param impostor imposter to get angular velocity from
  107917. * @returns angular velocity
  107918. */
  107919. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  107920. /**
  107921. * Sets the mass of physics body
  107922. * @param impostor imposter to set the mass on
  107923. * @param mass mass to set
  107924. */
  107925. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  107926. /**
  107927. * Gets the mass of the physics body
  107928. * @param impostor imposter to get the mass from
  107929. * @returns mass
  107930. */
  107931. getBodyMass(impostor: PhysicsImpostor): number;
  107932. /**
  107933. * Gets friction of the impostor
  107934. * @param impostor impostor to get friction from
  107935. * @returns friction value
  107936. */
  107937. getBodyFriction(impostor: PhysicsImpostor): number;
  107938. /**
  107939. * Sets friction of the impostor
  107940. * @param impostor impostor to set friction on
  107941. * @param friction friction value
  107942. */
  107943. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  107944. /**
  107945. * Gets restitution of the impostor
  107946. * @param impostor impostor to get restitution from
  107947. * @returns restitution value
  107948. */
  107949. getBodyRestitution(impostor: PhysicsImpostor): number;
  107950. /**
  107951. * Sets resitution of the impostor
  107952. * @param impostor impostor to set resitution on
  107953. * @param restitution resitution value
  107954. */
  107955. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  107956. /**
  107957. * Sleeps the physics body and stops it from being active
  107958. * @param impostor impostor to sleep
  107959. */
  107960. sleepBody(impostor: PhysicsImpostor): void;
  107961. /**
  107962. * Activates the physics body
  107963. * @param impostor impostor to activate
  107964. */
  107965. wakeUpBody(impostor: PhysicsImpostor): void;
  107966. /**
  107967. * Updates the distance parameters of the joint
  107968. * @param joint joint to update
  107969. * @param maxDistance maximum distance of the joint
  107970. * @param minDistance minimum distance of the joint
  107971. */
  107972. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  107973. /**
  107974. * Sets a motor on the joint
  107975. * @param joint joint to set motor on
  107976. * @param speed speed of the motor
  107977. * @param maxForce maximum force of the motor
  107978. * @param motorIndex index of the motor
  107979. */
  107980. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  107981. /**
  107982. * Sets the motors limit
  107983. * @param joint joint to set limit on
  107984. * @param upperLimit upper limit
  107985. * @param lowerLimit lower limit
  107986. */
  107987. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  107988. /**
  107989. * Syncs the position and rotation of a mesh with the impostor
  107990. * @param mesh mesh to sync
  107991. * @param impostor impostor to update the mesh with
  107992. */
  107993. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  107994. /**
  107995. * Gets the radius of the impostor
  107996. * @param impostor impostor to get radius from
  107997. * @returns the radius
  107998. */
  107999. getRadius(impostor: PhysicsImpostor): number;
  108000. /**
  108001. * Gets the box size of the impostor
  108002. * @param impostor impostor to get box size from
  108003. * @param result the resulting box size
  108004. */
  108005. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  108006. /**
  108007. * Disposes of the impostor
  108008. */
  108009. dispose(): void;
  108010. }
  108011. }
  108012. declare module BABYLON {
  108013. /** @hidden */
  108014. export var blackAndWhitePixelShader: {
  108015. name: string;
  108016. shader: string;
  108017. };
  108018. }
  108019. declare module BABYLON {
  108020. /**
  108021. * Post process used to render in black and white
  108022. */
  108023. export class BlackAndWhitePostProcess extends PostProcess {
  108024. /**
  108025. * Linear about to convert he result to black and white (default: 1)
  108026. */
  108027. degree: number;
  108028. /**
  108029. * Creates a black and white post process
  108030. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  108031. * @param name The name of the effect.
  108032. * @param options The required width/height ratio to downsize to before computing the render pass.
  108033. * @param camera The camera to apply the render pass to.
  108034. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108035. * @param engine The engine which the post process will be applied. (default: current engine)
  108036. * @param reusable If the post process can be reused on the same frame. (default: false)
  108037. */
  108038. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  108039. }
  108040. }
  108041. declare module BABYLON {
  108042. /**
  108043. * This represents a set of one or more post processes in Babylon.
  108044. * A post process can be used to apply a shader to a texture after it is rendered.
  108045. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  108046. */
  108047. export class PostProcessRenderEffect {
  108048. private _postProcesses;
  108049. private _getPostProcesses;
  108050. private _singleInstance;
  108051. private _cameras;
  108052. private _indicesForCamera;
  108053. /**
  108054. * Name of the effect
  108055. * @hidden
  108056. */
  108057. _name: string;
  108058. /**
  108059. * Instantiates a post process render effect.
  108060. * A post process can be used to apply a shader to a texture after it is rendered.
  108061. * @param engine The engine the effect is tied to
  108062. * @param name The name of the effect
  108063. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  108064. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  108065. */
  108066. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  108067. /**
  108068. * Checks if all the post processes in the effect are supported.
  108069. */
  108070. readonly isSupported: boolean;
  108071. /**
  108072. * Updates the current state of the effect
  108073. * @hidden
  108074. */
  108075. _update(): void;
  108076. /**
  108077. * Attaches the effect on cameras
  108078. * @param cameras The camera to attach to.
  108079. * @hidden
  108080. */
  108081. _attachCameras(cameras: Camera): void;
  108082. /**
  108083. * Attaches the effect on cameras
  108084. * @param cameras The camera to attach to.
  108085. * @hidden
  108086. */
  108087. _attachCameras(cameras: Camera[]): void;
  108088. /**
  108089. * Detatches the effect on cameras
  108090. * @param cameras The camera to detatch from.
  108091. * @hidden
  108092. */
  108093. _detachCameras(cameras: Camera): void;
  108094. /**
  108095. * Detatches the effect on cameras
  108096. * @param cameras The camera to detatch from.
  108097. * @hidden
  108098. */
  108099. _detachCameras(cameras: Camera[]): void;
  108100. /**
  108101. * Enables the effect on given cameras
  108102. * @param cameras The camera to enable.
  108103. * @hidden
  108104. */
  108105. _enable(cameras: Camera): void;
  108106. /**
  108107. * Enables the effect on given cameras
  108108. * @param cameras The camera to enable.
  108109. * @hidden
  108110. */
  108111. _enable(cameras: Nullable<Camera[]>): void;
  108112. /**
  108113. * Disables the effect on the given cameras
  108114. * @param cameras The camera to disable.
  108115. * @hidden
  108116. */
  108117. _disable(cameras: Camera): void;
  108118. /**
  108119. * Disables the effect on the given cameras
  108120. * @param cameras The camera to disable.
  108121. * @hidden
  108122. */
  108123. _disable(cameras: Nullable<Camera[]>): void;
  108124. /**
  108125. * Gets a list of the post processes contained in the effect.
  108126. * @param camera The camera to get the post processes on.
  108127. * @returns The list of the post processes in the effect.
  108128. */
  108129. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  108130. }
  108131. }
  108132. declare module BABYLON {
  108133. /** @hidden */
  108134. export var extractHighlightsPixelShader: {
  108135. name: string;
  108136. shader: string;
  108137. };
  108138. }
  108139. declare module BABYLON {
  108140. /**
  108141. * 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.
  108142. */
  108143. export class ExtractHighlightsPostProcess extends PostProcess {
  108144. /**
  108145. * The luminance threshold, pixels below this value will be set to black.
  108146. */
  108147. threshold: number;
  108148. /** @hidden */
  108149. _exposure: number;
  108150. /**
  108151. * Post process which has the input texture to be used when performing highlight extraction
  108152. * @hidden
  108153. */
  108154. _inputPostProcess: Nullable<PostProcess>;
  108155. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  108156. }
  108157. }
  108158. declare module BABYLON {
  108159. /** @hidden */
  108160. export var bloomMergePixelShader: {
  108161. name: string;
  108162. shader: string;
  108163. };
  108164. }
  108165. declare module BABYLON {
  108166. /**
  108167. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  108168. */
  108169. export class BloomMergePostProcess extends PostProcess {
  108170. /** Weight of the bloom to be added to the original input. */
  108171. weight: number;
  108172. /**
  108173. * Creates a new instance of @see BloomMergePostProcess
  108174. * @param name The name of the effect.
  108175. * @param originalFromInput Post process which's input will be used for the merge.
  108176. * @param blurred Blurred highlights post process which's output will be used.
  108177. * @param weight Weight of the bloom to be added to the original input.
  108178. * @param options The required width/height ratio to downsize to before computing the render pass.
  108179. * @param camera The camera to apply the render pass to.
  108180. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108181. * @param engine The engine which the post process will be applied. (default: current engine)
  108182. * @param reusable If the post process can be reused on the same frame. (default: false)
  108183. * @param textureType Type of textures used when performing the post process. (default: 0)
  108184. * @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)
  108185. */
  108186. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  108187. /** Weight of the bloom to be added to the original input. */
  108188. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  108189. }
  108190. }
  108191. declare module BABYLON {
  108192. /**
  108193. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  108194. */
  108195. export class BloomEffect extends PostProcessRenderEffect {
  108196. private bloomScale;
  108197. /**
  108198. * @hidden Internal
  108199. */
  108200. _effects: Array<PostProcess>;
  108201. /**
  108202. * @hidden Internal
  108203. */
  108204. _downscale: ExtractHighlightsPostProcess;
  108205. private _blurX;
  108206. private _blurY;
  108207. private _merge;
  108208. /**
  108209. * The luminance threshold to find bright areas of the image to bloom.
  108210. */
  108211. threshold: number;
  108212. /**
  108213. * The strength of the bloom.
  108214. */
  108215. weight: number;
  108216. /**
  108217. * Specifies the size of the bloom blur kernel, relative to the final output size
  108218. */
  108219. kernel: number;
  108220. /**
  108221. * Creates a new instance of @see BloomEffect
  108222. * @param scene The scene the effect belongs to.
  108223. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  108224. * @param bloomKernel The size of the kernel to be used when applying the blur.
  108225. * @param bloomWeight The the strength of bloom.
  108226. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  108227. * @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)
  108228. */
  108229. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  108230. /**
  108231. * Disposes each of the internal effects for a given camera.
  108232. * @param camera The camera to dispose the effect on.
  108233. */
  108234. disposeEffects(camera: Camera): void;
  108235. /**
  108236. * @hidden Internal
  108237. */
  108238. _updateEffects(): void;
  108239. /**
  108240. * Internal
  108241. * @returns if all the contained post processes are ready.
  108242. * @hidden
  108243. */
  108244. _isReady(): boolean;
  108245. }
  108246. }
  108247. declare module BABYLON {
  108248. /** @hidden */
  108249. export var chromaticAberrationPixelShader: {
  108250. name: string;
  108251. shader: string;
  108252. };
  108253. }
  108254. declare module BABYLON {
  108255. /**
  108256. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  108257. */
  108258. export class ChromaticAberrationPostProcess extends PostProcess {
  108259. /**
  108260. * The amount of seperation of rgb channels (default: 30)
  108261. */
  108262. aberrationAmount: number;
  108263. /**
  108264. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  108265. */
  108266. radialIntensity: number;
  108267. /**
  108268. * 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))
  108269. */
  108270. direction: Vector2;
  108271. /**
  108272. * 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))
  108273. */
  108274. centerPosition: Vector2;
  108275. /**
  108276. * Creates a new instance ChromaticAberrationPostProcess
  108277. * @param name The name of the effect.
  108278. * @param screenWidth The width of the screen to apply the effect on.
  108279. * @param screenHeight The height of the screen to apply the effect on.
  108280. * @param options The required width/height ratio to downsize to before computing the render pass.
  108281. * @param camera The camera to apply the render pass to.
  108282. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108283. * @param engine The engine which the post process will be applied. (default: current engine)
  108284. * @param reusable If the post process can be reused on the same frame. (default: false)
  108285. * @param textureType Type of textures used when performing the post process. (default: 0)
  108286. * @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)
  108287. */
  108288. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  108289. }
  108290. }
  108291. declare module BABYLON {
  108292. /** @hidden */
  108293. export var circleOfConfusionPixelShader: {
  108294. name: string;
  108295. shader: string;
  108296. };
  108297. }
  108298. declare module BABYLON {
  108299. /**
  108300. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  108301. */
  108302. export class CircleOfConfusionPostProcess extends PostProcess {
  108303. /**
  108304. * 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.
  108305. */
  108306. lensSize: number;
  108307. /**
  108308. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  108309. */
  108310. fStop: number;
  108311. /**
  108312. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  108313. */
  108314. focusDistance: number;
  108315. /**
  108316. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  108317. */
  108318. focalLength: number;
  108319. private _depthTexture;
  108320. /**
  108321. * Creates a new instance CircleOfConfusionPostProcess
  108322. * @param name The name of the effect.
  108323. * @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.
  108324. * @param options The required width/height ratio to downsize to before computing the render pass.
  108325. * @param camera The camera to apply the render pass to.
  108326. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108327. * @param engine The engine which the post process will be applied. (default: current engine)
  108328. * @param reusable If the post process can be reused on the same frame. (default: false)
  108329. * @param textureType Type of textures used when performing the post process. (default: 0)
  108330. * @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)
  108331. */
  108332. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  108333. /**
  108334. * 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.
  108335. */
  108336. depthTexture: RenderTargetTexture;
  108337. }
  108338. }
  108339. declare module BABYLON {
  108340. /** @hidden */
  108341. export var colorCorrectionPixelShader: {
  108342. name: string;
  108343. shader: string;
  108344. };
  108345. }
  108346. declare module BABYLON {
  108347. /**
  108348. *
  108349. * This post-process allows the modification of rendered colors by using
  108350. * a 'look-up table' (LUT). This effect is also called Color Grading.
  108351. *
  108352. * The object needs to be provided an url to a texture containing the color
  108353. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  108354. * Use an image editing software to tweak the LUT to match your needs.
  108355. *
  108356. * For an example of a color LUT, see here:
  108357. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  108358. * For explanations on color grading, see here:
  108359. * @see http://udn.epicgames.com/Three/ColorGrading.html
  108360. *
  108361. */
  108362. export class ColorCorrectionPostProcess extends PostProcess {
  108363. private _colorTableTexture;
  108364. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  108365. }
  108366. }
  108367. declare module BABYLON {
  108368. /** @hidden */
  108369. export var convolutionPixelShader: {
  108370. name: string;
  108371. shader: string;
  108372. };
  108373. }
  108374. declare module BABYLON {
  108375. /**
  108376. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  108377. * input texture to perform effects such as edge detection or sharpening
  108378. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  108379. */
  108380. export class ConvolutionPostProcess extends PostProcess {
  108381. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  108382. kernel: number[];
  108383. /**
  108384. * Creates a new instance ConvolutionPostProcess
  108385. * @param name The name of the effect.
  108386. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  108387. * @param options The required width/height ratio to downsize to before computing the render pass.
  108388. * @param camera The camera to apply the render pass to.
  108389. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108390. * @param engine The engine which the post process will be applied. (default: current engine)
  108391. * @param reusable If the post process can be reused on the same frame. (default: false)
  108392. * @param textureType Type of textures used when performing the post process. (default: 0)
  108393. */
  108394. constructor(name: string,
  108395. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  108396. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  108397. /**
  108398. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  108399. */
  108400. static EdgeDetect0Kernel: number[];
  108401. /**
  108402. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  108403. */
  108404. static EdgeDetect1Kernel: number[];
  108405. /**
  108406. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  108407. */
  108408. static EdgeDetect2Kernel: number[];
  108409. /**
  108410. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  108411. */
  108412. static SharpenKernel: number[];
  108413. /**
  108414. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  108415. */
  108416. static EmbossKernel: number[];
  108417. /**
  108418. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  108419. */
  108420. static GaussianKernel: number[];
  108421. }
  108422. }
  108423. declare module BABYLON {
  108424. /**
  108425. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  108426. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  108427. * based on samples that have a large difference in distance than the center pixel.
  108428. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  108429. */
  108430. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  108431. direction: Vector2;
  108432. /**
  108433. * Creates a new instance CircleOfConfusionPostProcess
  108434. * @param name The name of the effect.
  108435. * @param scene The scene the effect belongs to.
  108436. * @param direction The direction the blur should be applied.
  108437. * @param kernel The size of the kernel used to blur.
  108438. * @param options The required width/height ratio to downsize to before computing the render pass.
  108439. * @param camera The camera to apply the render pass to.
  108440. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  108441. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  108442. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108443. * @param engine The engine which the post process will be applied. (default: current engine)
  108444. * @param reusable If the post process can be reused on the same frame. (default: false)
  108445. * @param textureType Type of textures used when performing the post process. (default: 0)
  108446. * @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)
  108447. */
  108448. 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);
  108449. }
  108450. }
  108451. declare module BABYLON {
  108452. /** @hidden */
  108453. export var depthOfFieldMergePixelShader: {
  108454. name: string;
  108455. shader: string;
  108456. };
  108457. }
  108458. declare module BABYLON {
  108459. /**
  108460. * Options to be set when merging outputs from the default pipeline.
  108461. */
  108462. export class DepthOfFieldMergePostProcessOptions {
  108463. /**
  108464. * The original image to merge on top of
  108465. */
  108466. originalFromInput: PostProcess;
  108467. /**
  108468. * Parameters to perform the merge of the depth of field effect
  108469. */
  108470. depthOfField?: {
  108471. circleOfConfusion: PostProcess;
  108472. blurSteps: Array<PostProcess>;
  108473. };
  108474. /**
  108475. * Parameters to perform the merge of bloom effect
  108476. */
  108477. bloom?: {
  108478. blurred: PostProcess;
  108479. weight: number;
  108480. };
  108481. }
  108482. /**
  108483. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  108484. */
  108485. export class DepthOfFieldMergePostProcess extends PostProcess {
  108486. private blurSteps;
  108487. /**
  108488. * Creates a new instance of DepthOfFieldMergePostProcess
  108489. * @param name The name of the effect.
  108490. * @param originalFromInput Post process which's input will be used for the merge.
  108491. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  108492. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  108493. * @param options The required width/height ratio to downsize to before computing the render pass.
  108494. * @param camera The camera to apply the render pass to.
  108495. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108496. * @param engine The engine which the post process will be applied. (default: current engine)
  108497. * @param reusable If the post process can be reused on the same frame. (default: false)
  108498. * @param textureType Type of textures used when performing the post process. (default: 0)
  108499. * @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)
  108500. */
  108501. 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);
  108502. /**
  108503. * Updates the effect with the current post process compile time values and recompiles the shader.
  108504. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  108505. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  108506. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  108507. * @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
  108508. * @param onCompiled Called when the shader has been compiled.
  108509. * @param onError Called if there is an error when compiling a shader.
  108510. */
  108511. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  108512. }
  108513. }
  108514. declare module BABYLON {
  108515. /**
  108516. * Specifies the level of max blur that should be applied when using the depth of field effect
  108517. */
  108518. export enum DepthOfFieldEffectBlurLevel {
  108519. /**
  108520. * Subtle blur
  108521. */
  108522. Low = 0,
  108523. /**
  108524. * Medium blur
  108525. */
  108526. Medium = 1,
  108527. /**
  108528. * Large blur
  108529. */
  108530. High = 2
  108531. }
  108532. /**
  108533. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  108534. */
  108535. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  108536. private _circleOfConfusion;
  108537. /**
  108538. * @hidden Internal, blurs from high to low
  108539. */
  108540. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  108541. private _depthOfFieldBlurY;
  108542. private _dofMerge;
  108543. /**
  108544. * @hidden Internal post processes in depth of field effect
  108545. */
  108546. _effects: Array<PostProcess>;
  108547. /**
  108548. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  108549. */
  108550. focalLength: number;
  108551. /**
  108552. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  108553. */
  108554. fStop: number;
  108555. /**
  108556. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  108557. */
  108558. focusDistance: number;
  108559. /**
  108560. * 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.
  108561. */
  108562. lensSize: number;
  108563. /**
  108564. * Creates a new instance DepthOfFieldEffect
  108565. * @param scene The scene the effect belongs to.
  108566. * @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.
  108567. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  108568. * @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)
  108569. */
  108570. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  108571. /**
  108572. * 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.
  108573. */
  108574. depthTexture: RenderTargetTexture;
  108575. /**
  108576. * Disposes each of the internal effects for a given camera.
  108577. * @param camera The camera to dispose the effect on.
  108578. */
  108579. disposeEffects(camera: Camera): void;
  108580. /**
  108581. * @hidden Internal
  108582. */
  108583. _updateEffects(): void;
  108584. /**
  108585. * Internal
  108586. * @returns if all the contained post processes are ready.
  108587. * @hidden
  108588. */
  108589. _isReady(): boolean;
  108590. }
  108591. }
  108592. declare module BABYLON {
  108593. /** @hidden */
  108594. export var displayPassPixelShader: {
  108595. name: string;
  108596. shader: string;
  108597. };
  108598. }
  108599. declare module BABYLON {
  108600. /**
  108601. * DisplayPassPostProcess which produces an output the same as it's input
  108602. */
  108603. export class DisplayPassPostProcess extends PostProcess {
  108604. /**
  108605. * Creates the DisplayPassPostProcess
  108606. * @param name The name of the effect.
  108607. * @param options The required width/height ratio to downsize to before computing the render pass.
  108608. * @param camera The camera to apply the render pass to.
  108609. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108610. * @param engine The engine which the post process will be applied. (default: current engine)
  108611. * @param reusable If the post process can be reused on the same frame. (default: false)
  108612. */
  108613. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  108614. }
  108615. }
  108616. declare module BABYLON {
  108617. /** @hidden */
  108618. export var filterPixelShader: {
  108619. name: string;
  108620. shader: string;
  108621. };
  108622. }
  108623. declare module BABYLON {
  108624. /**
  108625. * Applies a kernel filter to the image
  108626. */
  108627. export class FilterPostProcess extends PostProcess {
  108628. /** The matrix to be applied to the image */
  108629. kernelMatrix: Matrix;
  108630. /**
  108631. *
  108632. * @param name The name of the effect.
  108633. * @param kernelMatrix The matrix to be applied to the image
  108634. * @param options The required width/height ratio to downsize to before computing the render pass.
  108635. * @param camera The camera to apply the render pass to.
  108636. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108637. * @param engine The engine which the post process will be applied. (default: current engine)
  108638. * @param reusable If the post process can be reused on the same frame. (default: false)
  108639. */
  108640. constructor(name: string,
  108641. /** The matrix to be applied to the image */
  108642. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  108643. }
  108644. }
  108645. declare module BABYLON {
  108646. /** @hidden */
  108647. export var fxaaPixelShader: {
  108648. name: string;
  108649. shader: string;
  108650. };
  108651. }
  108652. declare module BABYLON {
  108653. /** @hidden */
  108654. export var fxaaVertexShader: {
  108655. name: string;
  108656. shader: string;
  108657. };
  108658. }
  108659. declare module BABYLON {
  108660. /**
  108661. * Fxaa post process
  108662. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  108663. */
  108664. export class FxaaPostProcess extends PostProcess {
  108665. /** @hidden */
  108666. texelWidth: number;
  108667. /** @hidden */
  108668. texelHeight: number;
  108669. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  108670. private _getDefines;
  108671. }
  108672. }
  108673. declare module BABYLON {
  108674. /** @hidden */
  108675. export var grainPixelShader: {
  108676. name: string;
  108677. shader: string;
  108678. };
  108679. }
  108680. declare module BABYLON {
  108681. /**
  108682. * The GrainPostProcess adds noise to the image at mid luminance levels
  108683. */
  108684. export class GrainPostProcess extends PostProcess {
  108685. /**
  108686. * The intensity of the grain added (default: 30)
  108687. */
  108688. intensity: number;
  108689. /**
  108690. * If the grain should be randomized on every frame
  108691. */
  108692. animated: boolean;
  108693. /**
  108694. * Creates a new instance of @see GrainPostProcess
  108695. * @param name The name of the effect.
  108696. * @param options The required width/height ratio to downsize to before computing the render pass.
  108697. * @param camera The camera to apply the render pass to.
  108698. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108699. * @param engine The engine which the post process will be applied. (default: current engine)
  108700. * @param reusable If the post process can be reused on the same frame. (default: false)
  108701. * @param textureType Type of textures used when performing the post process. (default: 0)
  108702. * @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)
  108703. */
  108704. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  108705. }
  108706. }
  108707. declare module BABYLON {
  108708. /** @hidden */
  108709. export var highlightsPixelShader: {
  108710. name: string;
  108711. shader: string;
  108712. };
  108713. }
  108714. declare module BABYLON {
  108715. /**
  108716. * Extracts highlights from the image
  108717. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  108718. */
  108719. export class HighlightsPostProcess extends PostProcess {
  108720. /**
  108721. * Extracts highlights from the image
  108722. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  108723. * @param name The name of the effect.
  108724. * @param options The required width/height ratio to downsize to before computing the render pass.
  108725. * @param camera The camera to apply the render pass to.
  108726. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108727. * @param engine The engine which the post process will be applied. (default: current engine)
  108728. * @param reusable If the post process can be reused on the same frame. (default: false)
  108729. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  108730. */
  108731. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  108732. }
  108733. }
  108734. declare module BABYLON {
  108735. /** @hidden */
  108736. export var mrtFragmentDeclaration: {
  108737. name: string;
  108738. shader: string;
  108739. };
  108740. }
  108741. declare module BABYLON {
  108742. /** @hidden */
  108743. export var geometryPixelShader: {
  108744. name: string;
  108745. shader: string;
  108746. };
  108747. }
  108748. declare module BABYLON {
  108749. /** @hidden */
  108750. export var geometryVertexShader: {
  108751. name: string;
  108752. shader: string;
  108753. };
  108754. }
  108755. declare module BABYLON {
  108756. /**
  108757. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  108758. */
  108759. export class GeometryBufferRenderer {
  108760. /**
  108761. * Constant used to retrieve the position texture index in the G-Buffer textures array
  108762. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  108763. */
  108764. static readonly POSITION_TEXTURE_TYPE: number;
  108765. /**
  108766. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  108767. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  108768. */
  108769. static readonly VELOCITY_TEXTURE_TYPE: number;
  108770. /**
  108771. * Dictionary used to store the previous transformation matrices of each rendered mesh
  108772. * in order to compute objects velocities when enableVelocity is set to "true"
  108773. * @hidden
  108774. */
  108775. _previousTransformationMatrices: {
  108776. [index: number]: Matrix;
  108777. };
  108778. private _scene;
  108779. private _multiRenderTarget;
  108780. private _ratio;
  108781. private _enablePosition;
  108782. private _enableVelocity;
  108783. private _positionIndex;
  108784. private _velocityIndex;
  108785. protected _effect: Effect;
  108786. protected _cachedDefines: string;
  108787. /**
  108788. * Set the render list (meshes to be rendered) used in the G buffer.
  108789. */
  108790. renderList: Mesh[];
  108791. /**
  108792. * Gets wether or not G buffer are supported by the running hardware.
  108793. * This requires draw buffer supports
  108794. */
  108795. readonly isSupported: boolean;
  108796. /**
  108797. * Returns the index of the given texture type in the G-Buffer textures array
  108798. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  108799. * @returns the index of the given texture type in the G-Buffer textures array
  108800. */
  108801. getTextureIndex(textureType: number): number;
  108802. /**
  108803. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  108804. */
  108805. /**
  108806. * Sets whether or not objects positions are enabled for the G buffer.
  108807. */
  108808. enablePosition: boolean;
  108809. /**
  108810. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  108811. */
  108812. /**
  108813. * Sets wether or not objects velocities are enabled for the G buffer.
  108814. */
  108815. enableVelocity: boolean;
  108816. /**
  108817. * Gets the scene associated with the buffer.
  108818. */
  108819. readonly scene: Scene;
  108820. /**
  108821. * Gets the ratio used by the buffer during its creation.
  108822. * How big is the buffer related to the main canvas.
  108823. */
  108824. readonly ratio: number;
  108825. /** @hidden */
  108826. static _SceneComponentInitialization: (scene: Scene) => void;
  108827. /**
  108828. * Creates a new G Buffer for the scene
  108829. * @param scene The scene the buffer belongs to
  108830. * @param ratio How big is the buffer related to the main canvas.
  108831. */
  108832. constructor(scene: Scene, ratio?: number);
  108833. /**
  108834. * Checks wether everything is ready to render a submesh to the G buffer.
  108835. * @param subMesh the submesh to check readiness for
  108836. * @param useInstances is the mesh drawn using instance or not
  108837. * @returns true if ready otherwise false
  108838. */
  108839. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  108840. /**
  108841. * Gets the current underlying G Buffer.
  108842. * @returns the buffer
  108843. */
  108844. getGBuffer(): MultiRenderTarget;
  108845. /**
  108846. * Gets the number of samples used to render the buffer (anti aliasing).
  108847. */
  108848. /**
  108849. * Sets the number of samples used to render the buffer (anti aliasing).
  108850. */
  108851. samples: number;
  108852. /**
  108853. * Disposes the renderer and frees up associated resources.
  108854. */
  108855. dispose(): void;
  108856. protected _createRenderTargets(): void;
  108857. }
  108858. }
  108859. declare module BABYLON {
  108860. interface Scene {
  108861. /** @hidden (Backing field) */
  108862. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  108863. /**
  108864. * Gets or Sets the current geometry buffer associated to the scene.
  108865. */
  108866. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  108867. /**
  108868. * Enables a GeometryBufferRender and associates it with the scene
  108869. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  108870. * @returns the GeometryBufferRenderer
  108871. */
  108872. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  108873. /**
  108874. * Disables the GeometryBufferRender associated with the scene
  108875. */
  108876. disableGeometryBufferRenderer(): void;
  108877. }
  108878. /**
  108879. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  108880. * in several rendering techniques.
  108881. */
  108882. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  108883. /**
  108884. * The component name helpful to identify the component in the list of scene components.
  108885. */
  108886. readonly name: string;
  108887. /**
  108888. * The scene the component belongs to.
  108889. */
  108890. scene: Scene;
  108891. /**
  108892. * Creates a new instance of the component for the given scene
  108893. * @param scene Defines the scene to register the component in
  108894. */
  108895. constructor(scene: Scene);
  108896. /**
  108897. * Registers the component in a given scene
  108898. */
  108899. register(): void;
  108900. /**
  108901. * Rebuilds the elements related to this component in case of
  108902. * context lost for instance.
  108903. */
  108904. rebuild(): void;
  108905. /**
  108906. * Disposes the component and the associated ressources
  108907. */
  108908. dispose(): void;
  108909. private _gatherRenderTargets;
  108910. }
  108911. }
  108912. declare module BABYLON {
  108913. /** @hidden */
  108914. export var motionBlurPixelShader: {
  108915. name: string;
  108916. shader: string;
  108917. };
  108918. }
  108919. declare module BABYLON {
  108920. /**
  108921. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  108922. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  108923. * As an example, all you have to do is to create the post-process:
  108924. * var mb = new BABYLON.MotionBlurPostProcess(
  108925. * 'mb', // The name of the effect.
  108926. * scene, // The scene containing the objects to blur according to their velocity.
  108927. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  108928. * camera // The camera to apply the render pass to.
  108929. * );
  108930. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  108931. */
  108932. export class MotionBlurPostProcess extends PostProcess {
  108933. /**
  108934. * Defines how much the image is blurred by the movement. Default value is equal to 1
  108935. */
  108936. motionStrength: number;
  108937. /**
  108938. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  108939. */
  108940. /**
  108941. * Sets the number of iterations to be used for motion blur quality
  108942. */
  108943. motionBlurSamples: number;
  108944. private _motionBlurSamples;
  108945. private _geometryBufferRenderer;
  108946. /**
  108947. * Creates a new instance MotionBlurPostProcess
  108948. * @param name The name of the effect.
  108949. * @param scene The scene containing the objects to blur according to their velocity.
  108950. * @param options The required width/height ratio to downsize to before computing the render pass.
  108951. * @param camera The camera to apply the render pass to.
  108952. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108953. * @param engine The engine which the post process will be applied. (default: current engine)
  108954. * @param reusable If the post process can be reused on the same frame. (default: false)
  108955. * @param textureType Type of textures used when performing the post process. (default: 0)
  108956. * @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)
  108957. */
  108958. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  108959. /**
  108960. * Disposes the post process.
  108961. * @param camera The camera to dispose the post process on.
  108962. */
  108963. dispose(camera?: Camera): void;
  108964. }
  108965. }
  108966. declare module BABYLON {
  108967. /** @hidden */
  108968. export var refractionPixelShader: {
  108969. name: string;
  108970. shader: string;
  108971. };
  108972. }
  108973. declare module BABYLON {
  108974. /**
  108975. * Post process which applies a refractin texture
  108976. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  108977. */
  108978. export class RefractionPostProcess extends PostProcess {
  108979. /** the base color of the refraction (used to taint the rendering) */
  108980. color: Color3;
  108981. /** simulated refraction depth */
  108982. depth: number;
  108983. /** the coefficient of the base color (0 to remove base color tainting) */
  108984. colorLevel: number;
  108985. private _refTexture;
  108986. private _ownRefractionTexture;
  108987. /**
  108988. * Gets or sets the refraction texture
  108989. * Please note that you are responsible for disposing the texture if you set it manually
  108990. */
  108991. refractionTexture: Texture;
  108992. /**
  108993. * Initializes the RefractionPostProcess
  108994. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  108995. * @param name The name of the effect.
  108996. * @param refractionTextureUrl Url of the refraction texture to use
  108997. * @param color the base color of the refraction (used to taint the rendering)
  108998. * @param depth simulated refraction depth
  108999. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  109000. * @param camera The camera to apply the render pass to.
  109001. * @param options The required width/height ratio to downsize to before computing the render pass.
  109002. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  109003. * @param engine The engine which the post process will be applied. (default: current engine)
  109004. * @param reusable If the post process can be reused on the same frame. (default: false)
  109005. */
  109006. constructor(name: string, refractionTextureUrl: string,
  109007. /** the base color of the refraction (used to taint the rendering) */
  109008. color: Color3,
  109009. /** simulated refraction depth */
  109010. depth: number,
  109011. /** the coefficient of the base color (0 to remove base color tainting) */
  109012. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  109013. /**
  109014. * Disposes of the post process
  109015. * @param camera Camera to dispose post process on
  109016. */
  109017. dispose(camera: Camera): void;
  109018. }
  109019. }
  109020. declare module BABYLON {
  109021. /** @hidden */
  109022. export var sharpenPixelShader: {
  109023. name: string;
  109024. shader: string;
  109025. };
  109026. }
  109027. declare module BABYLON {
  109028. /**
  109029. * The SharpenPostProcess applies a sharpen kernel to every pixel
  109030. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  109031. */
  109032. export class SharpenPostProcess extends PostProcess {
  109033. /**
  109034. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  109035. */
  109036. colorAmount: number;
  109037. /**
  109038. * How much sharpness should be applied (default: 0.3)
  109039. */
  109040. edgeAmount: number;
  109041. /**
  109042. * Creates a new instance ConvolutionPostProcess
  109043. * @param name The name of the effect.
  109044. * @param options The required width/height ratio to downsize to before computing the render pass.
  109045. * @param camera The camera to apply the render pass to.
  109046. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  109047. * @param engine The engine which the post process will be applied. (default: current engine)
  109048. * @param reusable If the post process can be reused on the same frame. (default: false)
  109049. * @param textureType Type of textures used when performing the post process. (default: 0)
  109050. * @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)
  109051. */
  109052. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  109053. }
  109054. }
  109055. declare module BABYLON {
  109056. /**
  109057. * PostProcessRenderPipeline
  109058. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  109059. */
  109060. export class PostProcessRenderPipeline {
  109061. private engine;
  109062. private _renderEffects;
  109063. private _renderEffectsForIsolatedPass;
  109064. /**
  109065. * @hidden
  109066. */
  109067. protected _cameras: Camera[];
  109068. /** @hidden */
  109069. _name: string;
  109070. /**
  109071. * Gets pipeline name
  109072. */
  109073. readonly name: string;
  109074. /**
  109075. * Initializes a PostProcessRenderPipeline
  109076. * @param engine engine to add the pipeline to
  109077. * @param name name of the pipeline
  109078. */
  109079. constructor(engine: Engine, name: string);
  109080. /**
  109081. * Gets the class name
  109082. * @returns "PostProcessRenderPipeline"
  109083. */
  109084. getClassName(): string;
  109085. /**
  109086. * If all the render effects in the pipeline are supported
  109087. */
  109088. readonly isSupported: boolean;
  109089. /**
  109090. * Adds an effect to the pipeline
  109091. * @param renderEffect the effect to add
  109092. */
  109093. addEffect(renderEffect: PostProcessRenderEffect): void;
  109094. /** @hidden */
  109095. _rebuild(): void;
  109096. /** @hidden */
  109097. _enableEffect(renderEffectName: string, cameras: Camera): void;
  109098. /** @hidden */
  109099. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  109100. /** @hidden */
  109101. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  109102. /** @hidden */
  109103. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  109104. /** @hidden */
  109105. _attachCameras(cameras: Camera, unique: boolean): void;
  109106. /** @hidden */
  109107. _attachCameras(cameras: Camera[], unique: boolean): void;
  109108. /** @hidden */
  109109. _detachCameras(cameras: Camera): void;
  109110. /** @hidden */
  109111. _detachCameras(cameras: Nullable<Camera[]>): void;
  109112. /** @hidden */
  109113. _update(): void;
  109114. /** @hidden */
  109115. _reset(): void;
  109116. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  109117. /**
  109118. * Disposes of the pipeline
  109119. */
  109120. dispose(): void;
  109121. }
  109122. }
  109123. declare module BABYLON {
  109124. /**
  109125. * PostProcessRenderPipelineManager class
  109126. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  109127. */
  109128. export class PostProcessRenderPipelineManager {
  109129. private _renderPipelines;
  109130. /**
  109131. * Initializes a PostProcessRenderPipelineManager
  109132. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  109133. */
  109134. constructor();
  109135. /**
  109136. * Gets the list of supported render pipelines
  109137. */
  109138. readonly supportedPipelines: PostProcessRenderPipeline[];
  109139. /**
  109140. * Adds a pipeline to the manager
  109141. * @param renderPipeline The pipeline to add
  109142. */
  109143. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  109144. /**
  109145. * Attaches a camera to the pipeline
  109146. * @param renderPipelineName The name of the pipeline to attach to
  109147. * @param cameras the camera to attach
  109148. * @param unique if the camera can be attached multiple times to the pipeline
  109149. */
  109150. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  109151. /**
  109152. * Detaches a camera from the pipeline
  109153. * @param renderPipelineName The name of the pipeline to detach from
  109154. * @param cameras the camera to detach
  109155. */
  109156. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  109157. /**
  109158. * Enables an effect by name on a pipeline
  109159. * @param renderPipelineName the name of the pipeline to enable the effect in
  109160. * @param renderEffectName the name of the effect to enable
  109161. * @param cameras the cameras that the effect should be enabled on
  109162. */
  109163. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  109164. /**
  109165. * Disables an effect by name on a pipeline
  109166. * @param renderPipelineName the name of the pipeline to disable the effect in
  109167. * @param renderEffectName the name of the effect to disable
  109168. * @param cameras the cameras that the effect should be disabled on
  109169. */
  109170. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  109171. /**
  109172. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  109173. */
  109174. update(): void;
  109175. /** @hidden */
  109176. _rebuild(): void;
  109177. /**
  109178. * Disposes of the manager and pipelines
  109179. */
  109180. dispose(): void;
  109181. }
  109182. }
  109183. declare module BABYLON {
  109184. interface Scene {
  109185. /** @hidden (Backing field) */
  109186. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  109187. /**
  109188. * Gets the postprocess render pipeline manager
  109189. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  109190. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  109191. */
  109192. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  109193. }
  109194. /**
  109195. * Defines the Render Pipeline scene component responsible to rendering pipelines
  109196. */
  109197. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  109198. /**
  109199. * The component name helpfull to identify the component in the list of scene components.
  109200. */
  109201. readonly name: string;
  109202. /**
  109203. * The scene the component belongs to.
  109204. */
  109205. scene: Scene;
  109206. /**
  109207. * Creates a new instance of the component for the given scene
  109208. * @param scene Defines the scene to register the component in
  109209. */
  109210. constructor(scene: Scene);
  109211. /**
  109212. * Registers the component in a given scene
  109213. */
  109214. register(): void;
  109215. /**
  109216. * Rebuilds the elements related to this component in case of
  109217. * context lost for instance.
  109218. */
  109219. rebuild(): void;
  109220. /**
  109221. * Disposes the component and the associated ressources
  109222. */
  109223. dispose(): void;
  109224. private _gatherRenderTargets;
  109225. }
  109226. }
  109227. declare module BABYLON {
  109228. /**
  109229. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  109230. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  109231. */
  109232. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  109233. private _scene;
  109234. private _camerasToBeAttached;
  109235. /**
  109236. * ID of the sharpen post process,
  109237. */
  109238. private readonly SharpenPostProcessId;
  109239. /**
  109240. * @ignore
  109241. * ID of the image processing post process;
  109242. */
  109243. readonly ImageProcessingPostProcessId: string;
  109244. /**
  109245. * @ignore
  109246. * ID of the Fast Approximate Anti-Aliasing post process;
  109247. */
  109248. readonly FxaaPostProcessId: string;
  109249. /**
  109250. * ID of the chromatic aberration post process,
  109251. */
  109252. private readonly ChromaticAberrationPostProcessId;
  109253. /**
  109254. * ID of the grain post process
  109255. */
  109256. private readonly GrainPostProcessId;
  109257. /**
  109258. * Sharpen post process which will apply a sharpen convolution to enhance edges
  109259. */
  109260. sharpen: SharpenPostProcess;
  109261. private _sharpenEffect;
  109262. private bloom;
  109263. /**
  109264. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  109265. */
  109266. depthOfField: DepthOfFieldEffect;
  109267. /**
  109268. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  109269. */
  109270. fxaa: FxaaPostProcess;
  109271. /**
  109272. * Image post processing pass used to perform operations such as tone mapping or color grading.
  109273. */
  109274. imageProcessing: ImageProcessingPostProcess;
  109275. /**
  109276. * Chromatic aberration post process which will shift rgb colors in the image
  109277. */
  109278. chromaticAberration: ChromaticAberrationPostProcess;
  109279. private _chromaticAberrationEffect;
  109280. /**
  109281. * Grain post process which add noise to the image
  109282. */
  109283. grain: GrainPostProcess;
  109284. private _grainEffect;
  109285. /**
  109286. * Glow post process which adds a glow to emissive areas of the image
  109287. */
  109288. private _glowLayer;
  109289. /**
  109290. * Animations which can be used to tweak settings over a period of time
  109291. */
  109292. animations: Animation[];
  109293. private _imageProcessingConfigurationObserver;
  109294. private _sharpenEnabled;
  109295. private _bloomEnabled;
  109296. private _depthOfFieldEnabled;
  109297. private _depthOfFieldBlurLevel;
  109298. private _fxaaEnabled;
  109299. private _imageProcessingEnabled;
  109300. private _defaultPipelineTextureType;
  109301. private _bloomScale;
  109302. private _chromaticAberrationEnabled;
  109303. private _grainEnabled;
  109304. private _buildAllowed;
  109305. /**
  109306. * Gets active scene
  109307. */
  109308. readonly scene: Scene;
  109309. /**
  109310. * Enable or disable the sharpen process from the pipeline
  109311. */
  109312. sharpenEnabled: boolean;
  109313. private _resizeObserver;
  109314. private _hardwareScaleLevel;
  109315. private _bloomKernel;
  109316. /**
  109317. * Specifies the size of the bloom blur kernel, relative to the final output size
  109318. */
  109319. bloomKernel: number;
  109320. /**
  109321. * Specifies the weight of the bloom in the final rendering
  109322. */
  109323. private _bloomWeight;
  109324. /**
  109325. * Specifies the luma threshold for the area that will be blurred by the bloom
  109326. */
  109327. private _bloomThreshold;
  109328. private _hdr;
  109329. /**
  109330. * The strength of the bloom.
  109331. */
  109332. bloomWeight: number;
  109333. /**
  109334. * The strength of the bloom.
  109335. */
  109336. bloomThreshold: number;
  109337. /**
  109338. * The scale of the bloom, lower value will provide better performance.
  109339. */
  109340. bloomScale: number;
  109341. /**
  109342. * Enable or disable the bloom from the pipeline
  109343. */
  109344. bloomEnabled: boolean;
  109345. private _rebuildBloom;
  109346. /**
  109347. * If the depth of field is enabled.
  109348. */
  109349. depthOfFieldEnabled: boolean;
  109350. /**
  109351. * Blur level of the depth of field effect. (Higher blur will effect performance)
  109352. */
  109353. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  109354. /**
  109355. * If the anti aliasing is enabled.
  109356. */
  109357. fxaaEnabled: boolean;
  109358. private _samples;
  109359. /**
  109360. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  109361. */
  109362. samples: number;
  109363. /**
  109364. * If image processing is enabled.
  109365. */
  109366. imageProcessingEnabled: boolean;
  109367. /**
  109368. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  109369. */
  109370. glowLayerEnabled: boolean;
  109371. /**
  109372. * Enable or disable the chromaticAberration process from the pipeline
  109373. */
  109374. chromaticAberrationEnabled: boolean;
  109375. /**
  109376. * Enable or disable the grain process from the pipeline
  109377. */
  109378. grainEnabled: boolean;
  109379. /**
  109380. * @constructor
  109381. * @param name - The rendering pipeline name (default: "")
  109382. * @param hdr - If high dynamic range textures should be used (default: true)
  109383. * @param scene - The scene linked to this pipeline (default: the last created scene)
  109384. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  109385. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  109386. */
  109387. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  109388. /**
  109389. * Get the class name
  109390. * @returns "DefaultRenderingPipeline"
  109391. */
  109392. getClassName(): string;
  109393. /**
  109394. * Force the compilation of the entire pipeline.
  109395. */
  109396. prepare(): void;
  109397. private _hasCleared;
  109398. private _prevPostProcess;
  109399. private _prevPrevPostProcess;
  109400. private _setAutoClearAndTextureSharing;
  109401. private _depthOfFieldSceneObserver;
  109402. private _buildPipeline;
  109403. private _disposePostProcesses;
  109404. /**
  109405. * Adds a camera to the pipeline
  109406. * @param camera the camera to be added
  109407. */
  109408. addCamera(camera: Camera): void;
  109409. /**
  109410. * Removes a camera from the pipeline
  109411. * @param camera the camera to remove
  109412. */
  109413. removeCamera(camera: Camera): void;
  109414. /**
  109415. * Dispose of the pipeline and stop all post processes
  109416. */
  109417. dispose(): void;
  109418. /**
  109419. * Serialize the rendering pipeline (Used when exporting)
  109420. * @returns the serialized object
  109421. */
  109422. serialize(): any;
  109423. /**
  109424. * Parse the serialized pipeline
  109425. * @param source Source pipeline.
  109426. * @param scene The scene to load the pipeline to.
  109427. * @param rootUrl The URL of the serialized pipeline.
  109428. * @returns An instantiated pipeline from the serialized object.
  109429. */
  109430. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  109431. }
  109432. }
  109433. declare module BABYLON {
  109434. /** @hidden */
  109435. export var lensHighlightsPixelShader: {
  109436. name: string;
  109437. shader: string;
  109438. };
  109439. }
  109440. declare module BABYLON {
  109441. /** @hidden */
  109442. export var depthOfFieldPixelShader: {
  109443. name: string;
  109444. shader: string;
  109445. };
  109446. }
  109447. declare module BABYLON {
  109448. /**
  109449. * BABYLON.JS Chromatic Aberration GLSL Shader
  109450. * Author: Olivier Guyot
  109451. * Separates very slightly R, G and B colors on the edges of the screen
  109452. * Inspired by Francois Tarlier & Martins Upitis
  109453. */
  109454. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  109455. /**
  109456. * @ignore
  109457. * The chromatic aberration PostProcess id in the pipeline
  109458. */
  109459. LensChromaticAberrationEffect: string;
  109460. /**
  109461. * @ignore
  109462. * The highlights enhancing PostProcess id in the pipeline
  109463. */
  109464. HighlightsEnhancingEffect: string;
  109465. /**
  109466. * @ignore
  109467. * The depth-of-field PostProcess id in the pipeline
  109468. */
  109469. LensDepthOfFieldEffect: string;
  109470. private _scene;
  109471. private _depthTexture;
  109472. private _grainTexture;
  109473. private _chromaticAberrationPostProcess;
  109474. private _highlightsPostProcess;
  109475. private _depthOfFieldPostProcess;
  109476. private _edgeBlur;
  109477. private _grainAmount;
  109478. private _chromaticAberration;
  109479. private _distortion;
  109480. private _highlightsGain;
  109481. private _highlightsThreshold;
  109482. private _dofDistance;
  109483. private _dofAperture;
  109484. private _dofDarken;
  109485. private _dofPentagon;
  109486. private _blurNoise;
  109487. /**
  109488. * @constructor
  109489. *
  109490. * Effect parameters are as follow:
  109491. * {
  109492. * chromatic_aberration: number; // from 0 to x (1 for realism)
  109493. * edge_blur: number; // from 0 to x (1 for realism)
  109494. * distortion: number; // from 0 to x (1 for realism)
  109495. * grain_amount: number; // from 0 to 1
  109496. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  109497. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  109498. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  109499. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  109500. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  109501. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  109502. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  109503. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  109504. * }
  109505. * Note: if an effect parameter is unset, effect is disabled
  109506. *
  109507. * @param name The rendering pipeline name
  109508. * @param parameters - An object containing all parameters (see above)
  109509. * @param scene The scene linked to this pipeline
  109510. * @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)
  109511. * @param cameras The array of cameras that the rendering pipeline will be attached to
  109512. */
  109513. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  109514. /**
  109515. * Sets the amount of blur at the edges
  109516. * @param amount blur amount
  109517. */
  109518. setEdgeBlur(amount: number): void;
  109519. /**
  109520. * Sets edge blur to 0
  109521. */
  109522. disableEdgeBlur(): void;
  109523. /**
  109524. * Sets the amout of grain
  109525. * @param amount Amount of grain
  109526. */
  109527. setGrainAmount(amount: number): void;
  109528. /**
  109529. * Set grain amount to 0
  109530. */
  109531. disableGrain(): void;
  109532. /**
  109533. * Sets the chromatic aberration amount
  109534. * @param amount amount of chromatic aberration
  109535. */
  109536. setChromaticAberration(amount: number): void;
  109537. /**
  109538. * Sets chromatic aberration amount to 0
  109539. */
  109540. disableChromaticAberration(): void;
  109541. /**
  109542. * Sets the EdgeDistortion amount
  109543. * @param amount amount of EdgeDistortion
  109544. */
  109545. setEdgeDistortion(amount: number): void;
  109546. /**
  109547. * Sets edge distortion to 0
  109548. */
  109549. disableEdgeDistortion(): void;
  109550. /**
  109551. * Sets the FocusDistance amount
  109552. * @param amount amount of FocusDistance
  109553. */
  109554. setFocusDistance(amount: number): void;
  109555. /**
  109556. * Disables depth of field
  109557. */
  109558. disableDepthOfField(): void;
  109559. /**
  109560. * Sets the Aperture amount
  109561. * @param amount amount of Aperture
  109562. */
  109563. setAperture(amount: number): void;
  109564. /**
  109565. * Sets the DarkenOutOfFocus amount
  109566. * @param amount amount of DarkenOutOfFocus
  109567. */
  109568. setDarkenOutOfFocus(amount: number): void;
  109569. /**
  109570. * Creates a pentagon bokeh effect
  109571. */
  109572. enablePentagonBokeh(): void;
  109573. /**
  109574. * Disables the pentagon bokeh effect
  109575. */
  109576. disablePentagonBokeh(): void;
  109577. /**
  109578. * Enables noise blur
  109579. */
  109580. enableNoiseBlur(): void;
  109581. /**
  109582. * Disables noise blur
  109583. */
  109584. disableNoiseBlur(): void;
  109585. /**
  109586. * Sets the HighlightsGain amount
  109587. * @param amount amount of HighlightsGain
  109588. */
  109589. setHighlightsGain(amount: number): void;
  109590. /**
  109591. * Sets the HighlightsThreshold amount
  109592. * @param amount amount of HighlightsThreshold
  109593. */
  109594. setHighlightsThreshold(amount: number): void;
  109595. /**
  109596. * Disables highlights
  109597. */
  109598. disableHighlights(): void;
  109599. /**
  109600. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  109601. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  109602. */
  109603. dispose(disableDepthRender?: boolean): void;
  109604. private _createChromaticAberrationPostProcess;
  109605. private _createHighlightsPostProcess;
  109606. private _createDepthOfFieldPostProcess;
  109607. private _createGrainTexture;
  109608. }
  109609. }
  109610. declare module BABYLON {
  109611. /** @hidden */
  109612. export var ssao2PixelShader: {
  109613. name: string;
  109614. shader: string;
  109615. };
  109616. }
  109617. declare module BABYLON {
  109618. /** @hidden */
  109619. export var ssaoCombinePixelShader: {
  109620. name: string;
  109621. shader: string;
  109622. };
  109623. }
  109624. declare module BABYLON {
  109625. /**
  109626. * Render pipeline to produce ssao effect
  109627. */
  109628. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  109629. /**
  109630. * @ignore
  109631. * The PassPostProcess id in the pipeline that contains the original scene color
  109632. */
  109633. SSAOOriginalSceneColorEffect: string;
  109634. /**
  109635. * @ignore
  109636. * The SSAO PostProcess id in the pipeline
  109637. */
  109638. SSAORenderEffect: string;
  109639. /**
  109640. * @ignore
  109641. * The horizontal blur PostProcess id in the pipeline
  109642. */
  109643. SSAOBlurHRenderEffect: string;
  109644. /**
  109645. * @ignore
  109646. * The vertical blur PostProcess id in the pipeline
  109647. */
  109648. SSAOBlurVRenderEffect: string;
  109649. /**
  109650. * @ignore
  109651. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  109652. */
  109653. SSAOCombineRenderEffect: string;
  109654. /**
  109655. * The output strength of the SSAO post-process. Default value is 1.0.
  109656. */
  109657. totalStrength: number;
  109658. /**
  109659. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  109660. */
  109661. maxZ: number;
  109662. /**
  109663. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  109664. */
  109665. minZAspect: number;
  109666. private _samples;
  109667. /**
  109668. * Number of samples used for the SSAO calculations. Default value is 8
  109669. */
  109670. samples: number;
  109671. private _textureSamples;
  109672. /**
  109673. * Number of samples to use for antialiasing
  109674. */
  109675. textureSamples: number;
  109676. /**
  109677. * Ratio object used for SSAO ratio and blur ratio
  109678. */
  109679. private _ratio;
  109680. /**
  109681. * Dynamically generated sphere sampler.
  109682. */
  109683. private _sampleSphere;
  109684. /**
  109685. * Blur filter offsets
  109686. */
  109687. private _samplerOffsets;
  109688. private _expensiveBlur;
  109689. /**
  109690. * If bilateral blur should be used
  109691. */
  109692. expensiveBlur: boolean;
  109693. /**
  109694. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  109695. */
  109696. radius: number;
  109697. /**
  109698. * The base color of the SSAO post-process
  109699. * The final result is "base + ssao" between [0, 1]
  109700. */
  109701. base: number;
  109702. /**
  109703. * Support test.
  109704. */
  109705. static readonly IsSupported: boolean;
  109706. private _scene;
  109707. private _depthTexture;
  109708. private _normalTexture;
  109709. private _randomTexture;
  109710. private _originalColorPostProcess;
  109711. private _ssaoPostProcess;
  109712. private _blurHPostProcess;
  109713. private _blurVPostProcess;
  109714. private _ssaoCombinePostProcess;
  109715. private _firstUpdate;
  109716. /**
  109717. * Gets active scene
  109718. */
  109719. readonly scene: Scene;
  109720. /**
  109721. * @constructor
  109722. * @param name The rendering pipeline name
  109723. * @param scene The scene linked to this pipeline
  109724. * @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 }
  109725. * @param cameras The array of cameras that the rendering pipeline will be attached to
  109726. */
  109727. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  109728. /**
  109729. * Get the class name
  109730. * @returns "SSAO2RenderingPipeline"
  109731. */
  109732. getClassName(): string;
  109733. /**
  109734. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  109735. */
  109736. dispose(disableGeometryBufferRenderer?: boolean): void;
  109737. private _createBlurPostProcess;
  109738. /** @hidden */
  109739. _rebuild(): void;
  109740. private _bits;
  109741. private _radicalInverse_VdC;
  109742. private _hammersley;
  109743. private _hemisphereSample_uniform;
  109744. private _generateHemisphere;
  109745. private _createSSAOPostProcess;
  109746. private _createSSAOCombinePostProcess;
  109747. private _createRandomTexture;
  109748. /**
  109749. * Serialize the rendering pipeline (Used when exporting)
  109750. * @returns the serialized object
  109751. */
  109752. serialize(): any;
  109753. /**
  109754. * Parse the serialized pipeline
  109755. * @param source Source pipeline.
  109756. * @param scene The scene to load the pipeline to.
  109757. * @param rootUrl The URL of the serialized pipeline.
  109758. * @returns An instantiated pipeline from the serialized object.
  109759. */
  109760. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  109761. }
  109762. }
  109763. declare module BABYLON {
  109764. /** @hidden */
  109765. export var ssaoPixelShader: {
  109766. name: string;
  109767. shader: string;
  109768. };
  109769. }
  109770. declare module BABYLON {
  109771. /**
  109772. * Render pipeline to produce ssao effect
  109773. */
  109774. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  109775. /**
  109776. * @ignore
  109777. * The PassPostProcess id in the pipeline that contains the original scene color
  109778. */
  109779. SSAOOriginalSceneColorEffect: string;
  109780. /**
  109781. * @ignore
  109782. * The SSAO PostProcess id in the pipeline
  109783. */
  109784. SSAORenderEffect: string;
  109785. /**
  109786. * @ignore
  109787. * The horizontal blur PostProcess id in the pipeline
  109788. */
  109789. SSAOBlurHRenderEffect: string;
  109790. /**
  109791. * @ignore
  109792. * The vertical blur PostProcess id in the pipeline
  109793. */
  109794. SSAOBlurVRenderEffect: string;
  109795. /**
  109796. * @ignore
  109797. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  109798. */
  109799. SSAOCombineRenderEffect: string;
  109800. /**
  109801. * The output strength of the SSAO post-process. Default value is 1.0.
  109802. */
  109803. totalStrength: number;
  109804. /**
  109805. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  109806. */
  109807. radius: number;
  109808. /**
  109809. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  109810. * Must not be equal to fallOff and superior to fallOff.
  109811. * Default value is 0.0075
  109812. */
  109813. area: number;
  109814. /**
  109815. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  109816. * Must not be equal to area and inferior to area.
  109817. * Default value is 0.000001
  109818. */
  109819. fallOff: number;
  109820. /**
  109821. * The base color of the SSAO post-process
  109822. * The final result is "base + ssao" between [0, 1]
  109823. */
  109824. base: number;
  109825. private _scene;
  109826. private _depthTexture;
  109827. private _randomTexture;
  109828. private _originalColorPostProcess;
  109829. private _ssaoPostProcess;
  109830. private _blurHPostProcess;
  109831. private _blurVPostProcess;
  109832. private _ssaoCombinePostProcess;
  109833. private _firstUpdate;
  109834. /**
  109835. * Gets active scene
  109836. */
  109837. readonly scene: Scene;
  109838. /**
  109839. * @constructor
  109840. * @param name - The rendering pipeline name
  109841. * @param scene - The scene linked to this pipeline
  109842. * @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 }
  109843. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  109844. */
  109845. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  109846. /**
  109847. * Get the class name
  109848. * @returns "SSAORenderingPipeline"
  109849. */
  109850. getClassName(): string;
  109851. /**
  109852. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  109853. */
  109854. dispose(disableDepthRender?: boolean): void;
  109855. private _createBlurPostProcess;
  109856. /** @hidden */
  109857. _rebuild(): void;
  109858. private _createSSAOPostProcess;
  109859. private _createSSAOCombinePostProcess;
  109860. private _createRandomTexture;
  109861. }
  109862. }
  109863. declare module BABYLON {
  109864. /** @hidden */
  109865. export var standardPixelShader: {
  109866. name: string;
  109867. shader: string;
  109868. };
  109869. }
  109870. declare module BABYLON {
  109871. /**
  109872. * Standard rendering pipeline
  109873. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  109874. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  109875. */
  109876. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  109877. /**
  109878. * Public members
  109879. */
  109880. /**
  109881. * Post-process which contains the original scene color before the pipeline applies all the effects
  109882. */
  109883. originalPostProcess: Nullable<PostProcess>;
  109884. /**
  109885. * Post-process used to down scale an image x4
  109886. */
  109887. downSampleX4PostProcess: Nullable<PostProcess>;
  109888. /**
  109889. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  109890. */
  109891. brightPassPostProcess: Nullable<PostProcess>;
  109892. /**
  109893. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  109894. */
  109895. blurHPostProcesses: PostProcess[];
  109896. /**
  109897. * Post-process array storing all the vertical blur post-processes used by the pipeline
  109898. */
  109899. blurVPostProcesses: PostProcess[];
  109900. /**
  109901. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  109902. */
  109903. textureAdderPostProcess: Nullable<PostProcess>;
  109904. /**
  109905. * Post-process used to create volumetric lighting effect
  109906. */
  109907. volumetricLightPostProcess: Nullable<PostProcess>;
  109908. /**
  109909. * Post-process used to smooth the previous volumetric light post-process on the X axis
  109910. */
  109911. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  109912. /**
  109913. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  109914. */
  109915. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  109916. /**
  109917. * Post-process used to merge the volumetric light effect and the real scene color
  109918. */
  109919. volumetricLightMergePostProces: Nullable<PostProcess>;
  109920. /**
  109921. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  109922. */
  109923. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  109924. /**
  109925. * Base post-process used to calculate the average luminance of the final image for HDR
  109926. */
  109927. luminancePostProcess: Nullable<PostProcess>;
  109928. /**
  109929. * Post-processes used to create down sample post-processes in order to get
  109930. * the average luminance of the final image for HDR
  109931. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  109932. */
  109933. luminanceDownSamplePostProcesses: PostProcess[];
  109934. /**
  109935. * Post-process used to create a HDR effect (light adaptation)
  109936. */
  109937. hdrPostProcess: Nullable<PostProcess>;
  109938. /**
  109939. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  109940. */
  109941. textureAdderFinalPostProcess: Nullable<PostProcess>;
  109942. /**
  109943. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  109944. */
  109945. lensFlareFinalPostProcess: Nullable<PostProcess>;
  109946. /**
  109947. * Post-process used to merge the final HDR post-process and the real scene color
  109948. */
  109949. hdrFinalPostProcess: Nullable<PostProcess>;
  109950. /**
  109951. * Post-process used to create a lens flare effect
  109952. */
  109953. lensFlarePostProcess: Nullable<PostProcess>;
  109954. /**
  109955. * Post-process that merges the result of the lens flare post-process and the real scene color
  109956. */
  109957. lensFlareComposePostProcess: Nullable<PostProcess>;
  109958. /**
  109959. * Post-process used to create a motion blur effect
  109960. */
  109961. motionBlurPostProcess: Nullable<PostProcess>;
  109962. /**
  109963. * Post-process used to create a depth of field effect
  109964. */
  109965. depthOfFieldPostProcess: Nullable<PostProcess>;
  109966. /**
  109967. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  109968. */
  109969. fxaaPostProcess: Nullable<FxaaPostProcess>;
  109970. /**
  109971. * Represents the brightness threshold in order to configure the illuminated surfaces
  109972. */
  109973. brightThreshold: number;
  109974. /**
  109975. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  109976. */
  109977. blurWidth: number;
  109978. /**
  109979. * Sets if the blur for highlighted surfaces must be only horizontal
  109980. */
  109981. horizontalBlur: boolean;
  109982. /**
  109983. * Sets the overall exposure used by the pipeline
  109984. */
  109985. exposure: number;
  109986. /**
  109987. * Texture used typically to simulate "dirty" on camera lens
  109988. */
  109989. lensTexture: Nullable<Texture>;
  109990. /**
  109991. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  109992. */
  109993. volumetricLightCoefficient: number;
  109994. /**
  109995. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  109996. */
  109997. volumetricLightPower: number;
  109998. /**
  109999. * Used the set the blur intensity to smooth the volumetric lights
  110000. */
  110001. volumetricLightBlurScale: number;
  110002. /**
  110003. * Light (spot or directional) used to generate the volumetric lights rays
  110004. * The source light must have a shadow generate so the pipeline can get its
  110005. * depth map
  110006. */
  110007. sourceLight: Nullable<SpotLight | DirectionalLight>;
  110008. /**
  110009. * For eye adaptation, represents the minimum luminance the eye can see
  110010. */
  110011. hdrMinimumLuminance: number;
  110012. /**
  110013. * For eye adaptation, represents the decrease luminance speed
  110014. */
  110015. hdrDecreaseRate: number;
  110016. /**
  110017. * For eye adaptation, represents the increase luminance speed
  110018. */
  110019. hdrIncreaseRate: number;
  110020. /**
  110021. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  110022. */
  110023. lensColorTexture: Nullable<Texture>;
  110024. /**
  110025. * The overall strengh for the lens flare effect
  110026. */
  110027. lensFlareStrength: number;
  110028. /**
  110029. * Dispersion coefficient for lens flare ghosts
  110030. */
  110031. lensFlareGhostDispersal: number;
  110032. /**
  110033. * Main lens flare halo width
  110034. */
  110035. lensFlareHaloWidth: number;
  110036. /**
  110037. * Based on the lens distortion effect, defines how much the lens flare result
  110038. * is distorted
  110039. */
  110040. lensFlareDistortionStrength: number;
  110041. /**
  110042. * Lens star texture must be used to simulate rays on the flares and is available
  110043. * in the documentation
  110044. */
  110045. lensStarTexture: Nullable<Texture>;
  110046. /**
  110047. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  110048. * flare effect by taking account of the dirt texture
  110049. */
  110050. lensFlareDirtTexture: Nullable<Texture>;
  110051. /**
  110052. * Represents the focal length for the depth of field effect
  110053. */
  110054. depthOfFieldDistance: number;
  110055. /**
  110056. * Represents the blur intensity for the blurred part of the depth of field effect
  110057. */
  110058. depthOfFieldBlurWidth: number;
  110059. /**
  110060. * For motion blur, defines how much the image is blurred by the movement
  110061. */
  110062. motionStrength: number;
  110063. /**
  110064. * List of animations for the pipeline (IAnimatable implementation)
  110065. */
  110066. animations: Animation[];
  110067. /**
  110068. * Private members
  110069. */
  110070. private _scene;
  110071. private _currentDepthOfFieldSource;
  110072. private _basePostProcess;
  110073. private _hdrCurrentLuminance;
  110074. private _floatTextureType;
  110075. private _ratio;
  110076. private _bloomEnabled;
  110077. private _depthOfFieldEnabled;
  110078. private _vlsEnabled;
  110079. private _lensFlareEnabled;
  110080. private _hdrEnabled;
  110081. private _motionBlurEnabled;
  110082. private _fxaaEnabled;
  110083. private _motionBlurSamples;
  110084. private _volumetricLightStepsCount;
  110085. private _samples;
  110086. /**
  110087. * @ignore
  110088. * Specifies if the bloom pipeline is enabled
  110089. */
  110090. BloomEnabled: boolean;
  110091. /**
  110092. * @ignore
  110093. * Specifies if the depth of field pipeline is enabed
  110094. */
  110095. DepthOfFieldEnabled: boolean;
  110096. /**
  110097. * @ignore
  110098. * Specifies if the lens flare pipeline is enabed
  110099. */
  110100. LensFlareEnabled: boolean;
  110101. /**
  110102. * @ignore
  110103. * Specifies if the HDR pipeline is enabled
  110104. */
  110105. HDREnabled: boolean;
  110106. /**
  110107. * @ignore
  110108. * Specifies if the volumetric lights scattering effect is enabled
  110109. */
  110110. VLSEnabled: boolean;
  110111. /**
  110112. * @ignore
  110113. * Specifies if the motion blur effect is enabled
  110114. */
  110115. MotionBlurEnabled: boolean;
  110116. /**
  110117. * Specifies if anti-aliasing is enabled
  110118. */
  110119. fxaaEnabled: boolean;
  110120. /**
  110121. * Specifies the number of steps used to calculate the volumetric lights
  110122. * Typically in interval [50, 200]
  110123. */
  110124. volumetricLightStepsCount: number;
  110125. /**
  110126. * Specifies the number of samples used for the motion blur effect
  110127. * Typically in interval [16, 64]
  110128. */
  110129. motionBlurSamples: number;
  110130. /**
  110131. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  110132. */
  110133. samples: number;
  110134. /**
  110135. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  110136. * @constructor
  110137. * @param name The rendering pipeline name
  110138. * @param scene The scene linked to this pipeline
  110139. * @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)
  110140. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  110141. * @param cameras The array of cameras that the rendering pipeline will be attached to
  110142. */
  110143. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  110144. private _buildPipeline;
  110145. private _createDownSampleX4PostProcess;
  110146. private _createBrightPassPostProcess;
  110147. private _createBlurPostProcesses;
  110148. private _createTextureAdderPostProcess;
  110149. private _createVolumetricLightPostProcess;
  110150. private _createLuminancePostProcesses;
  110151. private _createHdrPostProcess;
  110152. private _createLensFlarePostProcess;
  110153. private _createDepthOfFieldPostProcess;
  110154. private _createMotionBlurPostProcess;
  110155. private _getDepthTexture;
  110156. private _disposePostProcesses;
  110157. /**
  110158. * Dispose of the pipeline and stop all post processes
  110159. */
  110160. dispose(): void;
  110161. /**
  110162. * Serialize the rendering pipeline (Used when exporting)
  110163. * @returns the serialized object
  110164. */
  110165. serialize(): any;
  110166. /**
  110167. * Parse the serialized pipeline
  110168. * @param source Source pipeline.
  110169. * @param scene The scene to load the pipeline to.
  110170. * @param rootUrl The URL of the serialized pipeline.
  110171. * @returns An instantiated pipeline from the serialized object.
  110172. */
  110173. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  110174. /**
  110175. * Luminance steps
  110176. */
  110177. static LuminanceSteps: number;
  110178. }
  110179. }
  110180. declare module BABYLON {
  110181. /** @hidden */
  110182. export var tonemapPixelShader: {
  110183. name: string;
  110184. shader: string;
  110185. };
  110186. }
  110187. declare module BABYLON {
  110188. /** Defines operator used for tonemapping */
  110189. export enum TonemappingOperator {
  110190. /** Hable */
  110191. Hable = 0,
  110192. /** Reinhard */
  110193. Reinhard = 1,
  110194. /** HejiDawson */
  110195. HejiDawson = 2,
  110196. /** Photographic */
  110197. Photographic = 3
  110198. }
  110199. /**
  110200. * Defines a post process to apply tone mapping
  110201. */
  110202. export class TonemapPostProcess extends PostProcess {
  110203. private _operator;
  110204. /** Defines the required exposure adjustement */
  110205. exposureAdjustment: number;
  110206. /**
  110207. * Creates a new TonemapPostProcess
  110208. * @param name defines the name of the postprocess
  110209. * @param _operator defines the operator to use
  110210. * @param exposureAdjustment defines the required exposure adjustement
  110211. * @param camera defines the camera to use (can be null)
  110212. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  110213. * @param engine defines the hosting engine (can be ignore if camera is set)
  110214. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  110215. */
  110216. constructor(name: string, _operator: TonemappingOperator,
  110217. /** Defines the required exposure adjustement */
  110218. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  110219. }
  110220. }
  110221. declare module BABYLON {
  110222. /** @hidden */
  110223. export var depthVertexShader: {
  110224. name: string;
  110225. shader: string;
  110226. };
  110227. }
  110228. declare module BABYLON {
  110229. /** @hidden */
  110230. export var volumetricLightScatteringPixelShader: {
  110231. name: string;
  110232. shader: string;
  110233. };
  110234. }
  110235. declare module BABYLON {
  110236. /** @hidden */
  110237. export var volumetricLightScatteringPassPixelShader: {
  110238. name: string;
  110239. shader: string;
  110240. };
  110241. }
  110242. declare module BABYLON {
  110243. /**
  110244. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  110245. */
  110246. export class VolumetricLightScatteringPostProcess extends PostProcess {
  110247. private _volumetricLightScatteringPass;
  110248. private _volumetricLightScatteringRTT;
  110249. private _viewPort;
  110250. private _screenCoordinates;
  110251. private _cachedDefines;
  110252. /**
  110253. * If not undefined, the mesh position is computed from the attached node position
  110254. */
  110255. attachedNode: {
  110256. position: Vector3;
  110257. };
  110258. /**
  110259. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  110260. */
  110261. customMeshPosition: Vector3;
  110262. /**
  110263. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  110264. */
  110265. useCustomMeshPosition: boolean;
  110266. /**
  110267. * If the post-process should inverse the light scattering direction
  110268. */
  110269. invert: boolean;
  110270. /**
  110271. * The internal mesh used by the post-process
  110272. */
  110273. mesh: Mesh;
  110274. /**
  110275. * @hidden
  110276. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  110277. */
  110278. useDiffuseColor: boolean;
  110279. /**
  110280. * Array containing the excluded meshes not rendered in the internal pass
  110281. */
  110282. excludedMeshes: AbstractMesh[];
  110283. /**
  110284. * Controls the overall intensity of the post-process
  110285. */
  110286. exposure: number;
  110287. /**
  110288. * Dissipates each sample's contribution in range [0, 1]
  110289. */
  110290. decay: number;
  110291. /**
  110292. * Controls the overall intensity of each sample
  110293. */
  110294. weight: number;
  110295. /**
  110296. * Controls the density of each sample
  110297. */
  110298. density: number;
  110299. /**
  110300. * @constructor
  110301. * @param name The post-process name
  110302. * @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)
  110303. * @param camera The camera that the post-process will be attached to
  110304. * @param mesh The mesh used to create the light scattering
  110305. * @param samples The post-process quality, default 100
  110306. * @param samplingModeThe post-process filtering mode
  110307. * @param engine The babylon engine
  110308. * @param reusable If the post-process is reusable
  110309. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  110310. */
  110311. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  110312. /**
  110313. * Returns the string "VolumetricLightScatteringPostProcess"
  110314. * @returns "VolumetricLightScatteringPostProcess"
  110315. */
  110316. getClassName(): string;
  110317. private _isReady;
  110318. /**
  110319. * Sets the new light position for light scattering effect
  110320. * @param position The new custom light position
  110321. */
  110322. setCustomMeshPosition(position: Vector3): void;
  110323. /**
  110324. * Returns the light position for light scattering effect
  110325. * @return Vector3 The custom light position
  110326. */
  110327. getCustomMeshPosition(): Vector3;
  110328. /**
  110329. * Disposes the internal assets and detaches the post-process from the camera
  110330. */
  110331. dispose(camera: Camera): void;
  110332. /**
  110333. * Returns the render target texture used by the post-process
  110334. * @return the render target texture used by the post-process
  110335. */
  110336. getPass(): RenderTargetTexture;
  110337. private _meshExcluded;
  110338. private _createPass;
  110339. private _updateMeshScreenCoordinates;
  110340. /**
  110341. * Creates a default mesh for the Volumeric Light Scattering post-process
  110342. * @param name The mesh name
  110343. * @param scene The scene where to create the mesh
  110344. * @return the default mesh
  110345. */
  110346. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  110347. }
  110348. }
  110349. declare module BABYLON {
  110350. interface Scene {
  110351. /** @hidden (Backing field) */
  110352. _boundingBoxRenderer: BoundingBoxRenderer;
  110353. /** @hidden (Backing field) */
  110354. _forceShowBoundingBoxes: boolean;
  110355. /**
  110356. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  110357. */
  110358. forceShowBoundingBoxes: boolean;
  110359. /**
  110360. * Gets the bounding box renderer associated with the scene
  110361. * @returns a BoundingBoxRenderer
  110362. */
  110363. getBoundingBoxRenderer(): BoundingBoxRenderer;
  110364. }
  110365. interface AbstractMesh {
  110366. /** @hidden (Backing field) */
  110367. _showBoundingBox: boolean;
  110368. /**
  110369. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  110370. */
  110371. showBoundingBox: boolean;
  110372. }
  110373. /**
  110374. * Component responsible of rendering the bounding box of the meshes in a scene.
  110375. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  110376. */
  110377. export class BoundingBoxRenderer implements ISceneComponent {
  110378. /**
  110379. * The component name helpfull to identify the component in the list of scene components.
  110380. */
  110381. readonly name: string;
  110382. /**
  110383. * The scene the component belongs to.
  110384. */
  110385. scene: Scene;
  110386. /**
  110387. * Color of the bounding box lines placed in front of an object
  110388. */
  110389. frontColor: Color3;
  110390. /**
  110391. * Color of the bounding box lines placed behind an object
  110392. */
  110393. backColor: Color3;
  110394. /**
  110395. * Defines if the renderer should show the back lines or not
  110396. */
  110397. showBackLines: boolean;
  110398. /**
  110399. * @hidden
  110400. */
  110401. renderList: SmartArray<BoundingBox>;
  110402. private _colorShader;
  110403. private _vertexBuffers;
  110404. private _indexBuffer;
  110405. /**
  110406. * Instantiates a new bounding box renderer in a scene.
  110407. * @param scene the scene the renderer renders in
  110408. */
  110409. constructor(scene: Scene);
  110410. /**
  110411. * Registers the component in a given scene
  110412. */
  110413. register(): void;
  110414. private _evaluateSubMesh;
  110415. private _activeMesh;
  110416. private _prepareRessources;
  110417. private _createIndexBuffer;
  110418. /**
  110419. * Rebuilds the elements related to this component in case of
  110420. * context lost for instance.
  110421. */
  110422. rebuild(): void;
  110423. /**
  110424. * @hidden
  110425. */
  110426. reset(): void;
  110427. /**
  110428. * Render the bounding boxes of a specific rendering group
  110429. * @param renderingGroupId defines the rendering group to render
  110430. */
  110431. render(renderingGroupId: number): void;
  110432. /**
  110433. * In case of occlusion queries, we can render the occlusion bounding box through this method
  110434. * @param mesh Define the mesh to render the occlusion bounding box for
  110435. */
  110436. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  110437. /**
  110438. * Dispose and release the resources attached to this renderer.
  110439. */
  110440. dispose(): void;
  110441. }
  110442. }
  110443. declare module BABYLON {
  110444. /** @hidden */
  110445. export var depthPixelShader: {
  110446. name: string;
  110447. shader: string;
  110448. };
  110449. }
  110450. declare module BABYLON {
  110451. /**
  110452. * This represents a depth renderer in Babylon.
  110453. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  110454. */
  110455. export class DepthRenderer {
  110456. private _scene;
  110457. private _depthMap;
  110458. private _effect;
  110459. private _cachedDefines;
  110460. private _camera;
  110461. /**
  110462. * Specifiess that the depth renderer will only be used within
  110463. * the camera it is created for.
  110464. * This can help forcing its rendering during the camera processing.
  110465. */
  110466. useOnlyInActiveCamera: boolean;
  110467. /** @hidden */
  110468. static _SceneComponentInitialization: (scene: Scene) => void;
  110469. /**
  110470. * Instantiates a depth renderer
  110471. * @param scene The scene the renderer belongs to
  110472. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  110473. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  110474. */
  110475. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  110476. /**
  110477. * Creates the depth rendering effect and checks if the effect is ready.
  110478. * @param subMesh The submesh to be used to render the depth map of
  110479. * @param useInstances If multiple world instances should be used
  110480. * @returns if the depth renderer is ready to render the depth map
  110481. */
  110482. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  110483. /**
  110484. * Gets the texture which the depth map will be written to.
  110485. * @returns The depth map texture
  110486. */
  110487. getDepthMap(): RenderTargetTexture;
  110488. /**
  110489. * Disposes of the depth renderer.
  110490. */
  110491. dispose(): void;
  110492. }
  110493. }
  110494. declare module BABYLON {
  110495. interface Scene {
  110496. /** @hidden (Backing field) */
  110497. _depthRenderer: {
  110498. [id: string]: DepthRenderer;
  110499. };
  110500. /**
  110501. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  110502. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  110503. * @returns the created depth renderer
  110504. */
  110505. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  110506. /**
  110507. * Disables a depth renderer for a given camera
  110508. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  110509. */
  110510. disableDepthRenderer(camera?: Nullable<Camera>): void;
  110511. }
  110512. /**
  110513. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  110514. * in several rendering techniques.
  110515. */
  110516. export class DepthRendererSceneComponent implements ISceneComponent {
  110517. /**
  110518. * The component name helpfull to identify the component in the list of scene components.
  110519. */
  110520. readonly name: string;
  110521. /**
  110522. * The scene the component belongs to.
  110523. */
  110524. scene: Scene;
  110525. /**
  110526. * Creates a new instance of the component for the given scene
  110527. * @param scene Defines the scene to register the component in
  110528. */
  110529. constructor(scene: Scene);
  110530. /**
  110531. * Registers the component in a given scene
  110532. */
  110533. register(): void;
  110534. /**
  110535. * Rebuilds the elements related to this component in case of
  110536. * context lost for instance.
  110537. */
  110538. rebuild(): void;
  110539. /**
  110540. * Disposes the component and the associated ressources
  110541. */
  110542. dispose(): void;
  110543. private _gatherRenderTargets;
  110544. private _gatherActiveCameraRenderTargets;
  110545. }
  110546. }
  110547. declare module BABYLON {
  110548. /** @hidden */
  110549. export var outlinePixelShader: {
  110550. name: string;
  110551. shader: string;
  110552. };
  110553. }
  110554. declare module BABYLON {
  110555. /** @hidden */
  110556. export var outlineVertexShader: {
  110557. name: string;
  110558. shader: string;
  110559. };
  110560. }
  110561. declare module BABYLON {
  110562. interface Scene {
  110563. /** @hidden */
  110564. _outlineRenderer: OutlineRenderer;
  110565. /**
  110566. * Gets the outline renderer associated with the scene
  110567. * @returns a OutlineRenderer
  110568. */
  110569. getOutlineRenderer(): OutlineRenderer;
  110570. }
  110571. interface AbstractMesh {
  110572. /** @hidden (Backing field) */
  110573. _renderOutline: boolean;
  110574. /**
  110575. * Gets or sets a boolean indicating if the outline must be rendered as well
  110576. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  110577. */
  110578. renderOutline: boolean;
  110579. /** @hidden (Backing field) */
  110580. _renderOverlay: boolean;
  110581. /**
  110582. * Gets or sets a boolean indicating if the overlay must be rendered as well
  110583. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  110584. */
  110585. renderOverlay: boolean;
  110586. }
  110587. /**
  110588. * This class is responsible to draw bothe outline/overlay of meshes.
  110589. * It should not be used directly but through the available method on mesh.
  110590. */
  110591. export class OutlineRenderer implements ISceneComponent {
  110592. /**
  110593. * The name of the component. Each component must have a unique name.
  110594. */
  110595. name: string;
  110596. /**
  110597. * The scene the component belongs to.
  110598. */
  110599. scene: Scene;
  110600. /**
  110601. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  110602. */
  110603. zOffset: number;
  110604. private _engine;
  110605. private _effect;
  110606. private _cachedDefines;
  110607. private _savedDepthWrite;
  110608. /**
  110609. * Instantiates a new outline renderer. (There could be only one per scene).
  110610. * @param scene Defines the scene it belongs to
  110611. */
  110612. constructor(scene: Scene);
  110613. /**
  110614. * Register the component to one instance of a scene.
  110615. */
  110616. register(): void;
  110617. /**
  110618. * Rebuilds the elements related to this component in case of
  110619. * context lost for instance.
  110620. */
  110621. rebuild(): void;
  110622. /**
  110623. * Disposes the component and the associated ressources.
  110624. */
  110625. dispose(): void;
  110626. /**
  110627. * Renders the outline in the canvas.
  110628. * @param subMesh Defines the sumesh to render
  110629. * @param batch Defines the batch of meshes in case of instances
  110630. * @param useOverlay Defines if the rendering is for the overlay or the outline
  110631. */
  110632. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  110633. /**
  110634. * Returns whether or not the outline renderer is ready for a given submesh.
  110635. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  110636. * @param subMesh Defines the submesh to check readyness for
  110637. * @param useInstances Defines wheter wee are trying to render instances or not
  110638. * @returns true if ready otherwise false
  110639. */
  110640. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  110641. private _beforeRenderingMesh;
  110642. private _afterRenderingMesh;
  110643. }
  110644. }
  110645. declare module BABYLON {
  110646. /**
  110647. * Defines the list of states available for a task inside a AssetsManager
  110648. */
  110649. export enum AssetTaskState {
  110650. /**
  110651. * Initialization
  110652. */
  110653. INIT = 0,
  110654. /**
  110655. * Running
  110656. */
  110657. RUNNING = 1,
  110658. /**
  110659. * Done
  110660. */
  110661. DONE = 2,
  110662. /**
  110663. * Error
  110664. */
  110665. ERROR = 3
  110666. }
  110667. /**
  110668. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  110669. */
  110670. export abstract class AbstractAssetTask {
  110671. /**
  110672. * Task name
  110673. */ name: string;
  110674. /**
  110675. * Callback called when the task is successful
  110676. */
  110677. onSuccess: (task: any) => void;
  110678. /**
  110679. * Callback called when the task is not successful
  110680. */
  110681. onError: (task: any, message?: string, exception?: any) => void;
  110682. /**
  110683. * Creates a new AssetsManager
  110684. * @param name defines the name of the task
  110685. */
  110686. constructor(
  110687. /**
  110688. * Task name
  110689. */ name: string);
  110690. private _isCompleted;
  110691. private _taskState;
  110692. private _errorObject;
  110693. /**
  110694. * Get if the task is completed
  110695. */
  110696. readonly isCompleted: boolean;
  110697. /**
  110698. * Gets the current state of the task
  110699. */
  110700. readonly taskState: AssetTaskState;
  110701. /**
  110702. * Gets the current error object (if task is in error)
  110703. */
  110704. readonly errorObject: {
  110705. message?: string;
  110706. exception?: any;
  110707. };
  110708. /**
  110709. * Internal only
  110710. * @hidden
  110711. */
  110712. _setErrorObject(message?: string, exception?: any): void;
  110713. /**
  110714. * Execute the current task
  110715. * @param scene defines the scene where you want your assets to be loaded
  110716. * @param onSuccess is a callback called when the task is successfully executed
  110717. * @param onError is a callback called if an error occurs
  110718. */
  110719. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  110720. /**
  110721. * Execute the current task
  110722. * @param scene defines the scene where you want your assets to be loaded
  110723. * @param onSuccess is a callback called when the task is successfully executed
  110724. * @param onError is a callback called if an error occurs
  110725. */
  110726. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  110727. /**
  110728. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  110729. * This can be used with failed tasks that have the reason for failure fixed.
  110730. */
  110731. reset(): void;
  110732. private onErrorCallback;
  110733. private onDoneCallback;
  110734. }
  110735. /**
  110736. * Define the interface used by progress events raised during assets loading
  110737. */
  110738. export interface IAssetsProgressEvent {
  110739. /**
  110740. * Defines the number of remaining tasks to process
  110741. */
  110742. remainingCount: number;
  110743. /**
  110744. * Defines the total number of tasks
  110745. */
  110746. totalCount: number;
  110747. /**
  110748. * Defines the task that was just processed
  110749. */
  110750. task: AbstractAssetTask;
  110751. }
  110752. /**
  110753. * Class used to share progress information about assets loading
  110754. */
  110755. export class AssetsProgressEvent implements IAssetsProgressEvent {
  110756. /**
  110757. * Defines the number of remaining tasks to process
  110758. */
  110759. remainingCount: number;
  110760. /**
  110761. * Defines the total number of tasks
  110762. */
  110763. totalCount: number;
  110764. /**
  110765. * Defines the task that was just processed
  110766. */
  110767. task: AbstractAssetTask;
  110768. /**
  110769. * Creates a AssetsProgressEvent
  110770. * @param remainingCount defines the number of remaining tasks to process
  110771. * @param totalCount defines the total number of tasks
  110772. * @param task defines the task that was just processed
  110773. */
  110774. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  110775. }
  110776. /**
  110777. * Define a task used by AssetsManager to load meshes
  110778. */
  110779. export class MeshAssetTask extends AbstractAssetTask {
  110780. /**
  110781. * Defines the name of the task
  110782. */
  110783. name: string;
  110784. /**
  110785. * Defines the list of mesh's names you want to load
  110786. */
  110787. meshesNames: any;
  110788. /**
  110789. * Defines the root url to use as a base to load your meshes and associated resources
  110790. */
  110791. rootUrl: string;
  110792. /**
  110793. * Defines the filename of the scene to load from
  110794. */
  110795. sceneFilename: string;
  110796. /**
  110797. * Gets the list of loaded meshes
  110798. */
  110799. loadedMeshes: Array<AbstractMesh>;
  110800. /**
  110801. * Gets the list of loaded particle systems
  110802. */
  110803. loadedParticleSystems: Array<IParticleSystem>;
  110804. /**
  110805. * Gets the list of loaded skeletons
  110806. */
  110807. loadedSkeletons: Array<Skeleton>;
  110808. /**
  110809. * Gets the list of loaded animation groups
  110810. */
  110811. loadedAnimationGroups: Array<AnimationGroup>;
  110812. /**
  110813. * Callback called when the task is successful
  110814. */
  110815. onSuccess: (task: MeshAssetTask) => void;
  110816. /**
  110817. * Callback called when the task is successful
  110818. */
  110819. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  110820. /**
  110821. * Creates a new MeshAssetTask
  110822. * @param name defines the name of the task
  110823. * @param meshesNames defines the list of mesh's names you want to load
  110824. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  110825. * @param sceneFilename defines the filename of the scene to load from
  110826. */
  110827. constructor(
  110828. /**
  110829. * Defines the name of the task
  110830. */
  110831. name: string,
  110832. /**
  110833. * Defines the list of mesh's names you want to load
  110834. */
  110835. meshesNames: any,
  110836. /**
  110837. * Defines the root url to use as a base to load your meshes and associated resources
  110838. */
  110839. rootUrl: string,
  110840. /**
  110841. * Defines the filename of the scene to load from
  110842. */
  110843. sceneFilename: string);
  110844. /**
  110845. * Execute the current task
  110846. * @param scene defines the scene where you want your assets to be loaded
  110847. * @param onSuccess is a callback called when the task is successfully executed
  110848. * @param onError is a callback called if an error occurs
  110849. */
  110850. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  110851. }
  110852. /**
  110853. * Define a task used by AssetsManager to load text content
  110854. */
  110855. export class TextFileAssetTask extends AbstractAssetTask {
  110856. /**
  110857. * Defines the name of the task
  110858. */
  110859. name: string;
  110860. /**
  110861. * Defines the location of the file to load
  110862. */
  110863. url: string;
  110864. /**
  110865. * Gets the loaded text string
  110866. */
  110867. text: string;
  110868. /**
  110869. * Callback called when the task is successful
  110870. */
  110871. onSuccess: (task: TextFileAssetTask) => void;
  110872. /**
  110873. * Callback called when the task is successful
  110874. */
  110875. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  110876. /**
  110877. * Creates a new TextFileAssetTask object
  110878. * @param name defines the name of the task
  110879. * @param url defines the location of the file to load
  110880. */
  110881. constructor(
  110882. /**
  110883. * Defines the name of the task
  110884. */
  110885. name: string,
  110886. /**
  110887. * Defines the location of the file to load
  110888. */
  110889. url: string);
  110890. /**
  110891. * Execute the current task
  110892. * @param scene defines the scene where you want your assets to be loaded
  110893. * @param onSuccess is a callback called when the task is successfully executed
  110894. * @param onError is a callback called if an error occurs
  110895. */
  110896. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  110897. }
  110898. /**
  110899. * Define a task used by AssetsManager to load binary data
  110900. */
  110901. export class BinaryFileAssetTask extends AbstractAssetTask {
  110902. /**
  110903. * Defines the name of the task
  110904. */
  110905. name: string;
  110906. /**
  110907. * Defines the location of the file to load
  110908. */
  110909. url: string;
  110910. /**
  110911. * Gets the lodaded data (as an array buffer)
  110912. */
  110913. data: ArrayBuffer;
  110914. /**
  110915. * Callback called when the task is successful
  110916. */
  110917. onSuccess: (task: BinaryFileAssetTask) => void;
  110918. /**
  110919. * Callback called when the task is successful
  110920. */
  110921. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  110922. /**
  110923. * Creates a new BinaryFileAssetTask object
  110924. * @param name defines the name of the new task
  110925. * @param url defines the location of the file to load
  110926. */
  110927. constructor(
  110928. /**
  110929. * Defines the name of the task
  110930. */
  110931. name: string,
  110932. /**
  110933. * Defines the location of the file to load
  110934. */
  110935. url: string);
  110936. /**
  110937. * Execute the current task
  110938. * @param scene defines the scene where you want your assets to be loaded
  110939. * @param onSuccess is a callback called when the task is successfully executed
  110940. * @param onError is a callback called if an error occurs
  110941. */
  110942. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  110943. }
  110944. /**
  110945. * Define a task used by AssetsManager to load images
  110946. */
  110947. export class ImageAssetTask extends AbstractAssetTask {
  110948. /**
  110949. * Defines the name of the task
  110950. */
  110951. name: string;
  110952. /**
  110953. * Defines the location of the image to load
  110954. */
  110955. url: string;
  110956. /**
  110957. * Gets the loaded images
  110958. */
  110959. image: HTMLImageElement;
  110960. /**
  110961. * Callback called when the task is successful
  110962. */
  110963. onSuccess: (task: ImageAssetTask) => void;
  110964. /**
  110965. * Callback called when the task is successful
  110966. */
  110967. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  110968. /**
  110969. * Creates a new ImageAssetTask
  110970. * @param name defines the name of the task
  110971. * @param url defines the location of the image to load
  110972. */
  110973. constructor(
  110974. /**
  110975. * Defines the name of the task
  110976. */
  110977. name: string,
  110978. /**
  110979. * Defines the location of the image to load
  110980. */
  110981. url: string);
  110982. /**
  110983. * Execute the current task
  110984. * @param scene defines the scene where you want your assets to be loaded
  110985. * @param onSuccess is a callback called when the task is successfully executed
  110986. * @param onError is a callback called if an error occurs
  110987. */
  110988. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  110989. }
  110990. /**
  110991. * Defines the interface used by texture loading tasks
  110992. */
  110993. export interface ITextureAssetTask<TEX extends BaseTexture> {
  110994. /**
  110995. * Gets the loaded texture
  110996. */
  110997. texture: TEX;
  110998. }
  110999. /**
  111000. * Define a task used by AssetsManager to load 2D textures
  111001. */
  111002. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  111003. /**
  111004. * Defines the name of the task
  111005. */
  111006. name: string;
  111007. /**
  111008. * Defines the location of the file to load
  111009. */
  111010. url: string;
  111011. /**
  111012. * Defines if mipmap should not be generated (default is false)
  111013. */
  111014. noMipmap?: boolean | undefined;
  111015. /**
  111016. * Defines if texture must be inverted on Y axis (default is false)
  111017. */
  111018. invertY?: boolean | undefined;
  111019. /**
  111020. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  111021. */
  111022. samplingMode: number;
  111023. /**
  111024. * Gets the loaded texture
  111025. */
  111026. texture: Texture;
  111027. /**
  111028. * Callback called when the task is successful
  111029. */
  111030. onSuccess: (task: TextureAssetTask) => void;
  111031. /**
  111032. * Callback called when the task is successful
  111033. */
  111034. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  111035. /**
  111036. * Creates a new TextureAssetTask object
  111037. * @param name defines the name of the task
  111038. * @param url defines the location of the file to load
  111039. * @param noMipmap defines if mipmap should not be generated (default is false)
  111040. * @param invertY defines if texture must be inverted on Y axis (default is false)
  111041. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  111042. */
  111043. constructor(
  111044. /**
  111045. * Defines the name of the task
  111046. */
  111047. name: string,
  111048. /**
  111049. * Defines the location of the file to load
  111050. */
  111051. url: string,
  111052. /**
  111053. * Defines if mipmap should not be generated (default is false)
  111054. */
  111055. noMipmap?: boolean | undefined,
  111056. /**
  111057. * Defines if texture must be inverted on Y axis (default is false)
  111058. */
  111059. invertY?: boolean | undefined,
  111060. /**
  111061. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  111062. */
  111063. samplingMode?: number);
  111064. /**
  111065. * Execute the current task
  111066. * @param scene defines the scene where you want your assets to be loaded
  111067. * @param onSuccess is a callback called when the task is successfully executed
  111068. * @param onError is a callback called if an error occurs
  111069. */
  111070. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  111071. }
  111072. /**
  111073. * Define a task used by AssetsManager to load cube textures
  111074. */
  111075. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  111076. /**
  111077. * Defines the name of the task
  111078. */
  111079. name: string;
  111080. /**
  111081. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  111082. */
  111083. url: string;
  111084. /**
  111085. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  111086. */
  111087. extensions?: string[] | undefined;
  111088. /**
  111089. * Defines if mipmaps should not be generated (default is false)
  111090. */
  111091. noMipmap?: boolean | undefined;
  111092. /**
  111093. * Defines the explicit list of files (undefined by default)
  111094. */
  111095. files?: string[] | undefined;
  111096. /**
  111097. * Gets the loaded texture
  111098. */
  111099. texture: CubeTexture;
  111100. /**
  111101. * Callback called when the task is successful
  111102. */
  111103. onSuccess: (task: CubeTextureAssetTask) => void;
  111104. /**
  111105. * Callback called when the task is successful
  111106. */
  111107. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  111108. /**
  111109. * Creates a new CubeTextureAssetTask
  111110. * @param name defines the name of the task
  111111. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  111112. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  111113. * @param noMipmap defines if mipmaps should not be generated (default is false)
  111114. * @param files defines the explicit list of files (undefined by default)
  111115. */
  111116. constructor(
  111117. /**
  111118. * Defines the name of the task
  111119. */
  111120. name: string,
  111121. /**
  111122. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  111123. */
  111124. url: string,
  111125. /**
  111126. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  111127. */
  111128. extensions?: string[] | undefined,
  111129. /**
  111130. * Defines if mipmaps should not be generated (default is false)
  111131. */
  111132. noMipmap?: boolean | undefined,
  111133. /**
  111134. * Defines the explicit list of files (undefined by default)
  111135. */
  111136. files?: string[] | undefined);
  111137. /**
  111138. * Execute the current task
  111139. * @param scene defines the scene where you want your assets to be loaded
  111140. * @param onSuccess is a callback called when the task is successfully executed
  111141. * @param onError is a callback called if an error occurs
  111142. */
  111143. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  111144. }
  111145. /**
  111146. * Define a task used by AssetsManager to load HDR cube textures
  111147. */
  111148. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  111149. /**
  111150. * Defines the name of the task
  111151. */
  111152. name: string;
  111153. /**
  111154. * Defines the location of the file to load
  111155. */
  111156. url: string;
  111157. /**
  111158. * Defines the desired size (the more it increases the longer the generation will be)
  111159. */
  111160. size: number;
  111161. /**
  111162. * Defines if mipmaps should not be generated (default is false)
  111163. */
  111164. noMipmap: boolean;
  111165. /**
  111166. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  111167. */
  111168. generateHarmonics: boolean;
  111169. /**
  111170. * 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)
  111171. */
  111172. gammaSpace: boolean;
  111173. /**
  111174. * Internal Use Only
  111175. */
  111176. reserved: boolean;
  111177. /**
  111178. * Gets the loaded texture
  111179. */
  111180. texture: HDRCubeTexture;
  111181. /**
  111182. * Callback called when the task is successful
  111183. */
  111184. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  111185. /**
  111186. * Callback called when the task is successful
  111187. */
  111188. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  111189. /**
  111190. * Creates a new HDRCubeTextureAssetTask object
  111191. * @param name defines the name of the task
  111192. * @param url defines the location of the file to load
  111193. * @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.
  111194. * @param noMipmap defines if mipmaps should not be generated (default is false)
  111195. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  111196. * @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)
  111197. * @param reserved Internal use only
  111198. */
  111199. constructor(
  111200. /**
  111201. * Defines the name of the task
  111202. */
  111203. name: string,
  111204. /**
  111205. * Defines the location of the file to load
  111206. */
  111207. url: string,
  111208. /**
  111209. * Defines the desired size (the more it increases the longer the generation will be)
  111210. */
  111211. size: number,
  111212. /**
  111213. * Defines if mipmaps should not be generated (default is false)
  111214. */
  111215. noMipmap?: boolean,
  111216. /**
  111217. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  111218. */
  111219. generateHarmonics?: boolean,
  111220. /**
  111221. * 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)
  111222. */
  111223. gammaSpace?: boolean,
  111224. /**
  111225. * Internal Use Only
  111226. */
  111227. reserved?: boolean);
  111228. /**
  111229. * Execute the current task
  111230. * @param scene defines the scene where you want your assets to be loaded
  111231. * @param onSuccess is a callback called when the task is successfully executed
  111232. * @param onError is a callback called if an error occurs
  111233. */
  111234. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  111235. }
  111236. /**
  111237. * This class can be used to easily import assets into a scene
  111238. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  111239. */
  111240. export class AssetsManager {
  111241. private _scene;
  111242. private _isLoading;
  111243. protected _tasks: AbstractAssetTask[];
  111244. protected _waitingTasksCount: number;
  111245. protected _totalTasksCount: number;
  111246. /**
  111247. * Callback called when all tasks are processed
  111248. */
  111249. onFinish: (tasks: AbstractAssetTask[]) => void;
  111250. /**
  111251. * Callback called when a task is successful
  111252. */
  111253. onTaskSuccess: (task: AbstractAssetTask) => void;
  111254. /**
  111255. * Callback called when a task had an error
  111256. */
  111257. onTaskError: (task: AbstractAssetTask) => void;
  111258. /**
  111259. * Callback called when a task is done (whatever the result is)
  111260. */
  111261. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  111262. /**
  111263. * Observable called when all tasks are processed
  111264. */
  111265. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  111266. /**
  111267. * Observable called when a task had an error
  111268. */
  111269. onTaskErrorObservable: Observable<AbstractAssetTask>;
  111270. /**
  111271. * Observable called when all tasks were executed
  111272. */
  111273. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  111274. /**
  111275. * Observable called when a task is done (whatever the result is)
  111276. */
  111277. onProgressObservable: Observable<IAssetsProgressEvent>;
  111278. /**
  111279. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  111280. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  111281. */
  111282. useDefaultLoadingScreen: boolean;
  111283. /**
  111284. * Creates a new AssetsManager
  111285. * @param scene defines the scene to work on
  111286. */
  111287. constructor(scene: Scene);
  111288. /**
  111289. * Add a MeshAssetTask to the list of active tasks
  111290. * @param taskName defines the name of the new task
  111291. * @param meshesNames defines the name of meshes to load
  111292. * @param rootUrl defines the root url to use to locate files
  111293. * @param sceneFilename defines the filename of the scene file
  111294. * @returns a new MeshAssetTask object
  111295. */
  111296. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  111297. /**
  111298. * Add a TextFileAssetTask to the list of active tasks
  111299. * @param taskName defines the name of the new task
  111300. * @param url defines the url of the file to load
  111301. * @returns a new TextFileAssetTask object
  111302. */
  111303. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  111304. /**
  111305. * Add a BinaryFileAssetTask to the list of active tasks
  111306. * @param taskName defines the name of the new task
  111307. * @param url defines the url of the file to load
  111308. * @returns a new BinaryFileAssetTask object
  111309. */
  111310. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  111311. /**
  111312. * Add a ImageAssetTask to the list of active tasks
  111313. * @param taskName defines the name of the new task
  111314. * @param url defines the url of the file to load
  111315. * @returns a new ImageAssetTask object
  111316. */
  111317. addImageTask(taskName: string, url: string): ImageAssetTask;
  111318. /**
  111319. * Add a TextureAssetTask to the list of active tasks
  111320. * @param taskName defines the name of the new task
  111321. * @param url defines the url of the file to load
  111322. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  111323. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  111324. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  111325. * @returns a new TextureAssetTask object
  111326. */
  111327. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  111328. /**
  111329. * Add a CubeTextureAssetTask to the list of active tasks
  111330. * @param taskName defines the name of the new task
  111331. * @param url defines the url of the file to load
  111332. * @param extensions defines the extension to use to load the cube map (can be null)
  111333. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  111334. * @param files defines the list of files to load (can be null)
  111335. * @returns a new CubeTextureAssetTask object
  111336. */
  111337. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  111338. /**
  111339. *
  111340. * Add a HDRCubeTextureAssetTask to the list of active tasks
  111341. * @param taskName defines the name of the new task
  111342. * @param url defines the url of the file to load
  111343. * @param size defines the size you want for the cubemap (can be null)
  111344. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  111345. * @param generateHarmonics defines if you want to automatically generate (true by default)
  111346. * @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)
  111347. * @param reserved Internal use only
  111348. * @returns a new HDRCubeTextureAssetTask object
  111349. */
  111350. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  111351. /**
  111352. * Remove a task from the assets manager.
  111353. * @param task the task to remove
  111354. */
  111355. removeTask(task: AbstractAssetTask): void;
  111356. private _decreaseWaitingTasksCount;
  111357. private _runTask;
  111358. /**
  111359. * Reset the AssetsManager and remove all tasks
  111360. * @return the current instance of the AssetsManager
  111361. */
  111362. reset(): AssetsManager;
  111363. /**
  111364. * Start the loading process
  111365. * @return the current instance of the AssetsManager
  111366. */
  111367. load(): AssetsManager;
  111368. /**
  111369. * Start the loading process as an async operation
  111370. * @return a promise returning the list of failed tasks
  111371. */
  111372. loadAsync(): Promise<void>;
  111373. }
  111374. }
  111375. declare module BABYLON {
  111376. /**
  111377. * Wrapper class for promise with external resolve and reject.
  111378. */
  111379. export class Deferred<T> {
  111380. /**
  111381. * The promise associated with this deferred object.
  111382. */
  111383. readonly promise: Promise<T>;
  111384. private _resolve;
  111385. private _reject;
  111386. /**
  111387. * The resolve method of the promise associated with this deferred object.
  111388. */
  111389. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  111390. /**
  111391. * The reject method of the promise associated with this deferred object.
  111392. */
  111393. readonly reject: (reason?: any) => void;
  111394. /**
  111395. * Constructor for this deferred object.
  111396. */
  111397. constructor();
  111398. }
  111399. }
  111400. declare module BABYLON {
  111401. /**
  111402. * Class used to help managing file picking and drag'n'drop
  111403. */
  111404. export class FilesInput {
  111405. /**
  111406. * List of files ready to be loaded
  111407. */
  111408. static readonly FilesToLoad: {
  111409. [key: string]: File;
  111410. };
  111411. /**
  111412. * Callback called when a file is processed
  111413. */
  111414. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  111415. private _engine;
  111416. private _currentScene;
  111417. private _sceneLoadedCallback;
  111418. private _progressCallback;
  111419. private _additionalRenderLoopLogicCallback;
  111420. private _textureLoadingCallback;
  111421. private _startingProcessingFilesCallback;
  111422. private _onReloadCallback;
  111423. private _errorCallback;
  111424. private _elementToMonitor;
  111425. private _sceneFileToLoad;
  111426. private _filesToLoad;
  111427. /**
  111428. * Creates a new FilesInput
  111429. * @param engine defines the rendering engine
  111430. * @param scene defines the hosting scene
  111431. * @param sceneLoadedCallback callback called when scene is loaded
  111432. * @param progressCallback callback called to track progress
  111433. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  111434. * @param textureLoadingCallback callback called when a texture is loading
  111435. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  111436. * @param onReloadCallback callback called when a reload is requested
  111437. * @param errorCallback callback call if an error occurs
  111438. */
  111439. 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);
  111440. private _dragEnterHandler;
  111441. private _dragOverHandler;
  111442. private _dropHandler;
  111443. /**
  111444. * Calls this function to listen to drag'n'drop events on a specific DOM element
  111445. * @param elementToMonitor defines the DOM element to track
  111446. */
  111447. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  111448. /**
  111449. * Release all associated resources
  111450. */
  111451. dispose(): void;
  111452. private renderFunction;
  111453. private drag;
  111454. private drop;
  111455. private _traverseFolder;
  111456. private _processFiles;
  111457. /**
  111458. * Load files from a drop event
  111459. * @param event defines the drop event to use as source
  111460. */
  111461. loadFiles(event: any): void;
  111462. private _processReload;
  111463. /**
  111464. * Reload the current scene from the loaded files
  111465. */
  111466. reload(): void;
  111467. }
  111468. }
  111469. declare module BABYLON {
  111470. /**
  111471. * Defines the root class used to create scene optimization to use with SceneOptimizer
  111472. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  111473. */
  111474. export class SceneOptimization {
  111475. /**
  111476. * Defines the priority of this optimization (0 by default which means first in the list)
  111477. */
  111478. priority: number;
  111479. /**
  111480. * Gets a string describing the action executed by the current optimization
  111481. * @returns description string
  111482. */
  111483. getDescription(): string;
  111484. /**
  111485. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  111486. * @param scene defines the current scene where to apply this optimization
  111487. * @param optimizer defines the current optimizer
  111488. * @returns true if everything that can be done was applied
  111489. */
  111490. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  111491. /**
  111492. * Creates the SceneOptimization object
  111493. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  111494. * @param desc defines the description associated with the optimization
  111495. */
  111496. constructor(
  111497. /**
  111498. * Defines the priority of this optimization (0 by default which means first in the list)
  111499. */
  111500. priority?: number);
  111501. }
  111502. /**
  111503. * Defines an optimization used to reduce the size of render target textures
  111504. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  111505. */
  111506. export class TextureOptimization extends SceneOptimization {
  111507. /**
  111508. * Defines the priority of this optimization (0 by default which means first in the list)
  111509. */
  111510. priority: number;
  111511. /**
  111512. * 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
  111513. */
  111514. maximumSize: number;
  111515. /**
  111516. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  111517. */
  111518. step: number;
  111519. /**
  111520. * Gets a string describing the action executed by the current optimization
  111521. * @returns description string
  111522. */
  111523. getDescription(): string;
  111524. /**
  111525. * Creates the TextureOptimization object
  111526. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  111527. * @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
  111528. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  111529. */
  111530. constructor(
  111531. /**
  111532. * Defines the priority of this optimization (0 by default which means first in the list)
  111533. */
  111534. priority?: number,
  111535. /**
  111536. * 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
  111537. */
  111538. maximumSize?: number,
  111539. /**
  111540. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  111541. */
  111542. step?: number);
  111543. /**
  111544. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  111545. * @param scene defines the current scene where to apply this optimization
  111546. * @param optimizer defines the current optimizer
  111547. * @returns true if everything that can be done was applied
  111548. */
  111549. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  111550. }
  111551. /**
  111552. * Defines an optimization used to increase or decrease the rendering resolution
  111553. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  111554. */
  111555. export class HardwareScalingOptimization extends SceneOptimization {
  111556. /**
  111557. * Defines the priority of this optimization (0 by default which means first in the list)
  111558. */
  111559. priority: number;
  111560. /**
  111561. * Defines the maximum scale to use (2 by default)
  111562. */
  111563. maximumScale: number;
  111564. /**
  111565. * Defines the step to use between two passes (0.5 by default)
  111566. */
  111567. step: number;
  111568. private _currentScale;
  111569. private _directionOffset;
  111570. /**
  111571. * Gets a string describing the action executed by the current optimization
  111572. * @return description string
  111573. */
  111574. getDescription(): string;
  111575. /**
  111576. * Creates the HardwareScalingOptimization object
  111577. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  111578. * @param maximumScale defines the maximum scale to use (2 by default)
  111579. * @param step defines the step to use between two passes (0.5 by default)
  111580. */
  111581. constructor(
  111582. /**
  111583. * Defines the priority of this optimization (0 by default which means first in the list)
  111584. */
  111585. priority?: number,
  111586. /**
  111587. * Defines the maximum scale to use (2 by default)
  111588. */
  111589. maximumScale?: number,
  111590. /**
  111591. * Defines the step to use between two passes (0.5 by default)
  111592. */
  111593. step?: number);
  111594. /**
  111595. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  111596. * @param scene defines the current scene where to apply this optimization
  111597. * @param optimizer defines the current optimizer
  111598. * @returns true if everything that can be done was applied
  111599. */
  111600. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  111601. }
  111602. /**
  111603. * Defines an optimization used to remove shadows
  111604. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  111605. */
  111606. export class ShadowsOptimization extends SceneOptimization {
  111607. /**
  111608. * Gets a string describing the action executed by the current optimization
  111609. * @return description string
  111610. */
  111611. getDescription(): string;
  111612. /**
  111613. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  111614. * @param scene defines the current scene where to apply this optimization
  111615. * @param optimizer defines the current optimizer
  111616. * @returns true if everything that can be done was applied
  111617. */
  111618. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  111619. }
  111620. /**
  111621. * Defines an optimization used to turn post-processes off
  111622. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  111623. */
  111624. export class PostProcessesOptimization extends SceneOptimization {
  111625. /**
  111626. * Gets a string describing the action executed by the current optimization
  111627. * @return description string
  111628. */
  111629. getDescription(): string;
  111630. /**
  111631. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  111632. * @param scene defines the current scene where to apply this optimization
  111633. * @param optimizer defines the current optimizer
  111634. * @returns true if everything that can be done was applied
  111635. */
  111636. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  111637. }
  111638. /**
  111639. * Defines an optimization used to turn lens flares off
  111640. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  111641. */
  111642. export class LensFlaresOptimization extends SceneOptimization {
  111643. /**
  111644. * Gets a string describing the action executed by the current optimization
  111645. * @return description string
  111646. */
  111647. getDescription(): string;
  111648. /**
  111649. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  111650. * @param scene defines the current scene where to apply this optimization
  111651. * @param optimizer defines the current optimizer
  111652. * @returns true if everything that can be done was applied
  111653. */
  111654. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  111655. }
  111656. /**
  111657. * Defines an optimization based on user defined callback.
  111658. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  111659. */
  111660. export class CustomOptimization extends SceneOptimization {
  111661. /**
  111662. * Callback called to apply the custom optimization.
  111663. */
  111664. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  111665. /**
  111666. * Callback called to get custom description
  111667. */
  111668. onGetDescription: () => string;
  111669. /**
  111670. * Gets a string describing the action executed by the current optimization
  111671. * @returns description string
  111672. */
  111673. getDescription(): string;
  111674. /**
  111675. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  111676. * @param scene defines the current scene where to apply this optimization
  111677. * @param optimizer defines the current optimizer
  111678. * @returns true if everything that can be done was applied
  111679. */
  111680. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  111681. }
  111682. /**
  111683. * Defines an optimization used to turn particles off
  111684. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  111685. */
  111686. export class ParticlesOptimization extends SceneOptimization {
  111687. /**
  111688. * Gets a string describing the action executed by the current optimization
  111689. * @return description string
  111690. */
  111691. getDescription(): string;
  111692. /**
  111693. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  111694. * @param scene defines the current scene where to apply this optimization
  111695. * @param optimizer defines the current optimizer
  111696. * @returns true if everything that can be done was applied
  111697. */
  111698. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  111699. }
  111700. /**
  111701. * Defines an optimization used to turn render targets off
  111702. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  111703. */
  111704. export class RenderTargetsOptimization extends SceneOptimization {
  111705. /**
  111706. * Gets a string describing the action executed by the current optimization
  111707. * @return description string
  111708. */
  111709. getDescription(): string;
  111710. /**
  111711. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  111712. * @param scene defines the current scene where to apply this optimization
  111713. * @param optimizer defines the current optimizer
  111714. * @returns true if everything that can be done was applied
  111715. */
  111716. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  111717. }
  111718. /**
  111719. * Defines an optimization used to merge meshes with compatible materials
  111720. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  111721. */
  111722. export class MergeMeshesOptimization extends SceneOptimization {
  111723. private static _UpdateSelectionTree;
  111724. /**
  111725. * Gets or sets a boolean which defines if optimization octree has to be updated
  111726. */
  111727. /**
  111728. * Gets or sets a boolean which defines if optimization octree has to be updated
  111729. */
  111730. static UpdateSelectionTree: boolean;
  111731. /**
  111732. * Gets a string describing the action executed by the current optimization
  111733. * @return description string
  111734. */
  111735. getDescription(): string;
  111736. private _canBeMerged;
  111737. /**
  111738. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  111739. * @param scene defines the current scene where to apply this optimization
  111740. * @param optimizer defines the current optimizer
  111741. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  111742. * @returns true if everything that can be done was applied
  111743. */
  111744. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  111745. }
  111746. /**
  111747. * Defines a list of options used by SceneOptimizer
  111748. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  111749. */
  111750. export class SceneOptimizerOptions {
  111751. /**
  111752. * Defines the target frame rate to reach (60 by default)
  111753. */
  111754. targetFrameRate: number;
  111755. /**
  111756. * Defines the interval between two checkes (2000ms by default)
  111757. */
  111758. trackerDuration: number;
  111759. /**
  111760. * Gets the list of optimizations to apply
  111761. */
  111762. optimizations: SceneOptimization[];
  111763. /**
  111764. * Creates a new list of options used by SceneOptimizer
  111765. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  111766. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  111767. */
  111768. constructor(
  111769. /**
  111770. * Defines the target frame rate to reach (60 by default)
  111771. */
  111772. targetFrameRate?: number,
  111773. /**
  111774. * Defines the interval between two checkes (2000ms by default)
  111775. */
  111776. trackerDuration?: number);
  111777. /**
  111778. * Add a new optimization
  111779. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  111780. * @returns the current SceneOptimizerOptions
  111781. */
  111782. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  111783. /**
  111784. * Add a new custom optimization
  111785. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  111786. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  111787. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  111788. * @returns the current SceneOptimizerOptions
  111789. */
  111790. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  111791. /**
  111792. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  111793. * @param targetFrameRate defines the target frame rate (60 by default)
  111794. * @returns a SceneOptimizerOptions object
  111795. */
  111796. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  111797. /**
  111798. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  111799. * @param targetFrameRate defines the target frame rate (60 by default)
  111800. * @returns a SceneOptimizerOptions object
  111801. */
  111802. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  111803. /**
  111804. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  111805. * @param targetFrameRate defines the target frame rate (60 by default)
  111806. * @returns a SceneOptimizerOptions object
  111807. */
  111808. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  111809. }
  111810. /**
  111811. * Class used to run optimizations in order to reach a target frame rate
  111812. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  111813. */
  111814. export class SceneOptimizer implements IDisposable {
  111815. private _isRunning;
  111816. private _options;
  111817. private _scene;
  111818. private _currentPriorityLevel;
  111819. private _targetFrameRate;
  111820. private _trackerDuration;
  111821. private _currentFrameRate;
  111822. private _sceneDisposeObserver;
  111823. private _improvementMode;
  111824. /**
  111825. * Defines an observable called when the optimizer reaches the target frame rate
  111826. */
  111827. onSuccessObservable: Observable<SceneOptimizer>;
  111828. /**
  111829. * Defines an observable called when the optimizer enables an optimization
  111830. */
  111831. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  111832. /**
  111833. * Defines an observable called when the optimizer is not able to reach the target frame rate
  111834. */
  111835. onFailureObservable: Observable<SceneOptimizer>;
  111836. /**
  111837. * Gets a boolean indicating if the optimizer is in improvement mode
  111838. */
  111839. readonly isInImprovementMode: boolean;
  111840. /**
  111841. * Gets the current priority level (0 at start)
  111842. */
  111843. readonly currentPriorityLevel: number;
  111844. /**
  111845. * Gets the current frame rate checked by the SceneOptimizer
  111846. */
  111847. readonly currentFrameRate: number;
  111848. /**
  111849. * Gets or sets the current target frame rate (60 by default)
  111850. */
  111851. /**
  111852. * Gets or sets the current target frame rate (60 by default)
  111853. */
  111854. targetFrameRate: number;
  111855. /**
  111856. * Gets or sets the current interval between two checks (every 2000ms by default)
  111857. */
  111858. /**
  111859. * Gets or sets the current interval between two checks (every 2000ms by default)
  111860. */
  111861. trackerDuration: number;
  111862. /**
  111863. * Gets the list of active optimizations
  111864. */
  111865. readonly optimizations: SceneOptimization[];
  111866. /**
  111867. * Creates a new SceneOptimizer
  111868. * @param scene defines the scene to work on
  111869. * @param options defines the options to use with the SceneOptimizer
  111870. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  111871. * @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)
  111872. */
  111873. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  111874. /**
  111875. * Stops the current optimizer
  111876. */
  111877. stop(): void;
  111878. /**
  111879. * Reset the optimizer to initial step (current priority level = 0)
  111880. */
  111881. reset(): void;
  111882. /**
  111883. * Start the optimizer. By default it will try to reach a specific framerate
  111884. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  111885. */
  111886. start(): void;
  111887. private _checkCurrentState;
  111888. /**
  111889. * Release all resources
  111890. */
  111891. dispose(): void;
  111892. /**
  111893. * Helper function to create a SceneOptimizer with one single line of code
  111894. * @param scene defines the scene to work on
  111895. * @param options defines the options to use with the SceneOptimizer
  111896. * @param onSuccess defines a callback to call on success
  111897. * @param onFailure defines a callback to call on failure
  111898. * @returns the new SceneOptimizer object
  111899. */
  111900. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  111901. }
  111902. }
  111903. declare module BABYLON {
  111904. /**
  111905. * Class used to serialize a scene into a string
  111906. */
  111907. export class SceneSerializer {
  111908. /**
  111909. * Clear cache used by a previous serialization
  111910. */
  111911. static ClearCache(): void;
  111912. /**
  111913. * Serialize a scene into a JSON compatible object
  111914. * @param scene defines the scene to serialize
  111915. * @returns a JSON compatible object
  111916. */
  111917. static Serialize(scene: Scene): any;
  111918. /**
  111919. * Serialize a mesh into a JSON compatible object
  111920. * @param toSerialize defines the mesh to serialize
  111921. * @param withParents defines if parents must be serialized as well
  111922. * @param withChildren defines if children must be serialized as well
  111923. * @returns a JSON compatible object
  111924. */
  111925. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  111926. }
  111927. }
  111928. declare module BABYLON {
  111929. /**
  111930. * This represents the different options avilable for the video capture.
  111931. */
  111932. export interface VideoRecorderOptions {
  111933. /** Defines the mime type of the video */
  111934. mimeType: string;
  111935. /** Defines the video the video should be recorded at */
  111936. fps: number;
  111937. /** Defines the chunk size for the recording data */
  111938. recordChunckSize: number;
  111939. /** The audio tracks to attach to the record */
  111940. audioTracks?: MediaStreamTrack[];
  111941. }
  111942. /**
  111943. * This can helps recording videos from BabylonJS.
  111944. * This is based on the available WebRTC functionalities of the browser.
  111945. *
  111946. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  111947. */
  111948. export class VideoRecorder {
  111949. private static readonly _defaultOptions;
  111950. /**
  111951. * Returns wehther or not the VideoRecorder is available in your browser.
  111952. * @param engine Defines the Babylon Engine to check the support for
  111953. * @returns true if supported otherwise false
  111954. */
  111955. static IsSupported(engine: Engine): boolean;
  111956. private readonly _options;
  111957. private _canvas;
  111958. private _mediaRecorder;
  111959. private _recordedChunks;
  111960. private _fileName;
  111961. private _resolve;
  111962. private _reject;
  111963. /**
  111964. * True wether a recording is already in progress.
  111965. */
  111966. readonly isRecording: boolean;
  111967. /**
  111968. * Create a new VideoCapture object which can help converting what you see in Babylon to
  111969. * a video file.
  111970. * @param engine Defines the BabylonJS Engine you wish to record
  111971. * @param options Defines options that can be used to customized the capture
  111972. */
  111973. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  111974. /**
  111975. * Stops the current recording before the default capture timeout passed in the startRecording
  111976. * functions.
  111977. */
  111978. stopRecording(): void;
  111979. /**
  111980. * Starts recording the canvas for a max duration specified in parameters.
  111981. * @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.
  111982. * @param maxDuration Defines the maximum recording time in seconds.
  111983. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  111984. * @return a promise callback at the end of the recording with the video data in Blob.
  111985. */
  111986. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  111987. /**
  111988. * Releases internal resources used during the recording.
  111989. */
  111990. dispose(): void;
  111991. private _handleDataAvailable;
  111992. private _handleError;
  111993. private _handleStop;
  111994. }
  111995. }
  111996. declare module BABYLON {
  111997. /**
  111998. * Helper class to push actions to a pool of workers.
  111999. */
  112000. export class WorkerPool implements IDisposable {
  112001. private _workerInfos;
  112002. private _pendingActions;
  112003. /**
  112004. * Constructor
  112005. * @param workers Array of workers to use for actions
  112006. */
  112007. constructor(workers: Array<Worker>);
  112008. /**
  112009. * Terminates all workers and clears any pending actions.
  112010. */
  112011. dispose(): void;
  112012. /**
  112013. * Pushes an action to the worker pool. If all the workers are active, the action will be
  112014. * pended until a worker has completed its action.
  112015. * @param action The action to perform. Call onComplete when the action is complete.
  112016. */
  112017. push(action: (worker: Worker, onComplete: () => void) => void): void;
  112018. private _execute;
  112019. }
  112020. }
  112021. declare module BABYLON {
  112022. /**
  112023. * Class containing a set of static utilities functions for screenshots
  112024. */
  112025. export class ScreenshotTools {
  112026. /**
  112027. * Captures a screenshot of the current rendering
  112028. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  112029. * @param engine defines the rendering engine
  112030. * @param camera defines the source camera
  112031. * @param size This parameter can be set to a single number or to an object with the
  112032. * following (optional) properties: precision, width, height. If a single number is passed,
  112033. * it will be used for both width and height. If an object is passed, the screenshot size
  112034. * will be derived from the parameters. The precision property is a multiplier allowing
  112035. * rendering at a higher or lower resolution
  112036. * @param successCallback defines the callback receives a single parameter which contains the
  112037. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  112038. * src parameter of an <img> to display it
  112039. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  112040. * Check your browser for supported MIME types
  112041. */
  112042. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  112043. /**
  112044. * Generates an image screenshot from the specified camera.
  112045. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  112046. * @param engine The engine to use for rendering
  112047. * @param camera The camera to use for rendering
  112048. * @param size This parameter can be set to a single number or to an object with the
  112049. * following (optional) properties: precision, width, height. If a single number is passed,
  112050. * it will be used for both width and height. If an object is passed, the screenshot size
  112051. * will be derived from the parameters. The precision property is a multiplier allowing
  112052. * rendering at a higher or lower resolution
  112053. * @param successCallback The callback receives a single parameter which contains the
  112054. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  112055. * src parameter of an <img> to display it
  112056. * @param mimeType The MIME type of the screenshot image (default: image/png).
  112057. * Check your browser for supported MIME types
  112058. * @param samples Texture samples (default: 1)
  112059. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  112060. * @param fileName A name for for the downloaded file.
  112061. */
  112062. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  112063. }
  112064. }
  112065. declare module BABYLON {
  112066. /**
  112067. * A cursor which tracks a point on a path
  112068. */
  112069. export class PathCursor {
  112070. private path;
  112071. /**
  112072. * Stores path cursor callbacks for when an onchange event is triggered
  112073. */
  112074. private _onchange;
  112075. /**
  112076. * The value of the path cursor
  112077. */
  112078. value: number;
  112079. /**
  112080. * The animation array of the path cursor
  112081. */
  112082. animations: Animation[];
  112083. /**
  112084. * Initializes the path cursor
  112085. * @param path The path to track
  112086. */
  112087. constructor(path: Path2);
  112088. /**
  112089. * Gets the cursor point on the path
  112090. * @returns A point on the path cursor at the cursor location
  112091. */
  112092. getPoint(): Vector3;
  112093. /**
  112094. * Moves the cursor ahead by the step amount
  112095. * @param step The amount to move the cursor forward
  112096. * @returns This path cursor
  112097. */
  112098. moveAhead(step?: number): PathCursor;
  112099. /**
  112100. * Moves the cursor behind by the step amount
  112101. * @param step The amount to move the cursor back
  112102. * @returns This path cursor
  112103. */
  112104. moveBack(step?: number): PathCursor;
  112105. /**
  112106. * Moves the cursor by the step amount
  112107. * If the step amount is greater than one, an exception is thrown
  112108. * @param step The amount to move the cursor
  112109. * @returns This path cursor
  112110. */
  112111. move(step: number): PathCursor;
  112112. /**
  112113. * Ensures that the value is limited between zero and one
  112114. * @returns This path cursor
  112115. */
  112116. private ensureLimits;
  112117. /**
  112118. * Runs onchange callbacks on change (used by the animation engine)
  112119. * @returns This path cursor
  112120. */
  112121. private raiseOnChange;
  112122. /**
  112123. * Executes a function on change
  112124. * @param f A path cursor onchange callback
  112125. * @returns This path cursor
  112126. */
  112127. onchange(f: (cursor: PathCursor) => void): PathCursor;
  112128. }
  112129. }
  112130. declare module BABYLON {
  112131. /** @hidden */
  112132. export var blurPixelShader: {
  112133. name: string;
  112134. shader: string;
  112135. };
  112136. }
  112137. declare module BABYLON {
  112138. /** @hidden */
  112139. export var bones300Declaration: {
  112140. name: string;
  112141. shader: string;
  112142. };
  112143. }
  112144. declare module BABYLON {
  112145. /** @hidden */
  112146. export var instances300Declaration: {
  112147. name: string;
  112148. shader: string;
  112149. };
  112150. }
  112151. declare module BABYLON {
  112152. /** @hidden */
  112153. export var pointCloudVertexDeclaration: {
  112154. name: string;
  112155. shader: string;
  112156. };
  112157. }
  112158. // Mixins
  112159. interface Window {
  112160. mozIndexedDB: IDBFactory;
  112161. webkitIndexedDB: IDBFactory;
  112162. msIndexedDB: IDBFactory;
  112163. webkitURL: typeof URL;
  112164. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  112165. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  112166. WebGLRenderingContext: WebGLRenderingContext;
  112167. MSGesture: MSGesture;
  112168. CANNON: any;
  112169. AudioContext: AudioContext;
  112170. webkitAudioContext: AudioContext;
  112171. PointerEvent: any;
  112172. Math: Math;
  112173. Uint8Array: Uint8ArrayConstructor;
  112174. Float32Array: Float32ArrayConstructor;
  112175. mozURL: typeof URL;
  112176. msURL: typeof URL;
  112177. VRFrameData: any; // WebVR, from specs 1.1
  112178. DracoDecoderModule: any;
  112179. setImmediate(handler: (...args: any[]) => void): number;
  112180. }
  112181. interface HTMLCanvasElement {
  112182. requestPointerLock(): void;
  112183. msRequestPointerLock?(): void;
  112184. mozRequestPointerLock?(): void;
  112185. webkitRequestPointerLock?(): void;
  112186. /** Track wether a record is in progress */
  112187. isRecording: boolean;
  112188. /** Capture Stream method defined by some browsers */
  112189. captureStream(fps?: number): MediaStream;
  112190. }
  112191. interface CanvasRenderingContext2D {
  112192. msImageSmoothingEnabled: boolean;
  112193. }
  112194. interface MouseEvent {
  112195. mozMovementX: number;
  112196. mozMovementY: number;
  112197. webkitMovementX: number;
  112198. webkitMovementY: number;
  112199. msMovementX: number;
  112200. msMovementY: number;
  112201. }
  112202. interface Navigator {
  112203. mozGetVRDevices: (any: any) => any;
  112204. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  112205. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  112206. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  112207. webkitGetGamepads(): Gamepad[];
  112208. msGetGamepads(): Gamepad[];
  112209. webkitGamepads(): Gamepad[];
  112210. }
  112211. interface HTMLVideoElement {
  112212. mozSrcObject: any;
  112213. }
  112214. interface Math {
  112215. fround(x: number): number;
  112216. imul(a: number, b: number): number;
  112217. }
  112218. interface WebGLProgram {
  112219. context?: WebGLRenderingContext;
  112220. vertexShader?: WebGLShader;
  112221. fragmentShader?: WebGLShader;
  112222. isParallelCompiled: boolean;
  112223. onCompiled?: () => void;
  112224. }
  112225. interface WebGLRenderingContext {
  112226. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  112227. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  112228. vertexAttribDivisor(index: number, divisor: number): void;
  112229. createVertexArray(): any;
  112230. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  112231. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  112232. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  112233. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  112234. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  112235. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  112236. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  112237. // Queries
  112238. createQuery(): WebGLQuery;
  112239. deleteQuery(query: WebGLQuery): void;
  112240. beginQuery(target: number, query: WebGLQuery): void;
  112241. endQuery(target: number): void;
  112242. getQueryParameter(query: WebGLQuery, pname: number): any;
  112243. getQuery(target: number, pname: number): any;
  112244. MAX_SAMPLES: number;
  112245. RGBA8: number;
  112246. READ_FRAMEBUFFER: number;
  112247. DRAW_FRAMEBUFFER: number;
  112248. UNIFORM_BUFFER: number;
  112249. HALF_FLOAT_OES: number;
  112250. RGBA16F: number;
  112251. RGBA32F: number;
  112252. R32F: number;
  112253. RG32F: number;
  112254. RGB32F: number;
  112255. R16F: number;
  112256. RG16F: number;
  112257. RGB16F: number;
  112258. RED: number;
  112259. RG: number;
  112260. R8: number;
  112261. RG8: number;
  112262. UNSIGNED_INT_24_8: number;
  112263. DEPTH24_STENCIL8: number;
  112264. /* Multiple Render Targets */
  112265. drawBuffers(buffers: number[]): void;
  112266. readBuffer(src: number): void;
  112267. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  112268. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  112269. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  112270. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  112271. // Occlusion Query
  112272. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  112273. ANY_SAMPLES_PASSED: number;
  112274. QUERY_RESULT_AVAILABLE: number;
  112275. QUERY_RESULT: number;
  112276. }
  112277. interface WebGLBuffer {
  112278. references: number;
  112279. capacity: number;
  112280. is32Bits: boolean;
  112281. }
  112282. interface WebGLProgram {
  112283. transformFeedback?: WebGLTransformFeedback | null;
  112284. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  112285. }
  112286. interface EXT_disjoint_timer_query {
  112287. QUERY_COUNTER_BITS_EXT: number;
  112288. TIME_ELAPSED_EXT: number;
  112289. TIMESTAMP_EXT: number;
  112290. GPU_DISJOINT_EXT: number;
  112291. QUERY_RESULT_EXT: number;
  112292. QUERY_RESULT_AVAILABLE_EXT: number;
  112293. queryCounterEXT(query: WebGLQuery, target: number): void;
  112294. createQueryEXT(): WebGLQuery;
  112295. beginQueryEXT(target: number, query: WebGLQuery): void;
  112296. endQueryEXT(target: number): void;
  112297. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  112298. deleteQueryEXT(query: WebGLQuery): void;
  112299. }
  112300. interface WebGLUniformLocation {
  112301. _currentState: any;
  112302. }
  112303. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  112304. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  112305. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  112306. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  112307. interface WebGLRenderingContext {
  112308. readonly RASTERIZER_DISCARD: number;
  112309. readonly DEPTH_COMPONENT24: number;
  112310. readonly TEXTURE_3D: number;
  112311. readonly TEXTURE_2D_ARRAY: number;
  112312. readonly TEXTURE_COMPARE_FUNC: number;
  112313. readonly TEXTURE_COMPARE_MODE: number;
  112314. readonly COMPARE_REF_TO_TEXTURE: number;
  112315. readonly TEXTURE_WRAP_R: number;
  112316. readonly HALF_FLOAT: number;
  112317. readonly RGB8: number;
  112318. readonly RED_INTEGER: number;
  112319. readonly RG_INTEGER: number;
  112320. readonly RGB_INTEGER: number;
  112321. readonly RGBA_INTEGER: number;
  112322. readonly R8_SNORM: number;
  112323. readonly RG8_SNORM: number;
  112324. readonly RGB8_SNORM: number;
  112325. readonly RGBA8_SNORM: number;
  112326. readonly R8I: number;
  112327. readonly RG8I: number;
  112328. readonly RGB8I: number;
  112329. readonly RGBA8I: number;
  112330. readonly R8UI: number;
  112331. readonly RG8UI: number;
  112332. readonly RGB8UI: number;
  112333. readonly RGBA8UI: number;
  112334. readonly R16I: number;
  112335. readonly RG16I: number;
  112336. readonly RGB16I: number;
  112337. readonly RGBA16I: number;
  112338. readonly R16UI: number;
  112339. readonly RG16UI: number;
  112340. readonly RGB16UI: number;
  112341. readonly RGBA16UI: number;
  112342. readonly R32I: number;
  112343. readonly RG32I: number;
  112344. readonly RGB32I: number;
  112345. readonly RGBA32I: number;
  112346. readonly R32UI: number;
  112347. readonly RG32UI: number;
  112348. readonly RGB32UI: number;
  112349. readonly RGBA32UI: number;
  112350. readonly RGB10_A2UI: number;
  112351. readonly R11F_G11F_B10F: number;
  112352. readonly RGB9_E5: number;
  112353. readonly RGB10_A2: number;
  112354. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  112355. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  112356. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  112357. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  112358. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  112359. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  112360. 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;
  112361. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  112362. readonly TRANSFORM_FEEDBACK: number;
  112363. readonly INTERLEAVED_ATTRIBS: number;
  112364. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  112365. createTransformFeedback(): WebGLTransformFeedback;
  112366. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  112367. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  112368. beginTransformFeedback(primitiveMode: number): void;
  112369. endTransformFeedback(): void;
  112370. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  112371. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  112372. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  112373. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  112374. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  112375. }
  112376. interface ImageBitmap {
  112377. readonly width: number;
  112378. readonly height: number;
  112379. close(): void;
  112380. }
  112381. interface WebGLQuery extends WebGLObject {
  112382. }
  112383. declare var WebGLQuery: {
  112384. prototype: WebGLQuery;
  112385. new(): WebGLQuery;
  112386. };
  112387. interface WebGLSampler extends WebGLObject {
  112388. }
  112389. declare var WebGLSampler: {
  112390. prototype: WebGLSampler;
  112391. new(): WebGLSampler;
  112392. };
  112393. interface WebGLSync extends WebGLObject {
  112394. }
  112395. declare var WebGLSync: {
  112396. prototype: WebGLSync;
  112397. new(): WebGLSync;
  112398. };
  112399. interface WebGLTransformFeedback extends WebGLObject {
  112400. }
  112401. declare var WebGLTransformFeedback: {
  112402. prototype: WebGLTransformFeedback;
  112403. new(): WebGLTransformFeedback;
  112404. };
  112405. interface WebGLVertexArrayObject extends WebGLObject {
  112406. }
  112407. declare var WebGLVertexArrayObject: {
  112408. prototype: WebGLVertexArrayObject;
  112409. new(): WebGLVertexArrayObject;
  112410. };
  112411. // Type definitions for WebVR API
  112412. // Project: https://w3c.github.io/webvr/
  112413. // Definitions by: six a <https://github.com/lostfictions>
  112414. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  112415. interface VRDisplay extends EventTarget {
  112416. /**
  112417. * Dictionary of capabilities describing the VRDisplay.
  112418. */
  112419. readonly capabilities: VRDisplayCapabilities;
  112420. /**
  112421. * z-depth defining the far plane of the eye view frustum
  112422. * enables mapping of values in the render target depth
  112423. * attachment to scene coordinates. Initially set to 10000.0.
  112424. */
  112425. depthFar: number;
  112426. /**
  112427. * z-depth defining the near plane of the eye view frustum
  112428. * enables mapping of values in the render target depth
  112429. * attachment to scene coordinates. Initially set to 0.01.
  112430. */
  112431. depthNear: number;
  112432. /**
  112433. * An identifier for this distinct VRDisplay. Used as an
  112434. * association point in the Gamepad API.
  112435. */
  112436. readonly displayId: number;
  112437. /**
  112438. * A display name, a user-readable name identifying it.
  112439. */
  112440. readonly displayName: string;
  112441. readonly isConnected: boolean;
  112442. readonly isPresenting: boolean;
  112443. /**
  112444. * If this VRDisplay supports room-scale experiences, the optional
  112445. * stage attribute contains details on the room-scale parameters.
  112446. */
  112447. readonly stageParameters: VRStageParameters | null;
  112448. /**
  112449. * Passing the value returned by `requestAnimationFrame` to
  112450. * `cancelAnimationFrame` will unregister the callback.
  112451. * @param handle Define the hanle of the request to cancel
  112452. */
  112453. cancelAnimationFrame(handle: number): void;
  112454. /**
  112455. * Stops presenting to the VRDisplay.
  112456. * @returns a promise to know when it stopped
  112457. */
  112458. exitPresent(): Promise<void>;
  112459. /**
  112460. * Return the current VREyeParameters for the given eye.
  112461. * @param whichEye Define the eye we want the parameter for
  112462. * @returns the eye parameters
  112463. */
  112464. getEyeParameters(whichEye: string): VREyeParameters;
  112465. /**
  112466. * Populates the passed VRFrameData with the information required to render
  112467. * the current frame.
  112468. * @param frameData Define the data structure to populate
  112469. * @returns true if ok otherwise false
  112470. */
  112471. getFrameData(frameData: VRFrameData): boolean;
  112472. /**
  112473. * Get the layers currently being presented.
  112474. * @returns the list of VR layers
  112475. */
  112476. getLayers(): VRLayer[];
  112477. /**
  112478. * Return a VRPose containing the future predicted pose of the VRDisplay
  112479. * when the current frame will be presented. The value returned will not
  112480. * change until JavaScript has returned control to the browser.
  112481. *
  112482. * The VRPose will contain the position, orientation, velocity,
  112483. * and acceleration of each of these properties.
  112484. * @returns the pose object
  112485. */
  112486. getPose(): VRPose;
  112487. /**
  112488. * Return the current instantaneous pose of the VRDisplay, with no
  112489. * prediction applied.
  112490. * @returns the current instantaneous pose
  112491. */
  112492. getImmediatePose(): VRPose;
  112493. /**
  112494. * The callback passed to `requestAnimationFrame` will be called
  112495. * any time a new frame should be rendered. When the VRDisplay is
  112496. * presenting the callback will be called at the native refresh
  112497. * rate of the HMD. When not presenting this function acts
  112498. * identically to how window.requestAnimationFrame acts. Content should
  112499. * make no assumptions of frame rate or vsync behavior as the HMD runs
  112500. * asynchronously from other displays and at differing refresh rates.
  112501. * @param callback Define the eaction to run next frame
  112502. * @returns the request handle it
  112503. */
  112504. requestAnimationFrame(callback: FrameRequestCallback): number;
  112505. /**
  112506. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  112507. * Repeat calls while already presenting will update the VRLayers being displayed.
  112508. * @param layers Define the list of layer to present
  112509. * @returns a promise to know when the request has been fulfilled
  112510. */
  112511. requestPresent(layers: VRLayer[]): Promise<void>;
  112512. /**
  112513. * Reset the pose for this display, treating its current position and
  112514. * orientation as the "origin/zero" values. VRPose.position,
  112515. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  112516. * updated when calling resetPose(). This should be called in only
  112517. * sitting-space experiences.
  112518. */
  112519. resetPose(): void;
  112520. /**
  112521. * The VRLayer provided to the VRDisplay will be captured and presented
  112522. * in the HMD. Calling this function has the same effect on the source
  112523. * canvas as any other operation that uses its source image, and canvases
  112524. * created without preserveDrawingBuffer set to true will be cleared.
  112525. * @param pose Define the pose to submit
  112526. */
  112527. submitFrame(pose?: VRPose): void;
  112528. }
  112529. declare var VRDisplay: {
  112530. prototype: VRDisplay;
  112531. new(): VRDisplay;
  112532. };
  112533. interface VRLayer {
  112534. leftBounds?: number[] | Float32Array | null;
  112535. rightBounds?: number[] | Float32Array | null;
  112536. source?: HTMLCanvasElement | null;
  112537. }
  112538. interface VRDisplayCapabilities {
  112539. readonly canPresent: boolean;
  112540. readonly hasExternalDisplay: boolean;
  112541. readonly hasOrientation: boolean;
  112542. readonly hasPosition: boolean;
  112543. readonly maxLayers: number;
  112544. }
  112545. interface VREyeParameters {
  112546. /** @deprecated */
  112547. readonly fieldOfView: VRFieldOfView;
  112548. readonly offset: Float32Array;
  112549. readonly renderHeight: number;
  112550. readonly renderWidth: number;
  112551. }
  112552. interface VRFieldOfView {
  112553. readonly downDegrees: number;
  112554. readonly leftDegrees: number;
  112555. readonly rightDegrees: number;
  112556. readonly upDegrees: number;
  112557. }
  112558. interface VRFrameData {
  112559. readonly leftProjectionMatrix: Float32Array;
  112560. readonly leftViewMatrix: Float32Array;
  112561. readonly pose: VRPose;
  112562. readonly rightProjectionMatrix: Float32Array;
  112563. readonly rightViewMatrix: Float32Array;
  112564. readonly timestamp: number;
  112565. }
  112566. interface VRPose {
  112567. readonly angularAcceleration: Float32Array | null;
  112568. readonly angularVelocity: Float32Array | null;
  112569. readonly linearAcceleration: Float32Array | null;
  112570. readonly linearVelocity: Float32Array | null;
  112571. readonly orientation: Float32Array | null;
  112572. readonly position: Float32Array | null;
  112573. readonly timestamp: number;
  112574. }
  112575. interface VRStageParameters {
  112576. sittingToStandingTransform?: Float32Array;
  112577. sizeX?: number;
  112578. sizeY?: number;
  112579. }
  112580. interface Navigator {
  112581. getVRDisplays(): Promise<VRDisplay[]>;
  112582. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  112583. }
  112584. interface Window {
  112585. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  112586. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  112587. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  112588. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  112589. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  112590. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  112591. }
  112592. interface Gamepad {
  112593. readonly displayId: number;
  112594. }
  112595. interface XRDevice {
  112596. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  112597. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  112598. }
  112599. interface XRSession {
  112600. getInputSources(): Array<any>;
  112601. baseLayer: XRWebGLLayer;
  112602. requestFrameOfReference(type: string): Promise<void>;
  112603. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  112604. end(): Promise<void>;
  112605. requestAnimationFrame: Function;
  112606. addEventListener: Function;
  112607. }
  112608. interface XRSessionCreationOptions {
  112609. outputContext?: WebGLRenderingContext | null;
  112610. immersive?: boolean;
  112611. environmentIntegration?: boolean;
  112612. }
  112613. interface XRLayer {
  112614. getViewport: Function;
  112615. framebufferWidth: number;
  112616. framebufferHeight: number;
  112617. }
  112618. interface XRView {
  112619. projectionMatrix: Float32Array;
  112620. }
  112621. interface XRFrame {
  112622. getDevicePose: Function;
  112623. getInputPose: Function;
  112624. views: Array<XRView>;
  112625. baseLayer: XRLayer;
  112626. }
  112627. interface XRFrameOfReference {
  112628. }
  112629. interface XRWebGLLayer extends XRLayer {
  112630. framebuffer: WebGLFramebuffer;
  112631. }
  112632. declare var XRWebGLLayer: {
  112633. prototype: XRWebGLLayer;
  112634. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  112635. };